zepio/app/components/column.js

33 lines
762 B
JavaScript
Raw Normal View History

2018-12-12 13:13:39 -08:00
// @flow
2019-01-29 07:03:04 -08:00
import React, { type Node, type ElementProps } from 'react';
2018-12-12 13:13:39 -08:00
import styled from 'styled-components';
const Flex = styled.div`
display: flex;
flex-direction: column;
align-items: ${props => props.alignItems};
justify-content: ${props => props.justifyContent};
2018-12-20 06:31:52 -08:00
${props => props.width && `width: ${props.width};`}
2018-12-12 13:13:39 -08:00
`;
type Props = {
...ElementProps<'div'>,
2018-12-12 13:13:39 -08:00
alignItems?: string,
justifyContent?: string,
className?: string,
children: Node,
2018-12-20 06:31:52 -08:00
width?: string,
2018-12-12 13:13:39 -08:00
};
export const ColumnComponent = ({ children, ...props }: Props) => (
2019-01-29 07:03:04 -08:00
<Flex {...props}>{React.Children.map(children, (ch: Node) => ch)}</Flex>
2018-12-12 13:13:39 -08:00
);
ColumnComponent.defaultProps = {
alignItems: 'flex-start',
justifyContent: 'flex-start',
className: '',
2018-12-20 06:31:52 -08:00
width: '',
2018-12-12 13:13:39 -08:00
};