zepio/app/components/column.js

40 lines
919 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';
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;
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 = {
...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
};