11import type { ReactElement } from "react" ;
2- import cn from "classnames" ;
32import { AppBarAction } from "@react-md/app-bar" ;
4- import { LightbulbOutlineSVGIcon } from "@react-md/material-icons" ;
3+ import { IconRotator } from "@react-md/icon" ;
4+ import { Brightness4SVGIcon } from "@react-md/material-icons" ;
55import { MenuItem } from "@react-md/menu" ;
66import { Tooltip , useTooltip } from "@react-md/tooltip" ;
7- import { useIsUserInteractionMode , useToggle } from "@react-md/utils" ;
87
98import useTheme from "components/Theme/useTheme" ;
109import useThemeActions from "components/Theme/useThemeActions" ;
11- import LightbulbSVGIcon from "icons/LightbulbSVGIcon" ;
12-
13- import styles from "./ToggleTheme.module.scss" ;
1410
1511export interface ToggleThemeProps {
1612 as : "action" | "menuitem" ;
1713}
1814
1915export default function ToggleTheme ( { as } : ToggleThemeProps ) : ReactElement {
20- const [ toggled , enable , disable ] = useToggle ( false ) ;
2116 const { theme } = useTheme ( ) ;
2217 const { toggleTheme } = useThemeActions ( ) ;
2318 const isLight = theme === "light" ;
2419
25- const isMouseMode = useIsUserInteractionMode ( "mouse" ) ;
2620 const { elementProps, tooltipProps } = useTooltip ( {
2721 baseId : "toggle-theme" ,
2822 onClick : toggleTheme ,
29- onMouseEnter : isMouseMode ? enable : undefined ,
30- onMouseLeave : isMouseMode ? disable : undefined ,
3123 } ) ;
3224
33- let icon = < LightbulbOutlineSVGIcon /> ;
34- if ( toggled !== isLight ) {
35- icon = (
36- < LightbulbSVGIcon
37- className = { cn ( {
38- [ styles . on ] : as === "menuitem" ,
39- } ) }
40- />
41- ) ;
42- }
25+ const icon = (
26+ < IconRotator rotated = { ! isLight } >
27+ < Brightness4SVGIcon />
28+ </ IconRotator >
29+ ) ;
4330
4431 if ( as === "menuitem" ) {
4532 return (
@@ -60,11 +47,6 @@ export default function ToggleTheme({ as }: ToggleThemeProps): ReactElement {
6047 { ...elementProps }
6148 aria-label = "Dark Theme"
6249 aria-pressed = { ! isLight }
63- className = { cn ( {
64- [ styles . on ] : isLight ,
65- [ styles . off ] : ! isLight ,
66- } ) }
67- inheritColor = { ! isLight }
6850 >
6951 { icon }
7052 </ AppBarAction >
0 commit comments