Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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?: {
Copy link
Contributor Author

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 type Column mais on doit le répéter pour chaque colonne et ça serait peut trop permissif ?

level: 2 | 3 | 4 | 5 | 6;
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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[];
};

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'
Comment on lines +64 to +71
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai ajouté de la doc sur storybook.

},
"brandTop": {
"control": { "type": null },
Expand Down
Loading