Create page section component

This commit is contained in:
Jan Tuomi
2018-11-16 20:18:22 +02:00
parent 14605cd0fc
commit 64151cec83
3 changed files with 56 additions and 0 deletions
@@ -0,0 +1,19 @@
@import "../../assets/scss/globals";
.page-section {
padding: 2rem 1rem;
background-color: $dark-blue;
display: flex;
flex-flow: column wrap;
justify-content: flex-start;
&.dark-blue {
background-color: $dark-blue;
color: $white;
}
&.white {
background-color: $white;
color: $dark-blue;
}
}
@@ -0,0 +1,35 @@
import * as React from "react";
import "./PageSection.scss";
export enum BackgroundColor {
DarkBlue,
White,
}
export interface PageSectionProps {
backgroundColor: BackgroundColor;
}
export interface PageSectionState {}
const colorToClass = (color: BackgroundColor): string => {
if (color === BackgroundColor.DarkBlue) {
return "dark-blue";
}
else if (color === BackgroundColor.White) {
return "white";
}
};
class PageSection extends React.Component<PageSectionProps, PageSectionState> {
render() {
const { backgroundColor, children } = this.props;
const className = `page-section ${colorToClass(backgroundColor)}`;
return (
<div className={className}>
{children}
</div>
);
}
}
export default PageSection;
+2
View File
@@ -0,0 +1,2 @@
import PageSection from "./PageSection";
export default PageSection;