Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubh942 committed Jul 6, 2024
1 parent 51992d4 commit d0ca7a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion webapp/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@ import Header from "./components/Header/Header";

const App = () => {
const [isDarkMode, setDarkMode] = useState("dark");
const [dark, setDark] = useState(false);

const toggleDarkMode = () => {
setDarkMode((isDarkMode) => (isDarkMode === "dark" ? "light" : "dark"));
setDark(!dark);
};

useEffect(() => {
document.documentElement.setAttribute("data-theme", isDarkMode);
}, [isDarkMode]);
return (
<div>
<Header isDarkMode={isDarkMode} toggleDarkMode={toggleDarkMode} />
<Header
isDarkMode={isDarkMode}
toggleDarkMode={toggleDarkMode}
dark={dark}
/>

<Routes>
<Route path="debug" element={<Debug />}>
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import c2si from "../../assets/c2si.png";
import { Link } from "react-router-dom";
import { DarkModeSwitch } from "react-toggle-dark-mode";

const Header = ({ isDarkMode, toggleDarkMode }) => {
const Header = ({ isDarkMode, toggleDarkMode, dark }) => {
return (
<div className="header">
<div className="head">
Expand All @@ -15,7 +15,7 @@ const Header = ({ isDarkMode, toggleDarkMode }) => {
<div className="darkmode">
<DarkModeSwitch
style={{ marginBottom: "2rem" }}
checked={isDarkMode}
checked={dark}
onChange={toggleDarkMode}
size={20}
/>
Expand Down

0 comments on commit d0ca7a9

Please sign in to comment.