-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
35 lines (30 loc) · 1.08 KB
/
App.tsx
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
import { useCallback, useState } from 'react';
import { HashRouter, Routes, Route } from 'react-router-dom';
import { ThemeProvider as StyledThemeProvider } from 'styled-components';
import { ThemeProvider } from 'src/contexts';
import Home from 'src/components/Home';
import SystemInfo from 'src/components/SystemInfo';
import GlobalStyles from 'src/styles/GlobalStyles';
import themes from 'src/styles/themes';
import { SupportedThemes } from 'src/types/themes';
const App: React.FC = () => {
const [theme, changeTheme] = useState<SupportedThemes>('dark');
const toggleTheme = useCallback(
() => changeTheme(theme === 'dark' ? 'light' : 'dark'),
[theme, changeTheme],
);
return (
<ThemeProvider value={{ theme, toggleTheme }}>
<StyledThemeProvider theme={themes[theme]}>
<GlobalStyles />
<HashRouter>
<Routes>
<Route path="/system" element={<SystemInfo />} />
<Route path="/" element={<Home />} />
</Routes>
</HashRouter>
</StyledThemeProvider>
</ThemeProvider>
);
};
export default App;