Skip to content

Commit cc1d5df

Browse files
committed
Add support for operator logo in footer
1 parent 648c38d commit cc1d5df

File tree

2 files changed

+104
-4
lines changed

2 files changed

+104
-4
lines changed

src/Footer.tsx

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ export type FooterProps = {
2323
cookiesManagementLinkProps?: RegisteredLinkProps;
2424
homeLinkProps: RegisteredLinkProps & { title: string };
2525
bottomItems?: FooterProps.BottomItem[];
26+
operatorLogo?: {
27+
orientation: "horizontal" | "vertical";
28+
/**
29+
* Expected ratio:
30+
* If "vertical": 9x16
31+
* If "horizontal": 16x9
32+
*/
33+
imgUrl: string;
34+
/** Textual alternative of the image, it MUST include the text present in the image*/
35+
alt: string;
36+
};
2637
classes?: Partial<
2738
Record<
2839
| "root"
@@ -37,7 +48,9 @@ export type FooterProps = {
3748
| "bottomList"
3849
| "bottomItem"
3950
| "bottomLink"
40-
| "bottomCopy",
51+
| "bottomCopy"
52+
| "brandLink"
53+
| "logo",
4154
string
4255
>
4356
>;
@@ -83,6 +96,7 @@ export const Footer = memo(
8396
personalDataLinkProps,
8497
cookiesManagementLinkProps,
8598
bottomItems = [],
99+
operatorLogo,
86100
...rest
87101
} = props;
88102

@@ -108,9 +122,39 @@ export const Footer = memo(
108122
classes.brand
109123
)}
110124
>
111-
<Link {...homeLinkProps}>
112-
<p className={fr.cx("fr-logo")}>{brandTop}</p>
113-
</Link>
125+
{(() => {
126+
const children = <p className={fr.cx("fr-logo")}>{brandTop}</p>;
127+
128+
return operatorLogo !== undefined ? (
129+
children
130+
) : (
131+
<Link {...homeLinkProps}>{children}</Link>
132+
);
133+
})()}
134+
{operatorLogo !== undefined && (
135+
<Link
136+
{...homeLinkProps}
137+
className={cx(
138+
fr.cx("fr-footer__brand-link"),
139+
classes.brandLink,
140+
homeLinkProps.className
141+
)}
142+
>
143+
<img
144+
className={cx(fr.cx("fr-footer__logo"), classes.logo)}
145+
style={(() => {
146+
switch (operatorLogo.orientation) {
147+
case "vertical":
148+
return { "width": "3.5rem" };
149+
case "horizontal":
150+
return { "maxWidth": "9.0625rem" };
151+
}
152+
})()}
153+
src={operatorLogo.imgUrl}
154+
alt={operatorLogo.alt}
155+
/>
156+
</Link>
157+
)}
114158
</div>
115159
<div className={cx(fr.cx("fr-footer__content"), classes.content)}>
116160
{contentDescription !== undefined && (

stories/Footer.stories.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { sectionName } from "./sectionName";
55
import { getStoryFactory } from "./getStory";
66
import { assert } from "tsafe/assert";
77
import type { Equals } from "tsafe";
8+
import placeholder_9x16ImgUrl from "./assets/placeholder.9x16.png";
9+
import placeholder_16x9ImgUrl from "./assets/placeholder.16x9.png";
810

911
const { meta, getStory } = getStoryFactory({
1012
sectionName,
@@ -86,3 +88,57 @@ export const Default = getStory({
8688
"title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)"
8789
}
8890
});
91+
92+
export const FooterWithVerticalOperatorLogo = getStory({
93+
"brandTop": (
94+
<>
95+
INTITULE
96+
<br />
97+
OFFICIEL
98+
</>
99+
),
100+
"accessibility": "fully compliant",
101+
"contentDescription": `
102+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
103+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
104+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
105+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
106+
eu fugiat nulla pariatur.
107+
`,
108+
"homeLinkProps": {
109+
"href": "/",
110+
"title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)"
111+
},
112+
"operatorLogo": {
113+
"orientation": "vertical",
114+
"imgUrl": placeholder_9x16ImgUrl,
115+
"alt": "[À MODIFIER - texte alternatif de l’image]"
116+
}
117+
});
118+
119+
export const FooterWithHorizontalOperatorLogo = getStory({
120+
"brandTop": (
121+
<>
122+
INTITULE
123+
<br />
124+
OFFICIEL
125+
</>
126+
),
127+
"accessibility": "fully compliant",
128+
"contentDescription": `
129+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
130+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
131+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
132+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
133+
eu fugiat nulla pariatur.
134+
`,
135+
"homeLinkProps": {
136+
"href": "/",
137+
"title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)"
138+
},
139+
"operatorLogo": {
140+
"orientation": "horizontal",
141+
"imgUrl": placeholder_16x9ImgUrl,
142+
"alt": "[À MODIFIER - texte alternatif de l’image]"
143+
}
144+
});

0 commit comments

Comments
 (0)