-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathHeader.js
57 lines (53 loc) · 1.51 KB
/
Header.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as React from "react";
import { makeStyles } from "@material-ui/styles";
import Breadcrumbs from "@material-ui/core/Breadcrumbs";
import Link from "@material-ui/core/Link";
import Typography from "@material-ui/core/Typography";
import { useLocation } from "react-router-dom";
const useStyles = makeStyles({
root: {
alignItems: "center",
display: "flex",
flexFlow: "row",
width: "100%",
marginTop: "10px",
},
context: {
flex: "1 0 auto",
},
actions: {
flex: "0 0 auto",
},
});
const Header = (props) => {
const classes = useStyles();
const { title, breadcrumbs, headerTitle } = props;
return (
<div className={classes.root}>
<Typography variant="h3" style={{ marginBottom: "10px" }}>
{headerTitle}
</Typography>
<div className={classes.context}>
{title && (
<Typography variant="h4" className={classes.title}>
{title}
</Typography>
)}
{breadcrumbs && breadcrumbs.length > 0 && (
<Breadcrumbs aria-label="breadcrumb">
{breadcrumbs.slice(0, breadcrumbs.length - 1).map((b) => (
<Link color="inherit" href={b.href} key={b.name}>
{b.name}
</Link>
))}
<Typography color="textPrimary">
{breadcrumbs[breadcrumbs.length - 1].name}
</Typography>
</Breadcrumbs>
)}
</div>
<div className={classes.actions}>{props.children}</div>
</div>
);
};
export default Header;