Skip to content

Commit dd67581

Browse files
committed
fix(dashboard): inconsistent interaction for profile menu options
Signed-off-by: amitamrutiya2210 <amitamrutiya2210@gmail.com>
1 parent 0006351 commit dd67581

File tree

2 files changed

+14
-52
lines changed

2 files changed

+14
-52
lines changed
Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,30 @@
11
"use client"
22
import * as React from "react"
33
import { useColorScheme } from "@mui/joy/styles"
4-
import IconButton, { IconButtonProps } from "@mui/joy/IconButton"
54

65
import DarkModeRoundedIcon from "@mui/icons-material/DarkModeRounded"
76
import LightModeIcon from "@mui/icons-material/LightMode"
7+
import { MenuItem } from "@mui/joy"
88

9-
export default function ColorSchemeToggle({ onClick, sx, ...props }: IconButtonProps) {
9+
export default function ColorSchemeToggle() {
1010
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-
}
2711
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={() => {
3514
if (mode === "light") {
3615
setMode("dark")
3716
} else {
3817
setMode("light")
3918
}
40-
onClick?.(event)
4119
}}
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+
}}
5325
>
54-
<DarkModeRoundedIcon />
55-
<LightModeIcon />
56-
</IconButton>
26+
{mode === "light" ? "Dark Mode" : "Light Mode"}
27+
{mode === "light" ? <DarkModeRoundedIcon /> : <LightModeIcon />}
28+
</MenuItem>
5729
)
5830
}

apps/dashboard/components/header.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ export default function Header() {
8484
placement="bottom-end"
8585
>
8686
<MenuItem
87+
onClick={() => navigator.clipboard.writeText(userData?.defaultAccount.id)}
8788
sx={{
8889
display: "flex",
8990
flexDirection: "column",
9091
alignItems: "flex-start",
9192
}}
9293
>
9394
<Box
94-
onClick={() => navigator.clipboard.writeText(userData?.defaultAccount.id)}
9595
sx={{
9696
width: "100%",
9797
display: "flex",
@@ -128,17 +128,7 @@ export default function Header() {
128128
Logout
129129
<LogoutOutlinedIcon></LogoutOutlinedIcon>
130130
</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>
142132
</Menu>
143133
</Dropdown>
144134
</Sheet>

0 commit comments

Comments
 (0)