🥚 Add easter egg on darkmode

Co-authored-by: Lucas Stoebner <stoebnerl@gmail.com>
pull/2360/head
Félix 2022-10-26 11:05:36 +02:00 committed by Johan Girod
parent 4a409243fe
commit 0544f7c923
1 changed files with 9 additions and 1 deletions

View File

@ -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}