dwysokinski.me/src/components/Section.js

46 lines
924 B
JavaScript
Raw Normal View History

import React from "react"
2020-07-13 17:04:46 +00:00
import PropTypes from "prop-types"
import classnames from "classnames"
import { makeStyles } from "@material-ui/core/styles"
const useStyles = makeStyles(theme => ({
section: {
padding: "3rem 1.5rem",
2020-07-13 17:04:46 +00:00
"&.is-primary": {
backgroundColor: theme.palette.primary.main,
},
[theme.breakpoints.up("md")]: {
padding: "6rem 1.5rem",
},
},
}))
2020-07-13 17:04:46 +00:00
export const BG_COLOR = {
TRANSPARENT: "transparent",
PRIMARY: "primary",
}
function Section({ children, className, bgColor }) {
const classes = useStyles()
2020-07-13 17:04:46 +00:00
return (
<section
className={classnames(classes.section, className, {
"is-primary": bgColor === BG_COLOR.PRIMARY,
})}
>
{children}
</section>
)
}
Section.defaultProps = {
bgColor: BG_COLOR.TRANSPARENT,
}
Section.propTypes = {
bgColor: PropTypes.oneOf(Object.values(BG_COLOR)).isRequired,
}
export default Section