From bf247fa2b5b6735231ff88e052c808f0b0677f7b Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Wed, 22 May 2024 11:14:53 +0200 Subject: [PATCH] fix: tweak page layout --- .../DynamicContent/OverviewTable/index.tsx | 69 ++++++++++++++++--- .../OverviewTable/overviewTable.module.css | 16 ++++- .../DynamicContent/dynamicContent.module.css | 1 - .../Loyalty/Blocks/DynamicContent/index.tsx | 67 +++++++++--------- 4 files changed, 111 insertions(+), 42 deletions(-) diff --git a/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx b/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx index dffb7c870..3b768963c 100644 --- a/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx +++ b/components/Loyalty/Blocks/DynamicContent/OverviewTable/index.tsx @@ -2,6 +2,7 @@ import { useState } from "react" +import { Lang } from "@/constants/languages" import { _ } from "@/lib/translation" import CheckCircle from "@/components/Icons/CheckCircle" @@ -20,6 +21,63 @@ import { LevelSummaryProps, } from "@/types/components/loyalty/blocks" +// These should ultimately be fetched from Contentstack +const titleTranslations = { + [Lang.en]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + // TODO: Add translations for the following languages + [Lang.da]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + [Lang.no]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + [Lang.sv]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + [Lang.fi]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], + [Lang.de]: [ + { text: "7 delightful levels", highlight: true }, + { text: "of friendship", highlight: false }, + ], +} + +type TitleTranslation = { + text: string + highlight: boolean +} + +type OverviewTableTitleProps = { texts: TitleTranslation[] } + +function OverviewTableTitle({ texts }: OverviewTableTitleProps) { + return ( + + {texts.map(({ text, highlight }, idx) => ( + <> + <span key={idx} className={highlight ? styles.highlight : ""}> + {text} + </span> + {idx < texts.length - 1 && " "} + </> + ))} + + ) +} + function getLevelByTier(tier: number) { return levelsData.levels.find( (level) => level.tier === tier @@ -83,17 +141,10 @@ export default function OverviewTable() { label: level.name, value: level.tier, })) + return (
- - {_("7 delightful levels of friendship")} - +

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do diff --git a/components/Loyalty/Blocks/DynamicContent/OverviewTable/overviewTable.module.css b/components/Loyalty/Blocks/DynamicContent/OverviewTable/overviewTable.module.css index 27ac0e8cd..d017407b0 100644 --- a/components/Loyalty/Blocks/DynamicContent/OverviewTable/overviewTable.module.css +++ b/components/Loyalty/Blocks/DynamicContent/OverviewTable/overviewTable.module.css @@ -1,15 +1,29 @@ .container { background-color: var(--Main-Brand-PalePeach); + left: 50%; + margin-top: -1.6rem; + margin-left: -50vw; + margin-right: -50vw; + margin-bottom: -9.3rem; /* Based on the MaxWidth's 1.6rem + the LoyaltyPage's 7.7rem bottom margins */ + position: relative; + right: 50%; + width: 100dvw; + padding: 1.6rem; } .title { font-family: var(--typography-Title1-Desktop-fontFamily), inherit; } +.highlight { + color: var(--Base-Text-Primary-Accent); +} + .preamble { color: var(--Base-Text-Primary-High-contrast); font-size: var(--typography-Body-Regular-fontSize); line-height: 150%; + margin: 0; } .columns { @@ -76,7 +90,7 @@ position: absolute; position: absolute; top: 0; - bottom: 0; + bottom: 1.6rem; left: 50%; right: 0; z-index: 1; diff --git a/components/Loyalty/Blocks/DynamicContent/dynamicContent.module.css b/components/Loyalty/Blocks/DynamicContent/dynamicContent.module.css index b1ebc5a58..9cba2379c 100644 --- a/components/Loyalty/Blocks/DynamicContent/dynamicContent.module.css +++ b/components/Loyalty/Blocks/DynamicContent/dynamicContent.module.css @@ -1,7 +1,6 @@ .container { display: grid; gap: 2.4rem; - overflow: hidden; margin-right: -1.6rem; padding-right: 1.6rem; } diff --git a/components/Loyalty/Blocks/DynamicContent/index.tsx b/components/Loyalty/Blocks/DynamicContent/index.tsx index 3e8db8392..eca1b1123 100644 --- a/components/Loyalty/Blocks/DynamicContent/index.tsx +++ b/components/Loyalty/Blocks/DynamicContent/index.tsx @@ -29,39 +29,44 @@ function DynamicComponentBlock({ component }: DynamicComponentProps) { export default function DynamicContent({ dynamicContent, }: DynamicContentProps) { + const displayHeader = !!( + dynamicContent.title || + dynamicContent.subtitle || + dynamicContent.title + ) return (

-
- {dynamicContent.title && ( - - {dynamicContent.title} - - )} - {dynamicContent.link ? ( - - {dynamicContent.link.text} - - ) : null} - {dynamicContent.subtitle && ( - - {dynamicContent.subtitle} - - )} -
-
- -
+ {displayHeader && ( +
+ {dynamicContent.title && ( + + {dynamicContent.title} + + )} + {dynamicContent.link ? ( + + {dynamicContent.link.text} + + ) : null} + {dynamicContent.subtitle && ( + + {dynamicContent.subtitle} + + )} +
+ )} +
) }