-
Notifications
You must be signed in to change notification settings - Fork 5k
Expand file tree
/
Copy pathindex.jsx
More file actions
64 lines (49 loc) · 1.77 KB
/
index.jsx
File metadata and controls
64 lines (49 loc) · 1.77 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
/**
=========================================================
* Material Dashboard 2 React - v2.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/material-dashboard-react
* Copyright 2023 Creative Tim (https://www.creative-tim.com)
Coded by www.creative-tim.com
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
import { useEffect } from "react";
// react-router-dom components
import { useLocation } from "react-router-dom";
// prop-types is a library for typechecking of props.
import PropTypes from "prop-types";
// Material Dashboard 2 React components
import MDBox from "components/MDBox";
// Material Dashboard 2 React context
import { useMaterialUIController, setLayout } from "context";
function DashboardLayout({ children }) {
const [controller, dispatch] = useMaterialUIController();
const { miniSidenav } = controller;
const { pathname } = useLocation();
useEffect(() => {
setLayout(dispatch, "dashboard");
}, [pathname]);
return (
<MDBox
sx={({ breakpoints, transitions, functions: { pxToRem } }) => ({
p: 3,
position: "relative",
[breakpoints.up("xl")]: {
marginLeft: miniSidenav ? pxToRem(120) : pxToRem(274),
transition: transitions.create(["margin-left", "margin-right"], {
easing: transitions.easing.easeInOut,
duration: transitions.duration.standard,
}),
},
})}
>
{children}
</MDBox>
);
}
// Typechecking props for the DashboardLayout
DashboardLayout.propTypes = {
children: PropTypes.node.isRequired,
};
export default DashboardLayout;