Skip to content

Commit 0bb5d49

Browse files
authored
chore(ui): merge SideBar and ProgressionSideBar (#7840)
* chore(ui): merge SideBar and ProgressionSideBar * fix purity issue * fix styling and crash * fixup! fix styling and crash * allow passing children
1 parent 639bf95 commit 0bb5d49

File tree

19 files changed

+245
-508
lines changed

19 files changed

+245
-508
lines changed

apps/site/components/withProgressionSidebar.tsx

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

apps/site/components/withSidebar.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,35 @@ import type { NavigationKeys } from '#site/types';
1414
type WithSidebarProps = {
1515
navKeys: Array<NavigationKeys>;
1616
context?: Record<string, RichTranslationValues>;
17+
showProgressionIcons?: boolean;
1718
};
1819

19-
const WithSidebar: FC<WithSidebarProps> = ({ navKeys, context }) => {
20+
const WithSidebar: FC<WithSidebarProps> = ({ navKeys, context, ...props }) => {
2021
const { getSideNavigation } = useSiteNavigation();
2122
const pathname = usePathname()!;
2223
const locale = useLocale();
2324
const t = useTranslations();
2425
const { push } = useRouter();
26+
const sideNavigation = getSideNavigation(navKeys, context);
2527

26-
const mappedSidebarItems = getSideNavigation(navKeys, context).map(
27-
([, { label, items }]) => ({
28-
groupName: label,
29-
items: items.map(([, item]) => item),
30-
})
31-
);
28+
const mappedSidebarItems =
29+
// If there's only a single navigation key, use it's sub-items
30+
// as our navigation.
31+
(navKeys.length === 1 ? sideNavigation[0][1].items : sideNavigation).map(
32+
([, { label, items }]) => ({
33+
groupName: label,
34+
items: items.map(([, item]) => item),
35+
})
36+
);
3237

3338
return (
3439
<Sidebar
3540
groups={mappedSidebarItems}
3641
pathname={pathname.replace(`/${locale}`, '')}
3742
title={t('components.common.sidebar.title')}
38-
onSelect={value => push(value)}
43+
onSelect={push}
3944
as={Link}
45+
{...props}
4046
/>
4147
);
4248
};

apps/site/layouts/Learn.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import WithBreadcrumbs from '#site/components/withBreadcrumbs';
55
import WithFooter from '#site/components/withFooter';
66
import WithMetaBar from '#site/components/withMetaBar';
77
import WithNavBar from '#site/components/withNavBar';
8-
import WithProgressionSidebar from '#site/components/withProgressionSidebar';
8+
import WithSideBar from '#site/components/withSidebar';
99
import WithSidebarCrossLinks from '#site/components/withSidebarCrossLinks';
1010

1111
const LearnLayout: FC<PropsWithChildren> = ({ children }) => (
1212
<>
1313
<WithNavBar />
1414

1515
<Article>
16-
<WithProgressionSidebar navKey="learn" />
16+
<WithSideBar navKeys={['learn']} showProgressionIcons={true} />
1717

1818
<div>
1919
<main>

packages/ui-components/Common/ProgressionSidebar/ProgressionSidebarGroup/index.module.css

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

packages/ui-components/Common/ProgressionSidebar/ProgressionSidebarGroup/index.tsx

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

packages/ui-components/Common/ProgressionSidebar/ProgressionSidebarItem/index.module.css

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

packages/ui-components/Common/ProgressionSidebar/ProgressionSidebarItem/index.tsx

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

packages/ui-components/Common/ProgressionSidebar/index.module.css

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

packages/ui-components/Common/ProgressionSidebar/index.stories.tsx

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

0 commit comments

Comments
 (0)