feat: update documentation sidebar

This commit is contained in:
Valerio Ageno
2024-08-15 11:31:33 +02:00
parent ad3e19e965
commit 4859916edd
2 changed files with 47 additions and 13 deletions
@@ -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}
/>
)
}
@@ -1,34 +1,30 @@
import { AppShell, NavLink } from '@mantine/core' import { AppShell } from '@mantine/core'
import { Link } from 'tuono' import SidebarLink from './SidebarLink'
export default function Sidebar({ close }: { close: () => void }): JSX.Element { export default function Sidebar({ close }: { close: () => void }): JSX.Element {
return ( return (
<AppShell.Navbar p="md"> <AppShell.Navbar p="md">
<h3>Tutorial</h3> <h3>Tutorial</h3>
<NavLink <SidebarLink
href="/documentation/tutorial/intro" href="/documentation/tutorial/intro"
component={Link}
label="Intro" label="Intro"
onClick={close} onClick={close}
/> />
<h3>Documentation</h3> <h3>Documentation</h3>
<NavLink <SidebarLink
href="/documentation/installation" href="/documentation/installation"
component={Link}
label="Installation" label="Installation"
onClick={close} onClick={close}
/> />
<NavLink label="Routing" href="#required-for-focus" defaultOpened> <SidebarLink label="Routing" href="#required-for-focus" defaultOpened>
<NavLink <SidebarLink
href="/documentation/routing/intro" href="/documentation/routing/intro"
component={Link}
label="FS routing" label="FS routing"
onClick={close} onClick={close}
/> />
</NavLink> </SidebarLink>
<NavLink <SidebarLink
label="Contributing" label="Contributing"
component={Link}
href="/documentation/contributing" href="/documentation/contributing"
onClick={close} onClick={close}
/> />