2021-01-17 08:31:50 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
2020-07-13 14:47:30 +00:00
|
|
|
|
2021-01-17 08:31:50 +00:00
|
|
|
import { makeStyles } from '@material-ui/core/styles';
|
2020-07-13 14:47:30 +00:00
|
|
|
|
|
|
|
const useStyles = makeStyles(theme => ({
|
|
|
|
section: {
|
2021-01-17 08:31:50 +00:00
|
|
|
padding: '3rem 0',
|
|
|
|
'&.is-primary': {
|
2020-07-13 17:04:46 +00:00
|
|
|
backgroundColor: theme.palette.primary.main,
|
|
|
|
},
|
2021-01-17 08:31:50 +00:00
|
|
|
'&.is-black': {
|
|
|
|
backgroundColor: '#000',
|
|
|
|
color: '#fff',
|
2020-07-14 10:24:48 +00:00
|
|
|
},
|
2021-01-17 08:31:50 +00:00
|
|
|
[theme.breakpoints.up('md')]: {
|
|
|
|
padding: '6rem 0',
|
2020-07-14 10:24:48 +00:00
|
|
|
},
|
2021-01-17 08:31:50 +00:00
|
|
|
'&.is-small': {
|
|
|
|
padding: '3rem 0',
|
2020-07-13 14:47:30 +00:00
|
|
|
},
|
|
|
|
},
|
2021-01-17 08:31:50 +00:00
|
|
|
}));
|
2020-07-13 14:47:30 +00:00
|
|
|
|
2020-07-13 17:04:46 +00:00
|
|
|
export const BG_COLOR = {
|
2021-01-17 08:31:50 +00:00
|
|
|
TRANSPARENT: 'transparent',
|
|
|
|
BLACK: 'black',
|
|
|
|
PRIMARY: 'primary',
|
|
|
|
};
|
2020-07-13 17:04:46 +00:00
|
|
|
|
2020-07-14 10:24:48 +00:00
|
|
|
export const SIZE = {
|
2021-01-17 08:31:50 +00:00
|
|
|
SMALL: 'small',
|
|
|
|
MEDIUM: 'medium',
|
|
|
|
};
|
2020-07-14 10:24:48 +00:00
|
|
|
|
2020-07-14 12:38:07 +00:00
|
|
|
function Section({ children, className, bgColor, component, size, ...rest }) {
|
2021-01-17 08:31:50 +00:00
|
|
|
const classes = useStyles();
|
|
|
|
const Component = component || 'section';
|
2020-07-13 17:04:46 +00:00
|
|
|
return (
|
2020-07-14 10:24:48 +00:00
|
|
|
<Component
|
2020-07-13 17:04:46 +00:00
|
|
|
className={classnames(classes.section, className, {
|
2021-01-17 08:31:50 +00:00
|
|
|
'is-primary': bgColor === BG_COLOR.PRIMARY,
|
|
|
|
'is-black': bgColor === BG_COLOR.BLACK,
|
|
|
|
'is-small': size === SIZE.SMALL,
|
2020-07-13 17:04:46 +00:00
|
|
|
})}
|
2020-07-14 12:38:07 +00:00
|
|
|
{...rest}
|
2020-07-13 17:04:46 +00:00
|
|
|
>
|
|
|
|
{children}
|
2020-07-14 10:24:48 +00:00
|
|
|
</Component>
|
2021-01-17 08:31:50 +00:00
|
|
|
);
|
2020-07-13 17:04:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Section.defaultProps = {
|
|
|
|
bgColor: BG_COLOR.TRANSPARENT,
|
2020-07-14 10:24:48 +00:00
|
|
|
size: SIZE.MEDIUM,
|
2021-01-17 08:31:50 +00:00
|
|
|
};
|
2020-07-13 17:04:46 +00:00
|
|
|
|
|
|
|
Section.propTypes = {
|
|
|
|
bgColor: PropTypes.oneOf(Object.values(BG_COLOR)).isRequired,
|
2020-07-14 10:24:48 +00:00
|
|
|
size: PropTypes.oneOf(Object.values(SIZE)).isRequired,
|
2021-01-17 08:31:50 +00:00
|
|
|
};
|
2020-07-13 14:47:30 +00:00
|
|
|
|
2021-01-17 08:31:50 +00:00
|
|
|
export default Section;
|