From 77e04e0cff1da7e073e3b032ed2e716cd2dd6808 Mon Sep 17 00:00:00 2001 From: Pavel Klibani Date: Thu, 26 Sep 2024 15:47:03 +0200 Subject: [PATCH] fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Feat(web-react): Introduce Footer component #DS-1368 --- .../examples/FooterContent.stories.tsx | 261 +++++++++--------- 1 file changed, 135 insertions(+), 126 deletions(-) diff --git a/packages/web-react/docs/stories/examples/FooterContent.stories.tsx b/packages/web-react/docs/stories/examples/FooterContent.stories.tsx index f601187f3f..e43e0f0284 100644 --- a/packages/web-react/docs/stories/examples/FooterContent.stories.tsx +++ b/packages/web-react/docs/stories/examples/FooterContent.stories.tsx @@ -4,6 +4,7 @@ import { Container } from '../../../src/components/Container'; import { Divider } from '../../../src/components/Divider'; import { Flex } from '../../../src/components/Flex'; import { Footer } from '../../../src/components/Footer'; +import FooterLinkFactory from '../../../src/components/Footer/demo/FooterLinkFactory'; import { Grid } from '../../../src/components/Grid'; import { Icon } from '../../../src/components/Icon'; import { Link } from '../../../src/components/Link'; @@ -21,6 +22,7 @@ type FooterCompositionsProps = { numberOfLinkColumns: GridColumns; showDividers: boolean; showLanguageSwitch: boolean; + showProductLogo: boolean; showSecondaryLinks: boolean; showSocialMediaButtons: boolean; }; @@ -44,7 +46,7 @@ export default { }, numberOfLinkColumns: { control: 'select', - options: [0, 1, 2, 3, 4], + options: [0, 1, 2, 3, 4, 5, 6, 7, 8], table: { defaultValue: { summary: 4 }, }, @@ -64,6 +66,13 @@ export default { defaultValue: { summary: true }, }, }, + showProductLogo: { + control: 'boolean', + description: 'Show product logo', + table: { + defaultValue: { summary: true }, + }, + }, showSecondaryLinks: { control: 'boolean', description: 'Show secondary links', @@ -85,11 +94,32 @@ export default { numberOfLinkColumns: 4, showDividers: true, showLanguageSwitch: true, + showProductLogo: true, showSecondaryLinks: true, showSocialMediaButtons: true, }, }; +type NavLinkColumnFactoryType = { + id: string; + headline: JSX.Element | string; + numOfLinks: number; + withNestedLinks?: boolean; +}; + +const NavLinkColumnFactory = ({ id, headline, numOfLinks, withNestedLinks = false }: NavLinkColumnFactoryType) => { + return ( + + ); +}; + export const FooterCompositions = (args: FooterCompositionsProps) => { const { headingsWithLink, @@ -97,18 +127,48 @@ export const FooterCompositions = (args: FooterCompositionsProps) => { numberOfLinkColumns, showDividers, showLanguageSwitch, + showProductLogo, showSecondaryLinks, showSocialMediaButtons, } = args; const logoRowColumns = () => { - let count = 1; + let count = 0; + if (showProductLogo) count += 1; if (showSocialMediaButtons) count += 1; if (showLanguageSwitch) count += 1; return count as GridColumns; }; + const getElementPosition = (element) => { + switch (element) { + case 'socialMediaButtons': + if (!showProductLogo && showLanguageSwitch) { + return 'left'; + } + + if (showProductLogo && !showLanguageSwitch) { + return 'right'; + } + + return 'center'; + + case 'languageSwitch': + if (!showProductLogo && !showSocialMediaButtons) { + return 'center'; + } + + return 'right'; + + case 'productLogo': + return showSocialMediaButtons || showLanguageSwitch ? 'left' : 'center'; + + default: + return 'center'; + } + }; + const columnHeading = (text: string) => { return headingsWithLink ? {text} : text; }; @@ -122,7 +182,7 @@ export const FooterCompositions = (args: FooterCompositionsProps) => { cols={{ mobile: 1, tablet: numberOfLinkColumns > 2 ? 2 : numberOfLinkColumns, - desktop: numberOfLinkColumns, + desktop: numberOfLinkColumns <= 5 ? numberOfLinkColumns : 4, }} spacing="space-800" marginBottom={showDividers ? undefined : 'space-900'} @@ -130,136 +190,83 @@ export const FooterCompositions = (args: FooterCompositionsProps) => { {/* Navigation links 1 */} {numberOfLinkColumns >= 1 && (
- + {nestedLinkBlocks && ( - + )}
)} {/* Navigation links 2 */} {numberOfLinkColumns >= 2 && ( - + )} {/* Navigation links 3 */} {numberOfLinkColumns >= 3 && ( - + )} {/* Navigation links 4 */} - {numberOfLinkColumns === 4 && ( - + {numberOfLinkColumns >= 4 && ( + + )} + + {/* Navigation links 5 */} + {numberOfLinkColumns >= 5 && ( + + )} + + {/* Navigation links 6 */} + {numberOfLinkColumns >= 6 && ( + + )} + + {/* Navigation links 7 */} + {numberOfLinkColumns >= 7 && ( + + )} + + {/* Navigation links 8 */} + {numberOfLinkColumns >= 8 && ( + )} )} @@ -276,15 +283,17 @@ export const FooterCompositions = (args: FooterCompositionsProps) => { marginBottom={showDividers || (!showDividers && !showSecondaryLinks) ? undefined : 'space-900'} > {/* Product logo */} -
- - {defaultSvgLogo} - -
+ {showProductLogo && ( +
+ + {defaultSvgLogo} + +
+ )} {/* Flex with social media links */} {showSocialMediaButtons && ( - +
  • Facebook @@ -320,7 +329,7 @@ export const FooterCompositions = (args: FooterCompositionsProps) => { {/* Language switch */} {showLanguageSwitch && ( -
    +