diff --git a/Client/src/Components/ThemeSwitch/index.css b/Client/src/Components/ThemeSwitch/index.css index c80a0f2d1..2519a0be8 100644 --- a/Client/src/Components/ThemeSwitch/index.css +++ b/Client/src/Components/ThemeSwitch/index.css @@ -6,20 +6,20 @@ stroke-width: 2px; } -[data-theme="dark"] .sun-and-moon > .sun { +.theme-dark .sun-and-moon > .sun { transform: scale(1.75); } -[data-theme="dark"] .sun-and-moon > .sun-beams { +.theme-dark .sun-and-moon > .sun-beams { opacity: 0; } -[data-theme="dark"] .sun-and-moon > .moon > circle { +.theme-dark .sun-and-moon > .moon > circle { transform: translateX(-7px); } @supports (cx: 1) { - [data-theme="dark"] .sun-and-moon > .moon > circle { + .theme-dark .sun-and-moon > .moon > circle { cx: 17; transform: translateX(0); } @@ -46,18 +46,18 @@ } } - [data-theme="dark"] .sun-and-moon > .sun { + .theme-dark .sun-and-moon > .sun { transition-timing-function: var(--ease-3); transition-duration: 0.25s; transform: scale(1.75); } - [data-theme="dark"] .sun-and-moon > .sun-beams { + .theme-dark .sun-and-moon > .sun-beams { transition-duration: 0.15s; transform: rotateZ(-25deg); } - [data-theme="dark"] .sun-and-moon > .moon > circle { + .theme-dark .sun-and-moon > .moon > circle { transition-duration: 0.5s; transition-delay: 0.25s; } diff --git a/Client/src/Components/ThemeSwitch/index.jsx b/Client/src/Components/ThemeSwitch/index.jsx index 4cb6c3a14..b751f542a 100644 --- a/Client/src/Components/ThemeSwitch/index.jsx +++ b/Client/src/Components/ThemeSwitch/index.jsx @@ -9,14 +9,13 @@ * Apache License: https://www.apache.org/licenses/LICENSE-2.0 */ -import React, { useEffect } from "react"; import { IconButton } from "@mui/material"; import SunAndMoonIcon from "./SunAndMoonIcon"; -import "./index.css"; import { useDispatch, useSelector } from "react-redux"; import { setMode } from "../../Features/UI/uiSlice"; +import "./index.css"; -const ThemeSwitch = () => { +const ThemeSwitch = ({ width = 48, height = 48 }) => { const mode = useSelector((state) => state.ui.mode); const dispatch = useDispatch(); @@ -24,20 +23,17 @@ const ThemeSwitch = () => { dispatch(setMode(mode === "light" ? "dark" : "light")); }; - useEffect(() => { - document.body.setAttribute("data-theme", mode); - }, [mode]); - return (