-
Notifications
You must be signed in to change notification settings - Fork 5k
Expand file tree
/
Copy pathindex.js
More file actions
89 lines (81 loc) · 2.38 KB
/
index.js
File metadata and controls
89 lines (81 loc) · 2.38 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// react-router-dom components
import { Link } from "react-router-dom";
// prop-types is a library for typechecking of props.
import PropTypes from "prop-types";
// @mui material components
import { Breadcrumbs as MuiBreadcrumbs } from "@mui/material";
import Icon from "@mui/material/Icon";
// Material Dashboard 2 React components
import MDBox from "components/MDBox";
import MDTypography from "components/MDTypography";
function Breadcrumbs({ icon, title, route, light }) {
const routes = route.slice(0, -1);
return (
<MDBox mr={{ xs: 0, xl: 8 }}>
<MuiBreadcrumbs
sx={{
"& .MuiBreadcrumbs-separator": {
color: ({ palette: { white, grey } }) => (light ? white.main : grey[600]),
},
}}
>
<Link to="/">
<MDTypography
component="span"
variant="body2"
color={light ? "white" : "dark"}
opacity={light ? 0.8 : 0.5}
sx={{ lineHeight: 0 }}
>
<Icon>{icon}</Icon>
</MDTypography>
</Link>
{routes.map((el) => (
<Link to={`/${el}`} key={el}>
<MDTypography
component="span"
variant="button"
fontWeight="regular"
textTransform="capitalize"
color={light ? "white" : "dark"}
opacity={light ? 0.8 : 0.5}
sx={{ lineHeight: 0 }}
>
{el}
</MDTypography>
</Link>
))}
<MDTypography
variant="button"
fontWeight="regular"
textTransform="capitalize"
color={light ? "white" : "dark"}
sx={{ lineHeight: 0 }}
>
{title.replace("-", " ")}
</MDTypography>
</MuiBreadcrumbs>
<MDTypography
fontWeight="bold"
textTransform="capitalize"
variant="h6"
color={light ? "white" : "dark"}
noWrap
>
{title.replace("-", " ")}
</MDTypography>
</MDBox>
);
}
// Setting default values for the props of Breadcrumbs
Breadcrumbs.defaultProps = {
light: false,
};
// Typechecking props for the Breadcrumbs
Breadcrumbs.propTypes = {
icon: PropTypes.node.isRequired,
title: PropTypes.string.isRequired,
route: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).isRequired,
light: PropTypes.bool,
};
export default Breadcrumbs;