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 function DarkProvider({ children }) {
|
||||
const [dark, setDark] = useState(false);
|
||||
const [dark, setDark] = useState(
|
||||
JSON.parse(window.localStorage.getItem("isDark")) ?? false
|
||||
);
|
||||
useEffect(() => {
|
||||
if (dark) {
|
||||
document.getElementById("body").classList.add("dark");
|
||||
} else {
|
||||
document.getElementById("body").classList.remove("dark");
|
||||
}
|
||||
window.localStorage.setItem("isDark", dark.toString());
|
||||
}, [dark]);
|
||||
return (
|
||||
<darkContext.Provider
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ export default function TabsManagerComponent() {
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-full h-full">
|
||||
<div className="w-full h-full dark:bg-gray-800">
|
||||
<ReactFlowProvider>
|
||||
{flows[tabIndex] ? (
|
||||
<FlowPage flow={flows[tabIndex]}></FlowPage>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue