Files
bee-dashboard/src/components/HistoryHeader.tsx
T
Vojtech Simetka a90b4c439b chore(deps): update react router from v5 to v6 (#280)
* chore(deps): update react router from v5 to v6

* fix: correctly choose navigate target if there is no history
2022-01-17 14:47:26 +01:00

42 lines
906 B
TypeScript

import { Box, createStyles, Grid, makeStyles, Typography } from '@material-ui/core'
import { ArrowBack } from '@material-ui/icons'
import { ReactElement } from 'react'
import { useNavigate } from 'react-router-dom'
interface Props {
children: string
}
const useStyles = makeStyles(() =>
createStyles({
pressable: {
cursor: 'pointer',
},
icon: {
color: '#242424',
},
}),
)
export function HistoryHeader({ children }: Props): ReactElement {
const classes = useStyles()
const navigate = useNavigate()
function goBack() {
navigate(-1)
}
return (
<Box mb={4}>
<Grid container direction="row">
<Box mr={2}>
<div className={classes.pressable} onClick={goBack}>
<ArrowBack className={classes.icon} />
</div>
</Box>
<Typography variant="h1">{children}</Typography>
</Grid>
</Box>
)
}