1
- import { type Interpolation , type Theme , useTheme } from "@emotion/react" ;
2
1
import type { ComponentProps , FC , HTMLAttributes } from "react" ;
3
2
import { Link , type LinkProps } from "react-router" ;
3
+ import { cn } from "utils/cn" ;
4
4
import { TopbarIconButton } from "./Topbar" ;
5
5
6
6
export const Sidebar : FC < HTMLAttributes < HTMLDivElement > > = ( props ) => {
7
- const theme = useTheme ( ) ;
8
7
return (
9
8
< div
10
- css = { {
11
- width : 260 ,
12
- borderRight : `1px solid ${ theme . palette . divider } ` ,
13
- height : "100%" ,
14
- overflow : "auto" ,
15
- flexShrink : 0 ,
16
- padding : "8px 0" ,
17
- display : "flex" ,
18
- flexDirection : "column" ,
19
- gap : 1 ,
20
- } }
9
+ // TODO: Remove extra border classes once MUI is removed
10
+ className = "flex flex-col gap-px w-64 border-solid border-0 border-r border-r-border h-full py-2 shrink-0 overflow-y-auto"
21
11
{ ...props }
22
12
/>
23
13
) ;
24
14
} ;
25
15
26
- export const SidebarLink : FC < LinkProps > = ( props ) => {
27
- return < Link css = { styles . sidebarItem } { ...props } /> ;
16
+ export const SidebarLink : FC < LinkProps > = ( { className, ...props } ) => {
17
+ return (
18
+ < Link
19
+ className = { cn (
20
+ "text-[13px] text-content-primary py-2 px-4 text-left bg-transparent hover:divide-surface-tertiary cursor-pointer border-0 no-underline" ,
21
+ className ,
22
+ ) }
23
+ { ...props }
24
+ />
25
+ ) ;
28
26
} ;
29
27
30
28
interface SidebarItemProps extends HTMLAttributes < HTMLButtonElement > {
@@ -33,21 +31,16 @@ interface SidebarItemProps extends HTMLAttributes<HTMLButtonElement> {
33
31
34
32
export const SidebarItem : FC < SidebarItemProps > = ( {
35
33
isActive,
34
+ className,
36
35
...buttonProps
37
36
} ) => {
38
- const theme = useTheme ( ) ;
39
-
40
37
return (
41
38
< button
42
- css = { [
43
- styles . sidebarItem ,
44
- { opacity : "0.75" , "&:hover" : { opacity : 1 } } ,
45
- isActive && {
46
- background : theme . palette . action . selected ,
47
- opacity : 1 ,
48
- pointerEvents : "none" ,
49
- } ,
50
- ] }
39
+ className = { cn (
40
+ "text-[13px] text-content-primary py-2 px-4 text-left bg-transparent hover:divide-surface-tertiary opacity-75 hover:opacity-100 cursor-pointer border-0" ,
41
+ isActive && "opacity-100 bg-surface-tertiary" ,
42
+ className ,
43
+ ) }
51
44
{ ...buttonProps }
52
45
/>
53
46
) ;
@@ -56,15 +49,7 @@ export const SidebarItem: FC<SidebarItemProps> = ({
56
49
export const SidebarCaption : FC < HTMLAttributes < HTMLSpanElement > > = ( props ) => {
57
50
return (
58
51
< span
59
- css = { {
60
- fontSize : 10 ,
61
- lineHeight : 1.2 ,
62
- padding : "12px 16px" ,
63
- display : "block" ,
64
- textTransform : "uppercase" ,
65
- fontWeight : 500 ,
66
- letterSpacing : "0.1em" ,
67
- } }
52
+ className = "text-[10px] leading-tight py-3 px-4 uppercase font-medium text-content-primary tracking-widest"
68
53
{ ...props }
69
54
/>
70
55
) ;
@@ -76,49 +61,17 @@ interface SidebarIconButton extends ComponentProps<typeof TopbarIconButton> {
76
61
77
62
export const SidebarIconButton : FC < SidebarIconButton > = ( {
78
63
isActive,
64
+ className,
79
65
...buttonProps
80
66
} ) => {
81
67
return (
82
68
< TopbarIconButton
83
- css = { [
84
- { opacity : 0.75 , "&:hover" : { opacity : 1 } } ,
85
- isActive && styles . activeSidebarIconButton ,
86
- ] }
69
+ className = { cn (
70
+ "opacity-75 hover:opacity-100 border-0 border-x-2 border-x-transparent border-solid" ,
71
+ isActive && "opacity-100 relative border-l-sky-400" ,
72
+ className ,
73
+ ) }
87
74
{ ...buttonProps }
88
75
/>
89
76
) ;
90
77
} ;
91
-
92
- const styles = {
93
- sidebarItem : ( theme ) => ( {
94
- fontSize : 13 ,
95
- lineHeight : 1.2 ,
96
- color : theme . palette . text . primary ,
97
- textDecoration : "none" ,
98
- padding : "8px 16px" ,
99
- display : "block" ,
100
- textAlign : "left" ,
101
- background : "none" ,
102
- border : 0 ,
103
- cursor : "pointer" ,
104
-
105
- "&:hover" : {
106
- backgroundColor : theme . palette . action . hover ,
107
- } ,
108
- } ) ,
109
-
110
- activeSidebarIconButton : ( theme ) => ( {
111
- opacity : 1 ,
112
- position : "relative" ,
113
- "&::before" : {
114
- content : '""' ,
115
- position : "absolute" ,
116
- left : 0 ,
117
- top : 0 ,
118
- bottom : 0 ,
119
- width : 2 ,
120
- backgroundColor : theme . palette . primary . main ,
121
- height : "100%" ,
122
- } ,
123
- } ) ,
124
- } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments