🥚 Add easter egg on darkmode
Co-authored-by: Lucas Stoebner <stoebnerl@gmail.com>pull/2360/head
parent
4a409243fe
commit
0544f7c923
|
@ -14,12 +14,20 @@ export const DarkModeContext = React.createContext<DarkModeContextType>({
|
|||
})
|
||||
|
||||
export const DarkModeProvider: React.FC = ({ children }) => {
|
||||
const [darkMode, setDarkMode] = React.useState<boolean>(
|
||||
const [darkMode, _setDarkMode] = React.useState<boolean>(
|
||||
import.meta.env.DEV && typeof window !== 'undefined' ?
|
||||
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) :
|
||||
false
|
||||
)
|
||||
|
||||
const setDarkMode = (darkMode: boolean) => {
|
||||
_setDarkMode(darkMode)
|
||||
|
||||
// https://www.youtube.com/watch?v=Pr8ETbGz35Q
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(darkMode ? 'Nuit' : 'Jour')
|
||||
}
|
||||
|
||||
return (
|
||||
<DarkModeContext.Provider value={{ darkMode, setDarkMode }}>
|
||||
{children}
|
||||
|
|
Loading…
Reference in New Issue