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';
|
|
|
|
|
2019-02-06 19:06:48 -08:00
|
|
|
type FlexProps =
|
|
|
|
| {
|
|
|
|
alignItems: string,
|
|
|
|
justifyContent: string,
|
|
|
|
width: string,
|
|
|
|
}
|
|
|
|
| Object;
|
2018-12-12 13:13:39 -08:00
|
|
|
const Flex = styled.div`
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2019-02-06 19:06:48 -08:00
|
|
|
align-items: ${(props: FlexProps) => props.alignItems};
|
|
|
|
justify-content: ${(props: FlexProps) => props.justifyContent};
|
|
|
|
${(props: FlexProps) => props.width && `width: ${props.width};`}
|
2018-12-12 13:13:39 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
type Props = {
|
2019-01-24 11:24:10 -08:00
|
|
|
...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
|
|
|
};
|