front-hub/src/components/SectionWrapper.tsx

34 lines
957 B
TypeScript
Raw Normal View History

2022-11-18 16:51:10 +00:00
import { Breakpoint, Container, SxProps, Theme, useMediaQuery, useTheme } from "@mui/material";
2022-11-17 12:25:23 +00:00
import React, { ElementType } from "react";
interface Props {
component?: ElementType;
outerContainerSx?: SxProps<Theme>;
sx?: SxProps<Theme>;
innerSx?: SxProps<Theme>;
maxWidth?: false | Breakpoint;
children?: React.ReactNode;
2022-11-17 12:25:23 +00:00
}
2022-11-18 16:51:10 +00:00
export default function SectionWrapper({ component, outerContainerSx: sx, sx: innerSx, children, maxWidth }: Props) {
const theme = useTheme();
const matchMd = useMediaQuery(theme.breakpoints.up("md"));
const isMobile = useMediaQuery(theme.breakpoints.down(380));
2022-11-17 12:25:23 +00:00
return (
<Container component={component || "div"} maxWidth={false} disableGutters sx={sx}>
<Container
disableGutters
maxWidth={maxWidth}
sx={{
px: matchMd ? (isMobile ? "0px" : "20px") : "18px",
...innerSx,
}}
>
{children}
</Container>
</Container>
);
}