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 4859916 commit a7b7f0e
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 43 deletions.
38 changes: 0 additions & 38 deletions apps/documentation/src/components/sidebar/SidebarLink.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.link {
border-radius: 8px;
margin-top: 0.25rem;
line-height: 1.25rem;
font-weight: bold;
}
45 changes: 45 additions & 0 deletions apps/documentation/src/components/sidebar/sidebar-link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { NavLink, type NavLinkProps } from '@mantine/core'
import { useState, type ReactNode } from 'react'
import { Link, useRouter } from 'tuono'
import { IconChevronRight } from '@tabler/icons-react'

import styles from './sidebar-link.module.css'

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

export default function SidebarLink(
props: SidebarLinkProps & NavLinkProps,
): JSX.Element {
const { pathname } = useRouter()
const [isOpen, setIsOpen] = useState<boolean>(!!props.defaultOpened)

return (
<NavLink
component={props.href.startsWith('#') ? 'button' : Link}
active={pathname === props.href}
className={styles.link}
rightSection={
props.children && (
<IconChevronRight
size="1.2rem"
stroke={1.5}
className="mantine-rotate-rtl"
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
setIsOpen((state) => !state)
}}
/>
)
}
opened={isOpen}
autoContrast
{...props}
/>
)
}
9 changes: 5 additions & 4 deletions apps/documentation/src/components/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppShell } from '@mantine/core'
import SidebarLink from './SidebarLink'
import SidebarLink from './sidebar-link'

export default function Sidebar({ close }: { close: () => void }): JSX.Element {
return (
Expand All @@ -16,17 +16,18 @@ export default function Sidebar({ close }: { close: () => void }): JSX.Element {
label="Installation"
onClick={close}
/>
<SidebarLink label="Routing" href="#required-for-focus" defaultOpened>
<SidebarLink label="Routing" href="/documentation/routing" defaultOpened>
<SidebarLink
href="/documentation/routing/intro"
label="FS routing"
label="Project structure"
onClick={close}
/>
</SidebarLink>
<SidebarLink
label="Contributing"
label="Contributing"
href="/documentation/contributing"
onClick={close}
leftSection="✨"
/>
</AppShell.Navbar>
)
Expand Down
7 changes: 7 additions & 0 deletions apps/documentation/src/routes/documentation/routing/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Head } from 'tuono'

<Head>
<title>Tuono - Routing</title>
</Head>

# Routing index
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { Head } from 'tuono'
<title>Tuono - Routing</title>
</Head>

# Routing
# Project structure

Todo

0 comments on commit a7b7f0e

Please sign in to comment.