Skip to content

Commit

Permalink
feat: update documentation sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
Valerioageno committed Aug 15, 2024
1 parent ad3e19e commit 4859916
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 13 deletions.
38 changes: 38 additions & 0 deletions apps/documentation/src/components/sidebar/SidebarLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { NavLink, type NavLinkProps } from '@mantine/core'
import type { CSSProperties, ReactNode } from 'react'
import { Link, useRouter } from 'tuono'

interface SidebarLinkProps {
label: string
href: string
onClick?: () => void
children?: ReactNode
}

const styles: CSSProperties = {
borderRadius: 8,
marginTop: '0.25rem',
lineHeight: '1.25rem',
fontWeight: 'bold',
}

export default function SidebarLink(
props: SidebarLinkProps & NavLinkProps,
): JSX.Element {
const { pathname } = useRouter()

return (
<NavLink
component={props.href.startsWith('#') ? 'button' : Link}
style={
pathname === props.href
? {
color: 'var(--mantine-color-violet-4)',
...styles,
}
: styles
}
{...props}
/>
)
}
22 changes: 9 additions & 13 deletions apps/documentation/src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
import { AppShell, NavLink } from '@mantine/core'
import { Link } from 'tuono'
import { AppShell } from '@mantine/core'
import SidebarLink from './SidebarLink'

export default function Sidebar({ close }: { close: () => void }): JSX.Element {
return (
<AppShell.Navbar p="md">
<h3>Tutorial</h3>
<NavLink
<SidebarLink
href="/documentation/tutorial/intro"
component={Link}
label="Intro"
onClick={close}
/>
<h3>Documentation</h3>
<NavLink
<SidebarLink
href="/documentation/installation"
component={Link}
label="Installation"
onClick={close}
/>
<NavLink label="Routing" href="#required-for-focus" defaultOpened>
<NavLink
<SidebarLink label="Routing" href="#required-for-focus" defaultOpened>
<SidebarLink
href="/documentation/routing/intro"
component={Link}
label="FS routing"
onClick={close}
/>
</NavLink>
<NavLink
label="Contributing"
component={Link}
</SidebarLink>
<SidebarLink
label="✨ Contributing"
href="/documentation/contributing"
onClick={close}
/>
Expand Down

0 comments on commit 4859916

Please sign in to comment.