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

69 lines
2.2 KiB
TypeScript
Raw Normal View History

/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
2021-01-26 23:32:12 +03:30
* 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';
2021-09-09 17:51:22 +04:30
import makeStyles from '@mui/styles/makeStyles';
import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import IconButton from '@mui/material/IconButton';
import MenuIcon from '@mui/icons-material/Menu';
2021-05-17 01:36:31 +04:30
import NavBarContext from '../../context/NavbarContext';
import DarkTheme from '../../context/DarkTheme';
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
2021-09-09 17:51:22 +04:30
&& (
<div className={classes.root}>
<AppBar position="fixed" color={darkTheme ? 'default' : 'primary'}>
<Toolbar>
<IconButton
edge="start"
className={classes.menuButton}
color="inherit"
aria-label="menu"
disableRipple
onClick={() => setDrawerOpen(true)}
size="large"
>
<MenuIcon />
</IconButton>
<Typography variant="h6" className={classes.title}>
{title}
</Typography>
{action}
</Toolbar>
</AppBar>
<TemporaryDrawer drawerOpen={drawerOpen} setDrawerOpen={setDrawerOpen} />
</div>
)}
2021-03-18 21:46:24 +03:30
</>
2020-12-24 15:02:03 +03:30
);
}