Skip to content

Commit 0ccfb61

Browse files
authored
Merge pull request #131 from laruiss/develop
Develop
2 parents 97dfbc9 + 75d07ec commit 0ccfb61

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

src/components/DsfrHeader/DsfrHeader.stories.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ export default {
4141
},
4242
quickLinks: {
4343
control: 'array',
44-
description: 'Tableau des liens d’accès rapide, chaque objet contiendra les props suivantes :\n\n- label: (`\'Notifications\'`, par ex.)\n\n- path: (`\'/notification\'` par ex.)\n\n- `icon` pour le nom de l’icône à afficher (`\'ri-phone-line\'` par ex.)\n\n- `iconRight` (`true` pour afficher l’icône à droite, `false` par défaut)',
44+
description: `Tableau des liens d’accès rapide, chaque objet contiendra les props suivantes :
45+
46+
- \`label\`: (\`'Notifications'\`, par ex.)
47+
- \`path\`: (\`'/notification'\` par ex.)
48+
- \`icon\` pour le nom de l’icône à afficher (\`'ri-phone-line'\` par ex.)
49+
- \`iconRight\` (\`true\` pour afficher l’icône à droite, \`false\` par défaut)
50+
- \`button\`: (\`true\` pour avoir une balise \`button\`, \`false\` pour laisser en balise \`a\`)`,
4551
},
4652
modelValue: {
4753
control: 'text',
4854
description: 'Contenu du champs de saisie de la barre de recherche',
4955
},
5056
actionOnLogo: { action: 'clicked on logo' },
57+
actionOnLink: { action: 'clicked on quickLink' },
5158
onChangeSearchInput: { action: 'search changed' },
5259
},
5360
}
@@ -65,6 +72,15 @@ export const EnTete = (args, { argTypes }) => ({
6572
data () {
6673
return {
6774
...args,
75+
quickLincks: args.quickLinks.map((link, idx) => {
76+
if (idx === 0) {
77+
link.onClick = ($event) => {
78+
$event.preventDefault()
79+
this.actionOnLink()
80+
}
81+
}
82+
return link
83+
}),
6884
}
6985
},
7086
template: `
@@ -99,8 +115,8 @@ EnTete.args = {
99115
modelValue: '',
100116
homeTo: '#',
101117
quickLinks: [
118+
{ label: 'Lien2', path: '', icon: 'ri-notification-3-line', iconOnly: true, button: true },
102119
{ label: 'Lien1', path: '/path1', icon: '' },
103-
{ label: 'Lien2', path: '/path2', icon: 'ri-notification-3-line' },
104120
{ label: 'Lien3', path: '/path3', icon: 'ri-phone-line', iconRight: true },
105121
],
106122
}

src/components/DsfrHeader/DsfrHeader.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,17 @@ export default {
171171
default: () => 'Gouvernement',
172172
},
173173
},
174+
174175
emits: ['update:modelValue', 'search'],
176+
175177
data () {
176178
return {
177179
menuOpened: false,
178180
searchModalOpened: false,
179181
modalOpened: false,
180182
}
181183
},
184+
182185
methods: {
183186
hideModal () {
184187
this.modalOpened = false

src/components/DsfrHeader/DsfrHeaderMenuLink.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'flex': true,
99
'reverse': iconRight,
1010
}"
11+
@click.stop="onClick"
1112
>
1213
<VIcon
1314
v-if="icon"
@@ -28,8 +29,9 @@ export default {
2829
props: {
2930
path: {
3031
type: String,
31-
default: '',
32+
default: undefined,
3233
},
34+
button: Boolean,
3335
iconOnly: Boolean,
3436
iconRight: Boolean,
3537
icon: {
@@ -40,16 +42,24 @@ export default {
4042
type: String,
4143
default: '',
4244
},
45+
onClick: {
46+
type: Function,
47+
default: () => {},
48+
},
4349
},
50+
4451
computed: {
4552
is () {
53+
if (this.button) {
54+
return 'button'
55+
}
4656
return this.path.startsWith('http') ? 'a' : 'router-link'
4757
},
4858
to () {
49-
return this.path.startsWith('http') ? undefined : this.path
59+
return (this.button || this.path.startsWith('http')) ? undefined : this.path
5060
},
5161
href () {
52-
return this.path.startsWith('http') ? this.path : undefined
62+
return (!this.button && this.path.startsWith('http')) ? this.path : undefined
5363
},
5464
},
5565
}

src/components/DsfrHeader/DsfrHeaderMenuLinks.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
class="fr-links-group"
44
>
55
<li
6-
v-for="quickLink in links"
7-
:key="quickLink.path"
6+
v-for="(quickLink, index) in links"
7+
:key="index"
88
>
99
<DsfrHeaderMenuLink
1010
v-bind="quickLink"
@@ -15,20 +15,19 @@
1515

1616
<script>
1717
import DsfrHeaderMenuLink from './DsfrHeaderMenuLink.vue'
18+
1819
export default {
1920
name: 'DsfrMenuLinks',
2021
components: {
2122
DsfrHeaderMenuLink,
2223
},
24+
2325
props: {
2426
links: {
2527
type: Array,
2628
default: () => undefined,
2729
},
2830
},
29-
data () {
30-
return {}
31-
},
3231
}
3332
</script>
3433

0 commit comments

Comments
 (0)