Skip to content

Commit 60a8825

Browse files
committed
chore(website): Update Light/Dark Theme Toggle Icons
This icon is kind of standardized so might help users use the dark mode. The light bulb was really just for fun.
1 parent b147a88 commit 60a8825

3 files changed

Lines changed: 9 additions & 47 deletions

File tree

packages/documentation/src/components/Layout/ToggleTheme.module.scss

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/documentation/src/components/Layout/ToggleTheme.tsx

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,32 @@
11
import type { ReactElement } from "react";
2-
import cn from "classnames";
32
import { 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";
55
import { MenuItem } from "@react-md/menu";
66
import { Tooltip, useTooltip } from "@react-md/tooltip";
7-
import { useIsUserInteractionMode, useToggle } from "@react-md/utils";
87

98
import useTheme from "components/Theme/useTheme";
109
import useThemeActions from "components/Theme/useThemeActions";
11-
import LightbulbSVGIcon from "icons/LightbulbSVGIcon";
12-
13-
import styles from "./ToggleTheme.module.scss";
1410

1511
export interface ToggleThemeProps {
1612
as: "action" | "menuitem";
1713
}
1814

1915
export 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>

packages/documentation/src/components/Theme/styles.module.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
.transition {
1111
@include transition;
1212

13-
* {
13+
// make it so the light/dark theme toggle still animates with the default transform
14+
*:not(:global(.rmd-icon-rotator)) {
1415
@include transition;
1516
}
1617
}

0 commit comments

Comments
 (0)