1
1
import React , { useReducer } from 'react' ;
2
2
import styles from './App.module.scss' ;
3
- import { GlobalContext , globalState , globalReducer } from './context/reducers/globalReducer' ;
3
+ import {
4
+ GlobalContext ,
5
+ globalState ,
6
+ globalReducer ,
7
+ } from './context/reducers/globalReducer' ;
4
8
import { toggleTheme } from './context/actions/globalActions' ;
5
9
import ProjectLoader from './pages/ProjectLoader/ProjectLoader.jsx' ;
6
10
import NavBar from './components/NavBar/NavBar' ;
@@ -9,13 +13,14 @@ import RightPanel from './pages/RightPanel/RightPanel';
9
13
import FileDirectory from './components/FileDirectory/FileDirectory' ;
10
14
import { CSSTransition } from 'react-transition-group' ;
11
15
import { Switch } from '@material-ui/core' ;
16
+ import { BiSun , BiMoon } from 'react-icons/bi' ;
12
17
// import About from './pages/About/About';
13
18
14
19
const App = ( ) => {
15
20
const [ global , dispatchToGlobal ] = useReducer ( globalReducer , globalState ) ;
16
21
17
22
const changeTheme = ( ) => {
18
- localStorage . setItem ( " theme" , global . theme === 'light' ? 'dark' : 'light' ) ;
23
+ localStorage . setItem ( ' theme' , global . theme === 'light' ? 'dark' : 'light' ) ;
19
24
dispatchToGlobal ( toggleTheme ( ) ) ;
20
25
} ;
21
26
@@ -25,29 +30,43 @@ const App = () => {
25
30
{ /* pass global state and dispatch function as prop to context provider for child components */ }
26
31
< GlobalContext . Provider value = { [ global , dispatchToGlobal ] } >
27
32
< div id = { styles . toggle } >
28
- < Switch checked = { global . theme === 'light' ? true : false } onChange = { changeTheme } />
33
+ < div id = { styles . icon } >
34
+ < span title = "Dark Mode" >
35
+ < BiMoon size = { '1.5rem' } />
36
+ </ span >
37
+ < span title = "Change theme" >
38
+ < Switch
39
+ checked = { global . theme === 'light' ? true : false }
40
+ onChange = { changeTheme }
41
+ />
42
+ </ span >
43
+ < span title = "Light Mode" >
44
+ < BiSun size = { '1.5rem' } />
45
+ </ span >
46
+ </ div >
29
47
</ div >
30
- < ProjectLoader />
48
+ < ProjectLoader />
31
49
</ GlobalContext . Provider >
32
50
</ div >
33
51
) ;
34
52
}
35
53
return (
36
- /**
37
- * Wrap the components that we want to share the unique states with.
38
- * You can only provide one value to a Provider.
39
- * - In order to avoid creating separate Contexts, wrap multiples in an array (ex: testCase and dispatchToTestCase).
40
- *
41
- *
42
- * NOTE: This concept is similar to Redux and how it provides the store to your top-level component and all of its children.
43
- * We just have to create separate providers for each reducer because we don’t have a global store ala Redux.
44
- *
45
- *
46
- * We access the value that we gave to the Provider through useContext
47
- *
48
- * 01/29 There does not seem to be 'about' page functionality visible
49
- */
54
+ /**
55
+ * Wrap the components that we want to share the unique states with.
56
+ * You can only provide one value to a Provider.
57
+ * - In order to avoid creating separate Contexts, wrap multiples in an array (ex: testCase and dispatchToTestCase).
58
+ *
59
+ *
60
+ * NOTE: This concept is similar to Redux and how it provides the store to your top-level component and all of its children.
61
+ * We just have to create separate providers for each reducer because we don’t have a global store ala Redux.
62
+ *
63
+ *
64
+ * We access the value that we gave to the Provider through useContext
65
+ *
66
+ * 01/29 There does not seem to be 'about' page functionality visible
67
+ */
50
68
< div
69
+ //This could/should be deleted:
51
70
// id={
52
71
// global.isProjectLoaded === 'about'
53
72
// ? ''
@@ -62,14 +81,20 @@ const App = () => {
62
81
id = { styles . app }
63
82
>
64
83
< GlobalContext . Provider value = { [ global , dispatchToGlobal ] } >
65
- < NavBar inAboutPage = { false } />
66
- < div id = { styles [ `content${ global . theme } ` ] } >
67
- < CSSTransition in = { global . isFileDirectoryOpen } timeout = { 200 } classNames = "my-node" unmountOnExit appear >
68
- < FileDirectory fileTree = { global . fileTree } />
69
- </ CSSTransition >
70
- < LeftPanel />
71
- < RightPanel />
72
- </ div >
84
+ < NavBar inAboutPage = { false } />
85
+ < div id = { styles [ `content${ global . theme } ` ] } >
86
+ < CSSTransition
87
+ in = { global . isFileDirectoryOpen }
88
+ timeout = { 200 }
89
+ classNames = "my-node"
90
+ unmountOnExit
91
+ appear
92
+ >
93
+ < FileDirectory fileTree = { global . fileTree } />
94
+ </ CSSTransition >
95
+ < LeftPanel />
96
+ < RightPanel />
97
+ </ div >
73
98
</ GlobalContext . Provider >
74
99
</ div >
75
100
) ;
0 commit comments