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