Created
January 26, 2018 00:04
-
-
Save iamdanthedev/a4241068762e0d8d3ef1987208abf736 to your computer and use it in GitHub Desktop.
Three column + header layout react component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import styled from 'styled-components'; | |
import { Col, Grid, Row } from 'react-styled-flexboxgrid'; | |
import Form from 'semantic-ui-react/dist/commonjs/collections/Form/Form'; | |
import { SubheaderCentered } from '../typography/Subheader'; | |
/** | |
* |-------------------| | |
* | | | |
* |-------------------| | |
* | | | | | |
* | | | | | |
* | | | | | |
* |-------------------| | |
*/ | |
export const RecipeEditorLayout = props => { | |
const { children } = props; | |
if (React.Children.count(children) !== 3) { | |
throw new Error('ItemEditor3ColPage must have 3 children'); | |
} | |
return ( | |
<FormStyled> | |
<Row> | |
<StyledCol xs={12} sm={4} md={4} lg={4}> | |
<SubheaderCentered>General Info</SubheaderCentered> | |
{children[0]} | |
</StyledCol> | |
<StyledCol xs={12} sm={6} md={6} lg={6}> | |
<SubheaderCentered>Ingredients</SubheaderCentered> | |
{children[1]} | |
</StyledCol> | |
<StyledCol xs={12} sm={2} md={2} lg={2}> | |
<SubheaderCentered>Nutrients</SubheaderCentered> | |
{children[2]} | |
</StyledCol> | |
</Row> | |
</FormStyled> | |
); | |
}; | |
export default RecipeEditorLayout; | |
const StyledCol = styled(Col)` | |
display: flex; | |
flex-direction: column; | |
`; | |
const FormStyled = styled(Form)` | |
flex: 1; | |
& ${StyledCol} { | |
&:not(:first-child) { | |
border-left: 1px solid #e4e4e4; | |
} | |
} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment