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

66 lines
2.2 KiB
TypeScript
Raw Normal View History

2021-02-20 02:57:52 +03:30
// TODO: remove above!
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, { useContext, useState } from 'react';
2020-12-24 16:50:50 +01:00
import { makeStyles } from '@material-ui/core/styles';
2020-12-24 15:02:03 +03:30
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
2021-03-08 21:04:42 +03:30
import NavBarContext from '../context/NavbarContext';
2021-01-23 01:20:16 +03:30
import DarkTheme from '../context/DarkTheme';
2021-03-18 21:46:24 +03:30
import TemporaryDrawer from './TemporaryDrawer';
2020-12-24 15:02:03 +03:30
const useStyles = makeStyles((theme) => ({
root: {
flexGrow: 1,
},
menuButton: {
marginRight: theme.spacing(2),
},
title: {
flexGrow: 1,
},
}));
export default function NavBar() {
const classes = useStyles();
2020-12-24 16:50:50 +01:00
const [drawerOpen, setDrawerOpen] = useState(false);
2021-03-18 21:46:24 +03:30
const { title, action, override } = useContext(NavBarContext);
2021-01-23 01:20:16 +03:30
2021-02-20 02:57:52 +03:30
const { darkTheme } = useContext(DarkTheme);
2021-01-23 01:20:16 +03:30
2020-12-24 15:02:03 +03:30
return (
2021-03-18 21:46:24 +03:30
<>
{override.status && override.value}
{!override.status
&& (
<div className={classes.root}>
2021-03-19 14:52:20 +03:30
<AppBar position="fixed" color={darkTheme ? 'default' : 'primary'}>
2021-03-18 21:46:24 +03:30
<Toolbar>
<IconButton
edge="start"
className={classes.menuButton}
color="inherit"
aria-label="menu"
disableRipple
onClick={() => setDrawerOpen(true)}
2021-01-23 02:57:32 +03:30
>
2021-03-18 21:46:24 +03:30
<MenuIcon />
</IconButton>
<Typography variant="h6" className={classes.title}>
{title}
</Typography>
{action}
</Toolbar>
</AppBar>
<TemporaryDrawer drawerOpen={drawerOpen} setDrawerOpen={setDrawerOpen} />
</div>
)}
</>
2020-12-24 15:02:03 +03:30
);
}