Shift darkmode class to separate div
This commit is contained in:
parent
c521713b13
commit
2ef2ab5ea6
@ -13,14 +13,6 @@ body,
|
|||||||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
|
||||||
background-color: #a7b6c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
body.bp3-dark {
|
|
||||||
background-color: #202b33;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { Classes } from "@blueprintjs/core";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { Colors } from "@blueprintjs/core";
|
||||||
|
|
||||||
const DarkModeContext = React.createContext<{
|
const DarkModeContext = React.createContext<{
|
||||||
isDark: boolean;
|
isDark: boolean;
|
||||||
toggleDark: () => void;
|
toggleDark: () => void;
|
||||||
}>({ isDark: false, toggleDark: () => {} });
|
}>({ isDark: true, toggleDark: () => {} });
|
||||||
|
|
||||||
/** Context provider for managing dark mode state */
|
/** Context provider for managing dark mode state */
|
||||||
export const DarkModeProvider = ({
|
export const DarkModeProvider = ({
|
||||||
@ -12,16 +12,21 @@ export const DarkModeProvider = ({
|
|||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) => {
|
}) => {
|
||||||
const [isDark, setIsDark] = React.useState(false);
|
const [isDark, setIsDark] = React.useState(true);
|
||||||
|
|
||||||
const toggleDark = () => {
|
|
||||||
document.body.classList.toggle(Classes.DARK);
|
|
||||||
setIsDark((d) => !d);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DarkModeContext.Provider value={{ isDark, toggleDark }}>
|
<DarkModeContext.Provider
|
||||||
{children}
|
value={{ isDark, toggleDark: () => setIsDark((d) => !d) }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: "100%",
|
||||||
|
backgroundColor: isDark ? Colors.DARK_GRAY2 : Colors.GRAY4,
|
||||||
|
}}
|
||||||
|
className={isDark ? "bp3-dark" : ""}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
</DarkModeContext.Provider>
|
</DarkModeContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user