-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathHeader.tsx
52 lines (49 loc) · 1.41 KB
/
Header.tsx
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
import { alpha, Box, Paper, useMediaQuery } from "@mui/material";
import { FC, useEffect, useRef } from "react";
import styles from "./header.module.scss";
import { HeaderDesktop } from "components/Header/components/HeaderDesktop";
import { HeaderMobile } from "components/Header/components/HeaderMobile";
interface IHeader {
allowPadding: boolean;
}
export const Header: FC<IHeader> = ({ allowPadding }) => {
const marginTop = 20;
const headerRef = useRef<HTMLElement>(null);
useEffect(() => {
if (headerRef.current) {
const height = headerRef.current.getBoundingClientRect().height;
document.documentElement.style.setProperty(
"--header-height",
`${height + marginTop}px`,
);
}
}, []);
const isLT1200 = useMediaQuery("(max-width:1200px)");
return (
<>
<header ref={headerRef} className={styles.header} style={{ marginTop }}>
<Paper
sx={t => ({
bgcolor: alpha(t.palette.background.paper, 0.8),
width: "100%",
webkitBackdropFilter: "blur(10px)",
backdropFilter: "blur(10px)",
borderRadius: 1,
justifyContent: "center",
display: "flex",
alignItems: "center",
p: "8px 20px",
})}
elevation={0}
>
{isLT1200 ? (
<HeaderMobile key="headerMobile" />
) : (
<HeaderDesktop key="headerDesktop" />
)}
</Paper>
</header>
<Box height={allowPadding ? "calc(var(--header-height) + 5px)" : 0} />
</>
);
};