saving darkMode on localStorage
This commit is contained in:
parent
730fe45518
commit
7d49319696
2 changed files with 5 additions and 2 deletions
|
|
@ -13,13 +13,16 @@ const initialValue = {
|
||||||
export const darkContext = createContext<darkContextType>(initialValue);
|
export const darkContext = createContext<darkContextType>(initialValue);
|
||||||
|
|
||||||
export function DarkProvider({ children }) {
|
export function DarkProvider({ children }) {
|
||||||
const [dark, setDark] = useState(false);
|
const [dark, setDark] = useState(
|
||||||
|
JSON.parse(window.localStorage.getItem("isDark")) ?? false
|
||||||
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dark) {
|
if (dark) {
|
||||||
document.getElementById("body").classList.add("dark");
|
document.getElementById("body").classList.add("dark");
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("body").classList.remove("dark");
|
document.getElementById("body").classList.remove("dark");
|
||||||
}
|
}
|
||||||
|
window.localStorage.setItem("isDark", dark.toString());
|
||||||
}, [dark]);
|
}, [dark]);
|
||||||
return (
|
return (
|
||||||
<darkContext.Provider
|
<darkContext.Provider
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ export default function TabsManagerComponent() {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full h-full">
|
<div className="w-full h-full dark:bg-gray-800">
|
||||||
<ReactFlowProvider>
|
<ReactFlowProvider>
|
||||||
{flows[tabIndex] ? (
|
{flows[tabIndex] ? (
|
||||||
<FlowPage flow={flows[tabIndex]}></FlowPage>
|
<FlowPage flow={flows[tabIndex]}></FlowPage>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue