Skip to content

Commit 2fbbd1a

Browse files
committed
feat(DsfrFooter): ✨ gère l’attribut title des liens
fix #884
1 parent d6c94f0 commit 2fbbd1a

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/components/DsfrFooter/DsfrFooter.types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type DsfrFooterLinkProps = {
2424
onClick?: ($event: MouseEvent) => void
2525
to?: RouteLocationRaw
2626
href?: string
27+
title?: string
2728
}
2829

2930
export type DsfrFooterLinkListProps = {
@@ -44,15 +45,15 @@ export type DsfrFooterProps = {
4445
descText?: string
4546
beforeMandatoryLinks?: DsfrFooterLinkProps[]
4647
afterMandatoryLinks?: DsfrFooterLinkProps[]
47-
mandatoryLinks?: { label: string, to: RouteLocationRaw | undefined }[]
48-
ecosystemLinks?: { label: string, href: string }[]
48+
mandatoryLinks?: { label: string, to: RouteLocationRaw | undefined, title?: string }[]
49+
ecosystemLinks?: { label: string, href: string, title: string, [key: string]: string }[]
4950
operatorLinkText?: string
5051
operatorTo?: RouteLocationRaw | undefined
5152
operatorImgStyle?: StyleValue
5253
operatorImgSrc?: string
5354
operatorImgAlt?: string
5455
licenceTo?: string
55-
licenceLinkProps?: { href: string } | { to: RouteLocationRaw | undefined }
56+
licenceLinkProps?: ({ href: string } | { to: RouteLocationRaw | undefined }) & Record<string, string>
5657
licenceText?: string
5758
licenceName?: string
5859
}

src/components/DsfrFooter/DsfrFooter.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,22 @@ const props = withDefaults(defineProps<DsfrFooterProps>(), {
5353
{
5454
label: 'info.gouv.fr',
5555
href: 'https://info.gouv.fr',
56+
title: 'Informations gouvernementales, nouvelle fenêtre',
5657
},
5758
{
5859
label: 'service-public.fr',
5960
href: 'https://service-public.fr',
61+
title: 'Informations et démarches administratives, nouvelle fenêtre',
6062
},
6163
{
6264
label: 'legifrance.gouv.fr',
6365
href: 'https://legifrance.gouv.fr',
66+
title: 'Service public de diffusion du droit, nouvelle fenêtre',
6467
},
6568
{
6669
label: 'data.gouv.fr',
6770
href: 'https://data.gouv.fr',
71+
title: 'Plateforme des données publiques, nouvelle fenêtre',
6872
},
6973
],
7074
operatorLinkText: 'Revenir à l’accueil',
@@ -95,6 +99,12 @@ const isExternalLink = computed(() => {
9599
const to = props.licenceTo || (props.licenceLinkProps as { to: RouteLocationRaw }).to
96100
return to && typeof to === 'string' && to.startsWith('http')
97101
})
102+
103+
const licenceLinkAttrs = computed(() => {
104+
const { to, href, ...attrs } = props.licenceLinkProps ?? {}
105+
return attrs
106+
})
107+
98108
const routerLinkLicenceTo = computed(() => {
99109
return isExternalLink.value ? '' : props.licenceTo
100110
})
@@ -184,17 +194,19 @@ const externalOperatorLink = computed(() => {
184194
</p>
185195
<ul class="fr-footer__content-list">
186196
<li
187-
v-for="(link, index) in ecosystemLinks"
197+
v-for="({ href, label, title, ...attrs }, index) in ecosystemLinks"
188198
:key="index"
189199
class="fr-footer__content-item"
190200
>
191201
<a
192202
class="fr-footer__content-link"
193-
:href="link.href"
203+
:href="href"
194204
target="_blank"
195205
rel="noopener noreferrer"
206+
:title="title"
207+
v-bind="attrs"
196208
>
197-
{{ link.label }}
209+
{{ label }}
198210
</a>
199211
</li>
200212
</ul>
@@ -225,11 +237,11 @@ const externalOperatorLink = computed(() => {
225237
<component
226238
:is="isExternalLink ? 'a' : 'RouterLink'"
227239
class="fr-link-licence no-content-after"
228-
:to="isExternalLink ? null : routerLinkLicenceTo"
229-
:href="aLicenceHref"
240+
:to="isExternalLink ? undefined : routerLinkLicenceTo"
241+
:href="isExternalLink ? aLicenceHref : undefined"
230242
:target="isExternalLink ? '_blank' : undefined"
231243
rel="noopener noreferrer"
232-
v-bind="licenceLinkProps"
244+
v-bind="licenceLinkAttrs"
233245
>
234246
{{ licenceName }}
235247
</component>

0 commit comments

Comments
 (0)