-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Section.tsx
52 lines (48 loc) · 1.17 KB
/
Section.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 { Box, BoxProps, Paper, Typography } from "@mui/material";
import createStyles from "@mui/styles/createStyles";
import makeStyles from "@mui/styles/makeStyles";
import classNames from "classnames";
import React, { PropsWithChildren } from "react";
import { ClassNameProps } from "./props";
const useStyles = makeStyles((theme) =>
createStyles({
contentContainer: {
padding: theme.spacing(2),
height: "100%",
},
contentContainerNoTopPadding: {
paddingTop: 0,
},
}),
);
type SectionProps = {
title?: string;
noTopPadding?: boolean;
} & ClassNameProps &
BoxProps;
export const Section = ({
title,
children,
className,
noTopPadding = false,
...props
}: PropsWithChildren<SectionProps>) => {
const classes = useStyles();
return (
<Box className={className} {...props}>
{title && (
<Box paddingBottom={2}>
<Typography variant="h4">{title}</Typography>
</Box>
)}
<Paper
variant="outlined"
className={classNames(classes.contentContainer, {
[classes.contentContainerNoTopPadding]: noTopPadding,
})}
>
{children}
</Paper>
</Box>
);
};