Skip to content

Commit

Permalink
Fix mode switcher pour mode par défaut système
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-mathe committed Sep 25, 2024
1 parent ad03a1c commit 0b6bc0f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/theme/ModeSwitcher.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ import * as React from "react";
import {Button, useColorScheme} from "@mui/material-next";

export const ModeSwitcher = () => {
const { setColorScheme, systemMode,colorScheme, mode, setMode } = useColorScheme();
const {colorScheme, mode, setMode } = useColorScheme();

const darkMode = (mode === 'dark' || colorScheme === 'dark');

return (
<Button
variant="outlined"
onClick={() => {
console.log("colorScheme = " + colorScheme);
console.log("mode = " + mode);
console.log("systemMode = " + mode);
if (mode === 'light') {
setMode('dark');
} else {
if (darkMode) {
setMode('light');
} else {
setMode('dark');
}
}}
>
{mode === 'light' ? 'dark' : 'light'}
{darkMode ? 'light' : 'dark'}
</Button>
);
};

0 comments on commit 0b6bc0f

Please sign in to comment.