Skip to content

Commit 56a80bf

Browse files
committed
add ribbon to header component and update styles
1 parent 1ff3f2a commit 56a80bf

2 files changed

Lines changed: 61 additions & 42 deletions

File tree

src/features/common/components/headers/header/header.component.tsx

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from "@/features/common/values/theme.values";
2626
import { ThemeModel } from "@/features/common/models/theme.model";
2727
import { savePreferredThemeInCookie } from "@/features/themes/services/theme.client.utils";
28+
import { RibbonComponent } from "../../bars/ribbon/ribbon.component";
2829

2930
interface HeaderComponentProps {
3031
themeCode: ThemeCookieValues;
@@ -65,7 +66,7 @@ export const HeaderComponent: React.FC<HeaderComponentProps> = ({
6566
),
6667
};
6768
}),
68-
[dictionary.ribbon.themePicker.options]
69+
[dictionary.ribbon.themePicker.options],
6970
);
7071

7172
const sanitizedThemePickerCodeValue = useMemo(() => {
@@ -76,22 +77,22 @@ export const HeaderComponent: React.FC<HeaderComponentProps> = ({
7677
dictionary.ribbon.themePicker.options.filter((element) =>
7778
isSystemThemePreference(themeCode)
7879
? isSystemThemePreference(element.code)
79-
: element.code === sanitizedThemePickerCodeValue
80-
)[0]
80+
: element.code === sanitizedThemePickerCodeValue,
81+
)[0],
8182
);
8283

8384
const handleThemeSelection = useCallback(
8485
async (value: ThemePickerCodeValues) => {
8586
const themePreference = await savePreferredThemeInCookie(
8687
value,
87-
languageCode
88+
languageCode,
8889
);
8990

9091
if (themePreference) {
9192
setCurrentTheme(themePreference);
9293
}
9394
},
94-
[languageCode]
95+
[languageCode],
9596
);
9697

9798
return (
@@ -102,47 +103,52 @@ export const HeaderComponent: React.FC<HeaderComponentProps> = ({
102103
contentClassName={styles.content}
103104
aria-label="Main navigation"
104105
>
105-
<div className={styles.brand}>
106-
<SiteBrandComponent
107-
path={languagePathPrefix}
108-
languageCode={languageCode}
109-
/>
106+
<div className={styles.ribbonContainer}>
107+
<RibbonComponent dictionary={dictionary.ribbon} />
110108
</div>
111-
<div className={styles.navContainer}>
112-
<div className={styles.navTabs}>
113-
<ul className={styles.navList}>
114-
{dictionary.header.links.map((link) => {
115-
const linkPath =
116-
languageCode === DEFAULT_LANGUAGE_CODE || link.isExternal
117-
? link.path
118-
: createUrlPath([languagePathPrefix, link.path]);
109+
<div className={styles.outerNavContainer}>
110+
<div className={styles.brand}>
111+
<SiteBrandComponent
112+
path={languagePathPrefix}
113+
languageCode={languageCode}
114+
/>
115+
</div>
116+
<div className={styles.navContainer}>
117+
<div className={styles.navTabs}>
118+
<ul className={styles.navList}>
119+
{dictionary.header.links.map((link) => {
120+
const linkPath =
121+
languageCode === DEFAULT_LANGUAGE_CODE || link.isExternal
122+
? link.path
123+
: createUrlPath([languagePathPrefix, link.path]);
119124

120-
return (
121-
<li
122-
className={styles.navList__item}
123-
key={link.label}
124-
data-active={topSegmentPath === link.path}
125-
>
126-
<Link
127-
{...(link.isExternal
128-
? { target: "_blank", rel: "noopener noreferrer" }
129-
: {})}
130-
href={linkPath}
125+
return (
126+
<li
127+
className={styles.navList__item}
128+
key={link.label}
129+
data-active={topSegmentPath === link.path}
131130
>
132-
{link.label}
133-
</Link>
134-
</li>
135-
);
136-
})}
137-
</ul>
131+
<Link
132+
{...(link.isExternal
133+
? { target: "_blank", rel: "noopener noreferrer" }
134+
: {})}
135+
href={linkPath}
136+
>
137+
{link.label}
138+
</Link>
139+
</li>
140+
);
141+
})}
142+
</ul>
143+
</div>
144+
</div>
145+
<div className={styles.actions}>
146+
<ThemePickerComponent
147+
options={themeOptions}
148+
handleSelection={handleThemeSelection}
149+
selectedOptionCode={currentTheme.code}
150+
/>
138151
</div>
139-
</div>
140-
<div className={styles.actions}>
141-
<ThemePickerComponent
142-
options={themeOptions}
143-
handleSelection={handleThemeSelection}
144-
selectedOptionCode={currentTheme.code}
145-
/>
146152
</div>
147153
</BoxComponent>
148154
);

src/features/common/components/headers/header/header.module.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
}
3333

3434
.content {
35+
display: flex;
36+
flex-direction: column;
37+
}
38+
39+
.outerNavContainer {
3540
display: flex;
3641
width: 100%;
3742
margin: 0 auto;
@@ -49,6 +54,14 @@
4954
z-index: 100;
5055
}
5156

57+
.ribbonContainer {
58+
margin-top: 0.25rem;
59+
display: flex;
60+
justify-content: center;
61+
padding-bottom: 1rem;
62+
63+
}
64+
5265
.navContainer {
5366
display: flex;
5467
justify-content: center;

0 commit comments

Comments
 (0)