front-hub/src/components/SectionWrapper.tsx

36 lines
1003 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;
2022-11-18 16:51:10 +00:00
outerContainerSx?: SxProps<Theme>;
sx: SxProps<Theme>;
2022-11-17 12:25:23 +00:00
maxWidth?: false | Breakpoint;
children?: React.ReactNode;
}
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"));
2022-11-17 12:25:23 +00:00
return (
<Container
component={component || "div"}
maxWidth={false}
disableGutters
sx={sx}
>
<Container
disableGutters
maxWidth={maxWidth}
2022-11-18 16:51:10 +00:00
sx={{
px: matchMd ? "20px" : "18px",
...innerSx
}}
2022-11-17 12:25:23 +00:00
>
{children}
</Container>
</Container>
);
}