Files
bee-dashboard/src/components/NavBar.tsx
T
Andrew LeTourneau 325a59098e fix: Setting explicit Typography components to fix invalid DOM (#25)
* fix: Setting explicit Typography components to fix invalid DOM

Typography, by default, uses <p> as it's underlying component. When used
to embed other components it resulted in a DOM errors like: "<p> cannot appear
as descendant of <p>"... and more.

fix: Linting

* chore: apply suggestions from code review

Co-authored-by: Vojtech Simetka <vojtech@simetka.cz>
2021-03-29 10:23:12 +02:00

70 lines
1.7 KiB
TypeScript

import React, { useState } from 'react';
import { createStyles, Theme, makeStyles } from '@material-ui/core/styles';
import { Toolbar, Chip, IconButton } from '@material-ui/core/';
import { Sun, Moon } from 'react-feather';
const drawerWidth = 240;
const useStyles = makeStyles((theme: Theme) =>
createStyles({
appBar: {
width: `calc(100% - ${drawerWidth}px)`,
marginLeft: drawerWidth,
},
network: {
}
}),
);
export default function SideBar(props: any) {
const [darkMode, toggleDarkMode] = useState(false);
const switchTheme = () => {
let theme = localStorage.getItem('theme')
if (theme) {
localStorage.setItem('theme', theme === 'light' ? 'dark' : 'light')
} else {
localStorage.setItem('theme', darkMode ? 'dark' : 'light')
}
toggleDarkMode(!darkMode)
window.location.reload()
}
const classes = useStyles();
return (
<div>
<div style={{ display: 'fixed' }} className={classes.appBar}>
<Toolbar style={{ display: 'flex' }}>
<Chip
style={{ marginLeft: '7px' }}
size="small"
label='Goerli'
className={classes.network}
/>
<div style={{ width: '100%' }}>
<div style={{ float: 'right' }} >
<IconButton style={{ marginRight: '10px' }} aria-label="dark-mode" onClick={() => switchTheme()}>
{props.themeMode === 'dark' ?
<Moon />
:
<Sun />
}
</IconButton>
{/* <Chip
label="Connect Wallet"
color="primary"
/> */}
</div>
</div>
</Toolbar>
</div>
</div>
);
}