-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path_app.js
47 lines (35 loc) · 1.21 KB
/
_app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, { useState, useEffect } from 'react';
import { ThemeProvider } from '@material-ui/core/styles';
import CssBaseline from '@material-ui/core/CssBaseline';
import SnackbarController from '../components/snackbar'
import stores from '../stores/index.js'
import {
CONFIGURE,
} from '../stores/constants'
import '../styles/globals.css'
import lightTheme from '../theme/light';
import darkTheme from '../theme/dark';
function MyApp({ Component, pageProps }) {
const [ themeConfig, setThemeConfig ] = useState(lightTheme);
const changeTheme = (dark) => {
setThemeConfig(dark ? darkTheme : lightTheme)
localStorage.setItem("yearn.finance-dark-mode", dark ? "dark" : "light");
}
useEffect(function() {
const localStorageDarkMode = window.localStorage.getItem(
"yearn.finance-dark-mode"
);
changeTheme(localStorageDarkMode ? localStorageDarkMode === "dark" : false);
}, []);
useEffect(function() {
stores.dispatcher.dispatch({ type: CONFIGURE })
},[]);
return (
<ThemeProvider theme={ themeConfig }>
<CssBaseline />
<Component {...pageProps} changeTheme={ changeTheme } />
<SnackbarController />
</ThemeProvider>
)
}
export default MyApp