Files
suwayomi-material-you-webui/webUI/react/src/App.tsx

99 lines
3.8 KiB
TypeScript
Raw Normal View History

2021-01-26 23:32:12 +03:30
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
2021-01-22 17:00:33 +03:30
import React, { useState } from 'react';
2020-12-24 03:21:18 +03:30
import {
2021-01-19 14:47:07 +03:30
BrowserRouter as Router, Route, Switch,
2020-12-24 17:19:49 +03:30
} from 'react-router-dom';
2021-01-23 02:32:18 +03:30
import { Container } from '@material-ui/core';
2021-01-23 01:20:16 +03:30
import CssBaseline from '@material-ui/core/CssBaseline';
import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles';
2020-12-24 17:19:49 +03:30
import NavBar from './components/NavBar';
2021-01-19 14:47:07 +03:30
import Home from './screens/Home';
import Sources from './screens/Sources';
import Extensions from './screens/Extensions';
2021-01-19 15:07:20 +03:30
import MangaList from './screens/MangaList';
2021-01-19 20:20:28 +03:30
import Manga from './screens/Manga';
2021-01-20 01:05:24 +03:30
import Reader from './screens/Reader';
2021-01-22 18:07:31 +03:30
import Search from './screens/SearchSingle';
2021-01-22 17:00:33 +03:30
import NavBarTitle from './context/NavbarTitle';
2021-01-23 01:20:16 +03:30
import DarkTheme from './context/DarkTheme';
2021-02-13 21:12:18 +03:30
import Library from './screens/Library';
2020-12-24 16:50:50 +01:00
export default function App() {
2021-01-22 17:00:33 +03:30
const [title, setTitle] = useState<string>('Tachidesk');
2021-01-23 01:20:16 +03:30
const [darkTheme, setDarkTheme] = useState<boolean>(true);
const navTitleContext = { title, setTitle };
const darkThemeContext = { darkTheme, setDarkTheme };
const theme = React.useMemo(
() => createMuiTheme({
palette: {
type: darkTheme ? 'dark' : 'light',
},
2021-01-23 02:53:00 +03:30
overrides: {
MuiCssBaseline: {
'@global': {
'*::-webkit-scrollbar': {
width: '10px',
background: darkTheme ? '#222' : '#e1e1e1',
},
'*::-webkit-scrollbar-thumb': {
background: darkTheme ? '#111' : '#aaa',
borderRadius: '5px',
},
},
},
},
2021-01-23 01:20:16 +03:30
}),
[darkTheme],
);
2021-01-22 17:00:33 +03:30
2020-12-24 16:50:50 +01:00
return (
<Router>
2021-01-23 01:20:16 +03:30
<ThemeProvider theme={theme}>
<NavBarTitle.Provider value={navTitleContext}>
<CssBaseline />
<DarkTheme.Provider value={darkThemeContext}>
<NavBar />
</DarkTheme.Provider>
2021-01-23 02:53:00 +03:30
<Container maxWidth={false} disableGutters>
2021-01-23 02:32:18 +03:30
<Switch>
<Route path="/sources/:sourceId/search/">
<Search />
</Route>
<Route path="/extensions">
<Extensions />
</Route>
<Route path="/sources/:sourceId/popular/">
<MangaList popular />
</Route>
<Route path="/sources/:sourceId/latest/">
<MangaList popular={false} />
</Route>
<Route path="/sources">
<Sources />
</Route>
<Route path="/manga/:mangaId/chapter/:chapterId">
<Reader />
</Route>
<Route path="/manga/:id">
<Manga />
</Route>
2021-02-13 21:12:18 +03:30
<Route path="/library">
<Library />
</Route>
2021-01-23 02:32:18 +03:30
<Route path="/">
<Home />
</Route>
</Switch>
</Container>
2021-01-23 01:20:16 +03:30
</NavBarTitle.Provider>
</ThemeProvider>
2020-12-24 16:50:50 +01:00
</Router>
);
}