mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-29 22:02:46 -07:00
feat: update documentation sidebar
This commit is contained in:
@@ -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}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user