Skip to content

Commit 03a5867

Browse files
authored
Merge pull request #587 from vincentlaine/feat/searchBarDisabled
feat: ✨ Ajout de la possibilité de rendre le composant SearchBar disabled
2 parents 990977f + 5e6e187 commit 03a5867

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/components/DsfrSearchBar/DsfrSearchBar.stories.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export default {
2727
control: 'text',
2828
description: 'Texte à afficher si le champ de recherhe n’est pas rempli',
2929
},
30+
disabled: {
31+
control: 'boolean',
32+
description: 'Permet de désactiver le champ et le bouton, la saisie du champ et le clic sur le bouton sera impossible.',
33+
},
3034
buttonText: {
3135
control: 'text',
3236
description: 'Texte du bouton de la barre de recherche',
@@ -106,3 +110,35 @@ BarreDeRechercheLarge.args = {
106110
modelValue: '',
107111
large: true,
108112
}
113+
114+
export const BarreDeRechercheDesactivee = (args) => ({
115+
components: {
116+
DsfrSearchBar,
117+
},
118+
data () {
119+
return args
120+
},
121+
template: `
122+
<DsfrSearchBar
123+
:label="label"
124+
:placeholder="placeholder"
125+
:labelVisible="labelVisible"
126+
:button-text="buttonText"
127+
:hide-icon="hideIcon"
128+
v-model="modelValue"
129+
:large="large"
130+
:disabled="disabled"
131+
/>
132+
`,
133+
134+
})
135+
BarreDeRechercheDesactivee.args = {
136+
label: 'Label de search bar',
137+
hideIcon: false,
138+
placeholder: 'Rechercher',
139+
buttonText: '',
140+
labelVisible: false,
141+
modelValue: '',
142+
large: false,
143+
disabled: true,
144+
}

src/components/DsfrSearchBar/DsfrSearchBar.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ withDefaults(defineProps<{
1111
large?: boolean
1212
buttonText?: string
1313
modelValue?: string
14-
placeholder?: string
14+
placeholder?: string,
15+
disabled?: boolean
1516
}>(), {
1617
id: () => getRandomId('search', 'input'),
1718
label: '',
@@ -40,11 +41,13 @@ defineEmits<{
4041
:model-value="modelValue"
4142
:label-visible="false"
4243
:label="label"
44+
:disabled="disabled"
4345
@update:model-value="$emit('update:modelValue', $event)"
4446
@keydown.enter="$emit('search')"
4547
/>
4648
<DsfrButton
4749
title="Rechercher"
50+
:disabled="disabled"
4851
@click="$emit('search')"
4952
>
5053
{{ buttonText }}
@@ -56,4 +59,10 @@ defineEmits<{
5659
.fr-search-bar > .fr-label + .fr-input {
5760
margin: 0;
5861
}
62+
63+
/* Obligé de faire ça car ils ont hardcode la couleur dans le DSFR sans prendre en compte que ce champ pouvait être disabled */
64+
.fr-search-bar .fr-input:disabled {
65+
box-shadow: inset 0 -2px 0 0 var(--border-disabled-grey);
66+
color: var(--text-disabled-grey);
67+
}
5968
</style>

0 commit comments

Comments
 (0)