Skip to content

Commit b6e7e18

Browse files
committed
restructured header tools slots
1 parent cc0eab9 commit b6e7e18

File tree

5 files changed

+39
-50
lines changed

5 files changed

+39
-50
lines changed

packages/layout/slots/Header/Header.module.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
} */
1010

1111
.header-tools {
12-
display: flex;
13-
flex: 1 1 0;
14-
flex-direction: row-reverse;
12+
align-items: center;
1513
}
1614
}

packages/layout/slots/Header/Header.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ const Header = (props: HeaderProps) => {
2626
<SlotRenderer name="navigation" content={content} location={location} />
2727
<div className={clsx(styles['header-tools'], 'header-tools')}>
2828
<SlotRenderer
29-
name="headertools"
30-
content={content}
31-
location={location}
32-
/>
33-
<SlotRenderer
34-
name="language-switcher"
29+
name="headerTools"
3530
content={content}
3631
location={location}
3732
/>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import SlotRenderer, { type SlotComponentProps } from '../SlotRenderer';
2+
import { useRouteLoaderData } from 'react-router';
3+
import type { RootLoader } from 'seven/app/root';
4+
5+
const HeaderTools = (props: SlotComponentProps) => {
6+
const rootData = useRouteLoaderData<RootLoader>('root');
7+
8+
if (!rootData) {
9+
return null;
10+
}
11+
12+
const { isAuthenticated } = rootData;
13+
const { content, location } = props;
14+
15+
return (
16+
<>
17+
{isAuthenticated ? (
18+
<SlotRenderer
19+
name="siteActions"
20+
content={content}
21+
location={location}
22+
/>
23+
) : (
24+
<SlotRenderer name="anontools" content={content} location={location} />
25+
)}
26+
<SlotRenderer
27+
name="languageSwitcher"
28+
content={content}
29+
location={location}
30+
/>
31+
<SlotRenderer name="searchWidget" content={content} location={location} />
32+
</>
33+
);
34+
};
35+
36+
export default HeaderTools;

packages/layout/slots/LanguageSwitcher/LanguageSwitcher.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const LanguageSwitcher = (props: LanguageSelectorProps) => {
3636
{availableLanguages.map((lang) => {
3737
return (
3838
<Link
39-
aria-label={t('layout.languageSwitcher.switchTo', {
39+
aria-label={t('layout.slots.tools.languageSwitcher.switchTo', {
4040
lang: langmap[lang]?.nativeName.toLowerCase(),
4141
})}
4242
className={clsx({

packages/layout/slots/Tools.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)