-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4859916
commit a7b7f0e
Showing
6 changed files
with
64 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
apps/documentation/src/components/sidebar/sidebar-link.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
45
apps/documentation/src/components/sidebar/sidebar-link.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
apps/documentation/src/routes/documentation/routing/index.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ import { Head } from 'tuono' | |
<title>Tuono - Routing</title> | ||
</Head> | ||
|
||
# Routing | ||
# Project structure | ||
|
||
Todo |