diff --git a/src/features/common/components/bars/ribbon/ribbon.component.tsx b/src/features/common/components/bars/ribbon/ribbon.component.tsx index 4827cb2f..d4954b89 100644 --- a/src/features/common/components/bars/ribbon/ribbon.component.tsx +++ b/src/features/common/components/bars/ribbon/ribbon.component.tsx @@ -1,129 +1,21 @@ "use client"; -import React, { useCallback, useEffect, useMemo, useState } from "react"; +import React from "react"; import { LayoutDictionaryModel } from "@/features/localization/models/layout-dictionary.model"; import styles from "./ribbon.module.scss"; import { BoxComponent } from "@/features/common/components/box/box.component"; -import { savePreferredLanguage } from "@/features/localization/services/ui-language.utils"; import Link from "next/link"; -import { - getSanitizedThemePickerCodeValue, - isLightThemePreference, - isSystemThemePreference, -} from "@/features/themes/services/theme.utils"; -import { RibbonPickerComponent } from "@/features/common/components/bars/ribbon/ribbon-picker/ribbon-picker.component"; -import { LightIconComponent } from "@/features/common/components/bars/ribbon/assets/light-icon.component"; -import { DarkIconComponent } from "@/features/common/components/bars/ribbon/assets/dark-icon.component"; -import { ThemeModel } from "@/features/common/models/theme.model"; -import { useAppStore } from "@/features/common/services/app.store"; -import { SystemIconComponent } from "@/features/common/components/bars/ribbon/assets/system-icon.component"; -import { - ThemeCookieValues, - ThemePickerCodeValues, -} from "@/features/common/values/theme.values"; -import { savePreferredThemeInCookie } from "@/features/themes/services/theme.client.utils"; interface RibbonComponentProps { - themeCode: ThemeCookieValues; - languageCode: string; dictionary: LayoutDictionaryModel["ribbon"]; } export const RibbonComponent: React.FC = ({ - themeCode, - languageCode, dictionary, }) => { - const theme$ = useAppStore((state) => state.theme$); - - const sanitizedThemePickerCodeValue = useMemo(() => { - return getSanitizedThemePickerCodeValue(themeCode); - }, [themeCode]); - - const [currentTheme, setCurrentTheme] = useState( - dictionary.themePicker.options.filter((element) => - isSystemThemePreference(themeCode) - ? isSystemThemePreference(element.code) - : element.code === sanitizedThemePickerCodeValue, - )[0], - ); - - const themeOptions = useMemo( - () => - dictionary.themePicker.options.map((option) => { - return { - code: option.code, - full: { - ...option, - label: option.label, - icon: isSystemThemePreference(option.code) ? ( - - ) : isLightThemePreference(option.code) ? ( - - ) : ( - - ), - }, - compact: { - ...option, - label: null, - icon: isSystemThemePreference(option.code) ? ( - - ) : isLightThemePreference(option.code) ? ( - - ) : ( - - ), - }, - }; - }), - [dictionary.themePicker.options], - ); - - const handleThemeSelection = useCallback( - async (value: ThemePickerCodeValues) => { - const themePreference = await savePreferredThemeInCookie( - value, - languageCode, - ); - - if (themePreference) { - setCurrentTheme(themePreference); - } - }, - [languageCode], - ); - - const handleLanguageSelection = useCallback(async (value: string) => { - await savePreferredLanguage(value); - }, []); - - useEffect(() => { - if (theme$) { - setCurrentTheme( - dictionary.themePicker.options.filter((element) => - isSystemThemePreference(themeCode) - ? isSystemThemePreference(element.code) - : element.code === sanitizedThemePickerCodeValue, - )[0], - ); - } - }, [ - dictionary.themePicker.options, - sanitizedThemePickerCodeValue, - theme$, - themeCode, - ]); return ( - <> - +
{dictionary.cta.title} = ({
-
- - label={null} - compactLabel={null} - icon={ - isSystemThemePreference(currentTheme.code) ? ( - - ) : isLightThemePreference(currentTheme.code) ? ( - - ) : ( - - ) - } - languageCode={languageCode} - selectedOptionCode={currentTheme.code} - handleSelection={handleThemeSelection} - options={themeOptions} - aria={{ - buttonLabel: dictionary.themePicker.button.ariaLabel, - listLabel: dictionary.themePicker.list.ariaLabel, - }} - /> -
-
- ); }; diff --git a/src/features/common/components/bars/ribbon/ribbon.module.scss b/src/features/common/components/bars/ribbon/ribbon.module.scss index 8959d4ef..7436d922 100644 --- a/src/features/common/components/bars/ribbon/ribbon.module.scss +++ b/src/features/common/components/bars/ribbon/ribbon.module.scss @@ -1,38 +1,10 @@ @use "@/libs/theme/styles/variables" as *; @use "@/libs/theme/styles/mixins" as *; -.container { - @include Container; - - background: var(--color_bg_app_bar); - border-bottom: 1px solid; - border-image-slice: 1; - border-image-source: linear-gradient( - 135deg, - rgb(76, 183, 163) 0%, - rgb(63, 89, 228) 50%, - rgb(64, 22, 160) 100% - ); -} - -.wrapper { - @include ExtendedGrid; - height: $ribbon-height; -} - -.content { - position: relative; - @include InnerContentFlex; - height: 100%; - grid-column: 1 / -1; - align-items: center; - justify-content: space-between; - - color: $neutrals-light-100-snow; -} - .cta { display: flex; + align-items: center; + justify-content: center; font-size: 0.75rem; line-height: 1.25rem; color: $Neutral0; @@ -88,11 +60,3 @@ } } -.actions { - display: flex; - gap: 0.5rem; - - @media #{$breakpoint-dimension-md} { - gap: 1rem; - } -} diff --git a/src/features/common/components/headers/header/header.component.tsx b/src/features/common/components/headers/header/header.component.tsx index 7002824d..7810c630 100644 --- a/src/features/common/components/headers/header/header.component.tsx +++ b/src/features/common/components/headers/header/header.component.tsx @@ -25,6 +25,7 @@ import { } from "@/features/common/values/theme.values"; import { ThemeModel } from "@/features/common/models/theme.model"; import { savePreferredThemeInCookie } from "@/features/themes/services/theme.client.utils"; +import { RibbonComponent } from "../../bars/ribbon/ribbon.component"; interface HeaderComponentProps { themeCode: ThemeCookieValues; @@ -65,7 +66,7 @@ export const HeaderComponent: React.FC = ({ ), }; }), - [dictionary.ribbon.themePicker.options] + [dictionary.ribbon.themePicker.options], ); const sanitizedThemePickerCodeValue = useMemo(() => { @@ -76,22 +77,22 @@ export const HeaderComponent: React.FC = ({ dictionary.ribbon.themePicker.options.filter((element) => isSystemThemePreference(themeCode) ? isSystemThemePreference(element.code) - : element.code === sanitizedThemePickerCodeValue - )[0] + : element.code === sanitizedThemePickerCodeValue, + )[0], ); const handleThemeSelection = useCallback( async (value: ThemePickerCodeValues) => { const themePreference = await savePreferredThemeInCookie( value, - languageCode + languageCode, ); if (themePreference) { setCurrentTheme(themePreference); } }, - [languageCode] + [languageCode], ); return ( @@ -102,47 +103,52 @@ export const HeaderComponent: React.FC = ({ contentClassName={styles.content} aria-label="Main navigation" > -
- +
+
-
-
-
    - {dictionary.header.links.map((link) => { - const linkPath = - languageCode === DEFAULT_LANGUAGE_CODE || link.isExternal - ? link.path - : createUrlPath([languagePathPrefix, link.path]); +
    +
    + +
    +
    +
    +
      + {dictionary.header.links.map((link) => { + const linkPath = + languageCode === DEFAULT_LANGUAGE_CODE || link.isExternal + ? link.path + : createUrlPath([languagePathPrefix, link.path]); - return ( -
    • - - {link.label} - -
    • - ); - })} -
    + + {link.label} + + + ); + })} +
+
+
+
+
-
-
-
); diff --git a/src/features/common/components/headers/header/header.module.scss b/src/features/common/components/headers/header/header.module.scss index 9a00d9dc..3400faf5 100644 --- a/src/features/common/components/headers/header/header.module.scss +++ b/src/features/common/components/headers/header/header.module.scss @@ -32,6 +32,11 @@ } .content { + display: flex; + flex-direction: column; +} + +.outerNavContainer { display: flex; width: 100%; margin: 0 auto; @@ -49,6 +54,14 @@ z-index: 100; } +.ribbonContainer { + margin-top: 0.25rem; + display: flex; + justify-content: center; + padding-bottom: 1rem; + +} + .navContainer { display: flex; justify-content: center; diff --git a/src/features/common/components/headers/mobile-header/mobile-header.component.tsx b/src/features/common/components/headers/mobile-header/mobile-header.component.tsx index 32f1080b..c636172f 100644 --- a/src/features/common/components/headers/mobile-header/mobile-header.component.tsx +++ b/src/features/common/components/headers/mobile-header/mobile-header.component.tsx @@ -12,6 +12,7 @@ import { sitePaths } from "@/features/seo/site-tree"; import { createUrlPath, getPathnameSegments } from "@/libs/utils/path.utils"; import { SiteBrandComponent } from "@/features/common/components/site-brand/site-brand.component"; import { ThemeCookieValues } from "@/features/common/values/theme.values"; +import { RibbonComponent } from "../../bars/ribbon/ribbon.component"; interface MobileHeaderComponentProps { themeCode: ThemeCookieValues; @@ -78,14 +79,21 @@ export const MobileHeaderComponent: React.FC = ({ return ( <> - + +
+ +
+
- +
- +
+
= ({ }, ]} /> +

{homeDictionary.metadata.title}