zepio/app/components/column.js

34 lines
769 B
JavaScript
Raw Normal View History

2018-12-12 13:13:39 -08:00
// @flow
import React from 'react';
import styled from 'styled-components';
import type { Node, ElementProps } from 'react';
2018-12-12 13:13:39 -08:00
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) => (
<Flex {...props}>{React.Children.map(children, ch => ch)}</Flex>
);
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
};