forked from components-ai/css.gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNav.tsx
More file actions
53 lines (51 loc) · 1.24 KB
/
Nav.tsx
File metadata and controls
53 lines (51 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { HTMLAttributes } from 'react'
import Link, { LinkProps } from 'next/link'
import { useRouter } from 'next/router'
interface NavItemProps extends HTMLAttributes<HTMLLinkElement> {}
export const NavItem = ({
children,
href,
...props
}: NavItemProps & LinkProps) => {
const router = useRouter()
const isActive = router.asPath === href
return (
<Link passHref={true} href={href} {...props}>
<a
sx={{
fontSize: 2,
textDecoration: 'none',
display: 'block',
width: '100%',
color: isActive ? 'background' : 'muted',
backgroundColor: isActive ? 'primary' : 'background',
px: [2, 3, 4],
py: 2,
transition: 'color .2s ease-in-out',
':hover': {
color: isActive? 'background' : 'primary'
}
}}
>
{children}
</a>
</Link>
)
}
interface NavSectionTitleProps extends HTMLAttributes<HTMLHeadingElement> {}
export const NavSectionTitle = (props: NavSectionTitleProps) => {
return (
<h3
sx={{
lineHeight: '1.25',
fontWeight: 500,
fontSize: 2,
pt: [2, 3],
pb: 1,
px: [2, 3, 4],
m: 0,
}}
{...props}
/>
)
}