Skip to content

Commit

Permalink
feat(DsfrFooter): ✨ gère l’attribut title des liens
Browse files Browse the repository at this point in the history
fix #884
  • Loading branch information
laruiss committed Sep 15, 2024
1 parent d6c94f0 commit 2fbbd1a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/components/DsfrFooter/DsfrFooter.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type DsfrFooterLinkProps = {
onClick?: ($event: MouseEvent) => void
to?: RouteLocationRaw
href?: string
title?: string
}

export type DsfrFooterLinkListProps = {
Expand All @@ -44,15 +45,15 @@ export type DsfrFooterProps = {
descText?: string
beforeMandatoryLinks?: DsfrFooterLinkProps[]
afterMandatoryLinks?: DsfrFooterLinkProps[]
mandatoryLinks?: { label: string, to: RouteLocationRaw | undefined }[]
ecosystemLinks?: { label: string, href: string }[]
mandatoryLinks?: { label: string, to: RouteLocationRaw | undefined, title?: string }[]
ecosystemLinks?: { label: string, href: string, title: string, [key: string]: string }[]
operatorLinkText?: string
operatorTo?: RouteLocationRaw | undefined
operatorImgStyle?: StyleValue
operatorImgSrc?: string
operatorImgAlt?: string
licenceTo?: string
licenceLinkProps?: { href: string } | { to: RouteLocationRaw | undefined }
licenceLinkProps?: ({ href: string } | { to: RouteLocationRaw | undefined }) & Record<string, string>
licenceText?: string
licenceName?: string
}
24 changes: 18 additions & 6 deletions src/components/DsfrFooter/DsfrFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,22 @@ const props = withDefaults(defineProps<DsfrFooterProps>(), {
{
label: 'info.gouv.fr',
href: 'https://info.gouv.fr',
title: 'Informations gouvernementales, nouvelle fenêtre',
},
{
label: 'service-public.fr',
href: 'https://service-public.fr',
title: 'Informations et démarches administratives, nouvelle fenêtre',
},
{
label: 'legifrance.gouv.fr',
href: 'https://legifrance.gouv.fr',
title: 'Service public de diffusion du droit, nouvelle fenêtre',
},
{
label: 'data.gouv.fr',
href: 'https://data.gouv.fr',
title: 'Plateforme des données publiques, nouvelle fenêtre',
},
],
operatorLinkText: 'Revenir à l’accueil',
Expand Down Expand Up @@ -95,6 +99,12 @@ const isExternalLink = computed(() => {
const to = props.licenceTo || (props.licenceLinkProps as { to: RouteLocationRaw }).to
return to && typeof to === 'string' && to.startsWith('http')
})
const licenceLinkAttrs = computed(() => {
const { to, href, ...attrs } = props.licenceLinkProps ?? {}
return attrs
})
const routerLinkLicenceTo = computed(() => {
return isExternalLink.value ? '' : props.licenceTo
})
Expand Down Expand Up @@ -184,17 +194,19 @@ const externalOperatorLink = computed(() => {
</p>
<ul class="fr-footer__content-list">
<li
v-for="(link, index) in ecosystemLinks"
v-for="({ href, label, title, ...attrs }, index) in ecosystemLinks"
:key="index"
class="fr-footer__content-item"
>
<a
class="fr-footer__content-link"
:href="link.href"
:href="href"
target="_blank"
rel="noopener noreferrer"
:title="title"
v-bind="attrs"
>
{{ link.label }}
{{ label }}
</a>
</li>
</ul>
Expand Down Expand Up @@ -225,11 +237,11 @@ const externalOperatorLink = computed(() => {
<component
:is="isExternalLink ? 'a' : 'RouterLink'"
class="fr-link-licence no-content-after"
:to="isExternalLink ? null : routerLinkLicenceTo"
:href="aLicenceHref"
:to="isExternalLink ? undefined : routerLinkLicenceTo"
:href="isExternalLink ? aLicenceHref : undefined"
:target="isExternalLink ? '_blank' : undefined"
rel="noopener noreferrer"
v-bind="licenceLinkProps"
v-bind="licenceLinkAttrs"
>
{{ licenceName }}
</component>
Expand Down

0 comments on commit 2fbbd1a

Please sign in to comment.