-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathSideNavigationSection.tsx
More file actions
56 lines (49 loc) · 1.3 KB
/
SideNavigationSection.tsx
File metadata and controls
56 lines (49 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Box, HiddenVisually, Stack } from 'braid-design-system';
import { CategoryHeading } from '../CategoryHeading/CategoryHeading';
import { SideNavigationItem } from './SideNavigationItem';
import * as styles from './SideNavigation.css';
interface SideNavigationSection {
title: string;
hideTitle?: boolean;
items: SideNavigationItem[];
}
const Title = ({ children }: { children: string }) => (
<CategoryHeading component="h2">{children}</CategoryHeading>
);
const ItemList = ({ items }: { items: SideNavigationItem[] }) => (
<Stack component="ul" space="none">
{items.map(({ name, badge, path, active, onClick }: SideNavigationItem) => (
<SideNavigationItem
name={name}
badge={badge}
path={path}
active={active}
onClick={onClick}
key={name}
/>
))}
</Stack>
);
export const SideNavigationSection = ({
title,
hideTitle,
items,
}: SideNavigationSection) => (
<Box component="nav">
{hideTitle ? (
<>
<HiddenVisually>
<Title>{title}</Title>
</HiddenVisually>
<ItemList items={items} />
</>
) : (
<Stack space="small">
<Box className={styles.uppercase}>
<Title>{title}</Title>
</Box>
<ItemList items={items} />
</Stack>
)}
</Box>
);