1
1
import { BrowserRouter , Routes , Route } from "react-router-dom" ; // Link
2
+ import { GeistProvider , CssBaseline , Button } from '@geist-ui/react' ;
3
+ import { useState } from "react" ;
2
4
3
5
import "./App.css" ;
4
6
@@ -23,46 +25,85 @@ import GalleryPage from "./pages/Gallery/GalleryPage";
23
25
import OrganizePage from "./pages/Organize/OrganizePage" ;
24
26
25
27
import BaseLayout from "./pages/BaseLayout" ;
28
+ import Page from "./pages/Page" ;
29
+
30
+ // https://beta.reactjs.org/learn/sharing-state-between-components
26
31
27
32
function App ( ) {
33
+ const [ themeType , setThemeType ] = useState ( 'light' )
34
+ const enableDebugThemeButton = false ;
35
+ const switchThemes = ( ) => {
36
+ setThemeType ( last => ( last === 'dark' ? 'light' : 'dark' ) )
37
+ }
38
+
28
39
return (
29
40
30
41
< div className = "App" >
31
- < BrowserRouter >
32
- < Routes >
33
-
34
-
35
- { /* could refactor this to use contexts to inform the layout https://reactjs.org/docs/context.html */ }
36
- < Route element = { < BaseLayout /> } >
37
- < Route path = "*" element = { < NotFoundPage /> } />
38
- < Route path = "/" element = { < HomePage /> } />
39
- < Route path = "geist-test" element = { < GeistTestPage /> } />
40
- </ Route >
41
- < Route element = { < BaseLayout centered /> } >
42
- < Route path = "login" element = { < LoginPage /> } />
43
- < Route path = "register" element = { < RegisterPage /> } />
44
- </ Route >
45
- < Route element = { < BaseLayout wide /> } >
46
- < Route path = "gallery" element = { < GalleryPage /> } />
47
- < Route path = "organize" element = { < OrganizePage /> } />
48
- </ Route >
49
-
50
- { /* Legacy routes */ }
51
- < Route path = "old" element = { < Layout /> } >
52
- < Route index element = { < Home /> } />
53
- < Route path = "about" element = { < About /> } />
54
- < Route path = "stars" element = { < StarsContainer /> } >
55
- < Route path = ":starId" element = { < StarDetails /> } />
42
+ < GeistProvider themeType = { themeType } >
43
+ < CssBaseline />
44
+ { enableDebugThemeButton && < Button onClick = { switchThemes } height = "200px" > switch theme</ Button > }
45
+
46
+ < BrowserRouter >
47
+ < Routes >
48
+
49
+ { /* could also refactor to use loaders to preload data for the route https://reactrouter.com/en/main/route/loader */ }
50
+ { /* could refactor this to use contexts to inform the layout https://reactjs.org/docs/context.html */ }
51
+
52
+ < Route element = { < BaseLayout /> } >
53
+
54
+ < Route path = "*" element = { (
55
+ < Page title = "Not Found" children = { < NotFoundPage /> } />
56
+ ) } />
57
+ < Route path = "/" element = { (
58
+ < Page title = "Home" children = { < HomePage /> } />
59
+ ) } />
60
+ < Route path = "geist-test" element = { (
61
+ < Page title = "Geist Testing" children = { < GeistTestPage /> } />
62
+ ) } />
63
+
64
+ </ Route >
65
+
66
+ < Route element = { < BaseLayout centered /> } >
67
+
68
+ < Route path = "login" element = { (
69
+ < Page title = "Login" children = { < LoginPage /> } />
70
+ ) } />
71
+ < Route path = "register" element = { (
72
+ < Page title = "Register" children = { < RegisterPage /> } />
73
+ ) } />
74
+
75
+ </ Route >
76
+
77
+ < Route element = { < BaseLayout wide /> } >
78
+
79
+ < Route path = "gallery" element = { (
80
+ < Page title = "Gallery" children = { < GalleryPage /> } />
81
+ ) } />
82
+ < Route path = "organize" element = { (
83
+ < Page title = "Organize" children = { < OrganizePage /> } />
84
+ ) } />
85
+
56
86
</ Route >
57
- < Route path = "clusters" element = { < ClusterContainer /> } >
58
- < Route path = ":clusterId" element = { < ClusterDetails /> } />
87
+
88
+ { /* Legacy routes */ }
89
+ < Route path = "old" element = { < Layout /> } >
90
+ < Route index element = { < Home /> } />
91
+ < Route path = "about" element = { < About /> } />
92
+ < Route path = "stars" element = { < StarsContainer /> } >
93
+ < Route path = ":starId" element = { < StarDetails /> } />
94
+ </ Route >
95
+ < Route path = "clusters" element = { < ClusterContainer /> } >
96
+ < Route path = ":clusterId" element = { < ClusterDetails /> } />
97
+ </ Route >
98
+ < Route path = "test" element = { < Testing /> } />
99
+ < Route path = "*" element = { < NotFound /> } />
59
100
</ Route >
60
- < Route path = "test" element = { < Testing /> } />
61
- < Route path = "*" element = { < NotFound /> } />
62
- </ Route >
63
101
64
- </ Routes >
65
- </ BrowserRouter >
102
+ </ Routes >
103
+ </ BrowserRouter >
104
+
105
+ { /* <YourComponent onClick={switchThemes} /> */ }
106
+ </ GeistProvider >
66
107
</ div >
67
108
) ;
68
109
}
0 commit comments