File tree Expand file tree Collapse file tree 2 files changed +14
-52
lines changed
apps/dashboard/components Expand file tree Collapse file tree 2 files changed +14
-52
lines changed Original file line number Diff line number Diff line change 1
1
"use client"
2
2
import * as React from "react"
3
3
import { useColorScheme } from "@mui/joy/styles"
4
- import IconButton , { IconButtonProps } from "@mui/joy/IconButton"
5
4
6
5
import DarkModeRoundedIcon from "@mui/icons-material/DarkModeRounded"
7
6
import LightModeIcon from "@mui/icons-material/LightMode"
7
+ import { MenuItem } from "@mui/joy"
8
8
9
- export default function ColorSchemeToggle ( { onClick , sx , ... props } : IconButtonProps ) {
9
+ export default function ColorSchemeToggle ( ) {
10
10
const { mode, setMode } = useColorScheme ( )
11
- const [ mounted , setMounted ] = React . useState ( false )
12
- React . useEffect ( ( ) => {
13
- setMounted ( true )
14
- } , [ ] )
15
- if ( ! mounted ) {
16
- return (
17
- < IconButton
18
- size = "sm"
19
- variant = "outlined"
20
- color = "neutral"
21
- { ...props }
22
- sx = { sx }
23
- disabled
24
- />
25
- )
26
- }
27
11
return (
28
- < IconButton
29
- id = "toggle-mode"
30
- size = "sm"
31
- variant = "outlined"
32
- color = "neutral"
33
- { ...props }
34
- onClick = { ( event ) => {
12
+ < MenuItem
13
+ onClick = { ( ) => {
35
14
if ( mode === "light" ) {
36
15
setMode ( "dark" )
37
16
} else {
38
17
setMode ( "light" )
39
18
}
40
- onClick ?.( event )
41
19
} }
42
- sx = { [
43
- {
44
- "& > *:first-of-type" : {
45
- display : mode === "dark" ? "none" : "initial" ,
46
- } ,
47
- "& > *:last-of-type" : {
48
- display : mode === "light" ? "none" : "initial" ,
49
- } ,
50
- } ,
51
- ...( Array . isArray ( sx ) ? sx : [ sx ] ) ,
52
- ] }
20
+ sx = { {
21
+ display : "flex" ,
22
+ justifyContent : "space-between" ,
23
+ fontWeight : "500" ,
24
+ } }
53
25
>
54
- < DarkModeRoundedIcon />
55
- < LightModeIcon />
56
- </ IconButton >
26
+ { mode === "light" ? "Dark Mode" : "Light Mode" }
27
+ { mode === "light" ? < DarkModeRoundedIcon /> : < LightModeIcon /> }
28
+ </ MenuItem >
57
29
)
58
30
}
Original file line number Diff line number Diff line change @@ -84,14 +84,14 @@ export default function Header() {
84
84
placement = "bottom-end"
85
85
>
86
86
< MenuItem
87
+ onClick = { ( ) => navigator . clipboard . writeText ( userData ?. defaultAccount . id ) }
87
88
sx = { {
88
89
display : "flex" ,
89
90
flexDirection : "column" ,
90
91
alignItems : "flex-start" ,
91
92
} }
92
93
>
93
94
< Box
94
- onClick = { ( ) => navigator . clipboard . writeText ( userData ?. defaultAccount . id ) }
95
95
sx = { {
96
96
width : "100%" ,
97
97
display : "flex" ,
@@ -128,17 +128,7 @@ export default function Header() {
128
128
Logout
129
129
< LogoutOutlinedIcon > </ LogoutOutlinedIcon >
130
130
</ MenuItem >
131
-
132
- < MenuItem
133
- sx = { {
134
- display : "flex" ,
135
- justifyContent : "space-between" ,
136
- fontWeight : "500" ,
137
- } }
138
- >
139
- Dark Mode
140
- < ColorSchemeToggle > </ ColorSchemeToggle >
141
- </ MenuItem >
131
+ < ColorSchemeToggle > </ ColorSchemeToggle >
142
132
</ Menu >
143
133
</ Dropdown >
144
134
</ Sheet >
You can’t perform that action at this time.
0 commit comments