-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(footer): add heading level customisation on column name #349
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,10 @@ export type FooterProps = { | |
>; | ||
style?: CSSProperties; | ||
linkList?: FooterProps.LinkList.List; | ||
linkHeadingWrapper?: { | ||
level: 2 | 3 | 4 | 5 | 6; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On pourrait aussi ne pas permettre de mettre un heading ici et de pouvori mettre un simple p par exemple. A voir aussi si on ne commence pas à 3. |
||
useAriaLevel?: boolean; | ||
}; | ||
domains?: string[]; | ||
}; | ||
|
||
|
@@ -166,6 +170,9 @@ export const Footer = memo( | |
homeLinkProps: homeLinkProps_prop, | ||
style, | ||
linkList, | ||
linkHeadingWrapper = { | ||
level: 3 | ||
}, | ||
domains = ["info.gouv.fr", "service-public.fr", "legifrance.gouv.fr", "data.gouv.fr"], | ||
...rest | ||
} = props; | ||
|
@@ -200,6 +207,8 @@ export const Footer = memo( | |
|
||
const { main: mainPartnersLogo, sub: subPartnersLogos = [] } = partnersLogos ?? {}; | ||
|
||
const LinkHeadingLevel: "h2" | "h3" | "h4" | "h5" | "h6" = `h${linkHeadingWrapper.level}`; | ||
|
||
return ( | ||
<footer | ||
id={rootId} | ||
|
@@ -230,11 +239,22 @@ export const Footer = memo( | |
"fr-col-md-2" | ||
)} | ||
> | ||
{column?.categoryName && ( | ||
<h3 className={fr.cx("fr-footer__top-cat")}> | ||
{column?.categoryName} | ||
</h3> | ||
)} | ||
{column?.categoryName && | ||
(linkHeadingWrapper.useAriaLevel ? ( | ||
<div | ||
role="heading" | ||
aria-level={linkHeadingWrapper.level} | ||
className={fr.cx("fr-footer__top-cat")} | ||
> | ||
{column.categoryName} | ||
</div> | ||
) : ( | ||
<LinkHeadingLevel | ||
className={fr.cx("fr-footer__top-cat")} | ||
> | ||
{column.categoryName} | ||
</LinkHeadingLevel> | ||
))} | ||
<ul className={fr.cx("fr-footer__top-list")}> | ||
{column?.links.map( | ||
(linkItem, linkItemIndex) => ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,14 @@ const { meta, getStory } = getStoryFactory({ | |
"By default it's Etalab v2. [You can provide a custom React node](#with-custom-license)" | ||
}, | ||
"linkList": { | ||
"controls": { "type": null } | ||
"controls": { "type": null }, | ||
"description": | ||
"Customizable list element for footers. It allows you to display a categorized list of links tailored to various needs, particularly for websites requiring a structured and accessible footer." | ||
}, | ||
"linkHeadingWrapper": { | ||
"controls": { "type": null }, | ||
"description": | ||
'Allow to set a custom heading level on the column title and use a `<div role="heading" aria-level="level">` for SEO optimisation' | ||
Comment on lines
+64
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'ai ajouté de la doc sur storybook. |
||
}, | ||
"brandTop": { | ||
"control": { "type": null }, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je l'ia placé dans une variable à part pour éviter les intégrations actuelles. Sinon on peut partir aussi sur la modification de la variable
linkList
sous forme de "hack" où l'on a soit un objet, soit un tableau. Si un tableau, on garde le même comportement. Si un object, on retrouve à l'intérieur les infos sur la column. On peut aussi le mettre sur le typeColumn
mais on doit le répéter pour chaque colonne et ça serait peut trop permissif ?