Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export type FooterProps = {
>;
style?: CSSProperties;
linkList?: FooterProps.LinkList.List;
linkHeadingWrapper?: {
level: 2 | 3 | 4 | 5 | 6;
useAriaLevel?: boolean;
};
domains?: string[];
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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) => (
Expand Down
9 changes: 8 additions & 1 deletion stories/Footer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
"brandTop": {
"control": { "type": null },
Expand Down