add the Section component

This commit is contained in:
Dawid Wysokiński 2021-03-27 08:03:46 +01:00
parent aa34386e4a
commit 7915f1041a
2 changed files with 75 additions and 1 deletions

View File

@ -72,7 +72,6 @@ const useStyles = makeStyles(theme => ({
justifyContent: 'center',
paddingTop: theme.spacing(3),
paddingBottom: theme.spacing(3),
minHeight: '60vh',
},
imageWrapper: {
textAlign: 'center',

View File

@ -0,0 +1,75 @@
import React from 'react';
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
export enum Size {
Medium = 'medium',
Large = 'large',
}
export enum BgColor {
Primary = 'primary',
PrimaryDark = 'primary.dark',
Secondary = 'secondary',
SecondaryDark = 'secondary.dark',
}
export interface SectionProps extends React.HTMLAttributes<HTMLElement> {
size: Size;
bgColor: BgColor;
className: string;
}
const Section = ({
size,
bgColor,
className,
children,
...rest
}: SectionProps) => {
const classes = useStyles();
return (
<section
className={clsx(className, classes.section, {
['is-medium']: size === Size.Medium,
['is-large']: size === Size.Large,
['is-primary']: bgColor === BgColor.Primary,
['is-primary-dark']: bgColor === BgColor.PrimaryDark,
['is-secondary']: bgColor === BgColor.Secondary,
['is-secondary-dark']: bgColor === BgColor.SecondaryDark,
})}
{...rest}
>
{children}
</section>
);
};
const useStyles = makeStyles(theme => ({
section: {
'&.is-medium': {
padding: theme.spacing(3, 0),
},
'&.is-large': {
padding: theme.spacing(8, 0),
},
'&.is-primary': {
backgroundColor: theme.palette.primary.main,
color: theme.palette.primary.contrastText,
},
'&.is-primary-dark': {
backgroundColor: theme.palette.primary.dark,
color: theme.palette.primary.contrastText,
},
'&.is-secondary': {
backgroundColor: theme.palette.secondary.main,
color: theme.palette.secondary.contrastText,
},
'&.is-secondary-dark': {
backgroundColor: theme.palette.secondary.dark,
color: theme.palette.secondary.contrastText,
},
},
}));
export default Section;