11import * as React from 'react'
2- import { Header } from './style/Header '
2+ import { useState } from 'react '
33import { Footer } from './style/Footer'
44import { Main , Info } from './style/Main'
5+ import { Theme , dark , light } from './style/theme'
56import { GlobalStyle } from './style/Global'
67import { Schedule } from './Schedule'
78import { format } from 'date-fns'
9+ import { ThemeProvider } from 'styled-components'
810
911import LockIcon from 'feather-icons/dist/icons/lock.svg'
1012import UnLockIcon from 'feather-icons/dist/icons/unlock.svg'
13+ import LightModeIcon from 'feather-icons/dist/icons/sun.svg'
14+ import DarkModeIcon from 'feather-icons/dist/icons/moon.svg'
15+ import { Button } from './style/Form'
1116
1217export const App = ( ) => {
18+ const [ theme , updateTheme ] = useState < Theme > (
19+ window . localStorage . getItem ( 'theme' ) === 'light' ? light : dark ,
20+ )
1321 let cfg = {
1422 name : 'ExampleConf' ,
1523 day : format ( new Date ( ) , 'yyyy-MM-dd' ) ,
@@ -40,9 +48,8 @@ export const App = () => {
4048 console . log ( cfg )
4149 }
4250 return (
43- < >
51+ < ThemeProvider theme = { theme } >
4452 < GlobalStyle />
45- < Header > </ Header >
4653 < Main >
4754 < Schedule
4855 sessions = { cfg . sessions }
@@ -51,11 +58,35 @@ export const App = () => {
5158 conferenceDate = { cfg . day }
5259 />
5360 < Info >
54- Click the < LockIcon /> icon to create your own schedule. When done,
55- click the < UnLockIcon /> and share the updated URL.
61+ < p >
62+ Click the < LockIcon /> icon to create your own schedule. When done,
63+ click the < UnLockIcon /> and share the updated URL.
64+ </ p >
65+ </ Info >
66+ < Info >
67+ { theme === dark && (
68+ < Button
69+ onClick = { ( ) => {
70+ updateTheme ( light )
71+ window . localStorage . setItem ( 'theme' , 'light' )
72+ } }
73+ >
74+ < LightModeIcon /> switch to light mode
75+ </ Button >
76+ ) }
77+ { theme === light && (
78+ < Button
79+ onClick = { ( ) => {
80+ updateTheme ( dark )
81+ window . localStorage . setItem ( 'theme' , 'dark' )
82+ } }
83+ >
84+ < DarkModeIcon /> switch to dark mode
85+ </ Button >
86+ ) }
5687 </ Info >
5788 </ Main >
5889 < Footer />
59- </ >
90+ </ ThemeProvider >
6091 )
6192}
0 commit comments