-
Notifications
You must be signed in to change notification settings - Fork 230
/
Copy pathindex.js
122 lines (102 loc) · 3.59 KB
/
index.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
=========================================================
* Material Dashboard 2 React - v2.1.0
=========================================================
* Product Page: https://www.creative-tim.com/product/material-dashboard-react
* Copyright 2022 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 { useState, useEffect } from "react";
// prop-types is a library for typechecking of props.
import PropTypes from "prop-types";
// @mui material components
import Card from "@mui/material/Card";
import Grid from "@mui/material/Grid";
// Material Dashboard 2 React components
import MDBox from "components/MDBox";
import MDTypography from "components/MDTypography";
import MDAvatar from "components/MDAvatar";
// Material Dashboard 2 React base styles
import breakpoints from "assets/theme/base/breakpoints";
// Images
import burceMars from "assets/images/bruce-mars.jpg";
import backgroundImage from "assets/images/bg-profile.jpeg";
function Header({ name, children }) {
const [tabsOrientation, setTabsOrientation] = useState("horizontal");
const [tabValue, setTabValue] = useState(0);
useEffect(() => {
// A function that sets the orientation state of the tabs.
function handleTabsOrientation() {
return window.innerWidth < breakpoints.values.sm
? setTabsOrientation("vertical")
: setTabsOrientation("horizontal");
}
/**
The event listener that's calling the handleTabsOrientation function when resizing the window.
*/
window.addEventListener("resize", handleTabsOrientation);
// Call the handleTabsOrientation function to set the state with the initial value.
handleTabsOrientation();
// Remove event listener on cleanup
return () => window.removeEventListener("resize", handleTabsOrientation);
}, [tabsOrientation]);
const handleSetTabValue = (event, newValue) => setTabValue(newValue);
return (
<MDBox position="relative" mb={5}>
<MDBox
display="flex"
alignItems="center"
position="relative"
minHeight="18.75rem"
borderRadius="xl"
sx={{
backgroundImage: ({ functions: { rgba, linearGradient }, palette: { gradients } }) =>
`${linearGradient(
rgba(gradients.info.main, 0.6),
rgba(gradients.info.state, 0.6)
)}, url(${backgroundImage})`,
backgroundSize: "cover",
backgroundPosition: "50%",
overflow: "hidden",
}}
/>
<Card
sx={{
position: "relative",
mt: -8,
mx: 3,
py: 2,
px: 2,
}}
>
<Grid container spacing={3} alignItems="center">
<Grid item>
<MDAvatar src={burceMars} alt="profile-image" size="xl" shadow="sm" />
</Grid>
<Grid item>
<MDBox height="100%" mt={0.5} lineHeight={1}>
<MDTypography variant="h5" fontWeight="medium">
{name}
</MDTypography>
<MDTypography variant="button" color="text" fontWeight="regular">
CEO / Co-Founder
</MDTypography>
</MDBox>
</Grid>
</Grid>
{children}
</Card>
</MDBox>
);
}
// Setting default props for the Header
Header.defaultProps = {
children: "",
};
// Typechecking props for the Header
Header.propTypes = {
children: PropTypes.node,
};
export default Header;