Skip to content

Commit

Permalink
feat: allow navigable header sections in sidebar w/ link param (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
guscost authored May 18, 2024
1 parent 5bbc87f commit 191ca5c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/app/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ function flattenSidebar(sidebar: SidebarItem[]) {
const items: SidebarItem[] = []

for (const item of sidebar) {
if (item.link) {
items.push(item)
}
if (item.items) {
items.push(...flattenSidebar(item.items))
continue
}

items.push(item)
}

return items
Expand Down
14 changes: 14 additions & 0 deletions src/app/components/Sidebar.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,20 @@ export const sectionTitle = style(
'sectionTitle',
)

export const sectionTitleLink = style(
{
selectors: {
'&:hover': {
color: primitiveColorVars.text,
},
'&[data-active="true"]': {
color: primitiveColorVars.textAccent,
},
},
},
'sectionTitleLink',
)

export const sectionCollapse = style(
{
color: primitiveColorVars.text3,
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function SidebarItem(props: {
data-active={Boolean(match)}
onClick={onClick}
className={clsx(
depth === 0 ? styles.sectionTitle : styles.item,
depth === 0 ? [styles.sectionTitle, styles.sectionTitleLink] : styles.item,
hasActiveChildItem && styles.sectionHeaderActive,
)}
to={item.link}
Expand Down

0 comments on commit 191ca5c

Please sign in to comment.