@@ -5,8 +5,14 @@ import type { FC, ReactNode } from 'react';
5
5
import { cn } from '@repo/utils' ;
6
6
import { usePathname } from 'next/navigation' ;
7
7
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area' ;
8
- import { ScrollBar } from "../../ui/scroll-area" ;
9
- import { ChangelogIcon , DocsIcon , TutorialsIcon } from './icons' ;
8
+ import { ScrollBar } from '../../ui/scroll-area' ;
9
+ import {
10
+ APIIcon ,
11
+ ChangelogIcon ,
12
+ DocsIcon ,
13
+ IntegrationsIcon ,
14
+ TutorialsIcon ,
15
+ } from './icons' ;
10
16
11
17
interface SidebarProps {
12
18
children : ReactNode ;
@@ -21,36 +27,39 @@ export const Sidebar: FC<SidebarProps> = ({ children }) => {
21
27
< ScrollAreaPrimitive . Viewport className = "h-full w-full rounded-[inherit]" >
22
28
< div className = "py-12 pl-1 pr-4" >
23
29
< nav className = "flex flex-col gap-1.5 text-sm font-medium" >
24
- < Link
25
- className = { cn (
26
- 'flex items-center gap-3 hover:text-blue-500 transition-colors px-2 h-8' ,
27
- pathname === '/docs' && 'text-blue-500' ,
28
- ) }
30
+ < Line
29
31
href = "/docs"
30
- >
31
- < DocsIcon />
32
- Documentation
33
- </ Link >
34
- < Link
35
- className = { cn (
36
- 'flex items-center gap-3 hover:text-blue-500 transition-colors px-2 h-8' ,
37
- pathname === '/tutorials' && 'text-blue-500' ,
38
- ) }
39
- href = "#"
40
- >
41
- < TutorialsIcon />
42
- Tutorials
43
- </ Link >
44
- < Link
45
- className = { cn (
46
- 'flex items-center gap-3 hover:text-blue-500 transition-colors px-2 h-8' ,
47
- pathname . startsWith ( '/releases' ) && 'text-blue-500' ,
48
- ) }
32
+ icon = { < DocsIcon /> }
33
+ isActive = {
34
+ pathname . startsWith ( '/docs' ) &&
35
+ ! pathname . startsWith ( '/docs/api' )
36
+ }
37
+ label = "Documentation"
38
+ />
39
+ < Line
40
+ href = "/docs/api"
41
+ icon = { < APIIcon /> }
42
+ isActive = { pathname . startsWith ( '/docs/api' ) }
43
+ label = "API"
44
+ />
45
+ < Line
46
+ href = "/#"
47
+ icon = { < TutorialsIcon /> }
48
+ isActive = { pathname === '/tutorials' }
49
+ label = "Tutorials"
50
+ />
51
+ < Line
52
+ href = "/integrations"
53
+ icon = { < IntegrationsIcon /> }
54
+ isActive = { false }
55
+ label = "Integrations"
56
+ />
57
+ < Line
49
58
href = "/releases"
50
- >
51
- < ChangelogIcon />
52
- Changelog
53
- </ Link >
59
+ icon = { < ChangelogIcon /> }
60
+ isActive = { pathname . startsWith ( '/releases' ) }
61
+ label = " Changelog"
62
+ / >
54
63
</ nav >
55
64
{ children }
56
65
</ div >
@@ -60,3 +69,21 @@ export const Sidebar: FC<SidebarProps> = ({ children }) => {
60
69
</ nav >
61
70
) ;
62
71
} ;
72
+
73
+ export const Line : FC < {
74
+ isActive : boolean ;
75
+ href : string ;
76
+ icon : ReactNode ;
77
+ label : string ;
78
+ } > = ( { isActive, href, label, icon } ) => (
79
+ < Link
80
+ className = { cn (
81
+ 'flex items-center gap-3 hover:text-blue-500 transition-colors px-2 h-8' ,
82
+ isActive && 'text-blue-500' ,
83
+ ) }
84
+ href = { href }
85
+ >
86
+ { icon }
87
+ { label }
88
+ </ Link >
89
+ ) ;
0 commit comments