zepio/app/components/row.js

35 lines
811 B
JavaScript
Raw Normal View History

2018-12-10 09:05:59 -08:00
// @flow
import React from 'react';
import styled from 'styled-components';
import type { Node, ElementProps } from 'react';
2018-12-10 09:05:59 -08:00
2019-02-08 21:01:05 -08:00
type FlexProps = PropsWithTheme<{
alignItems: string,
justifyContent: string,
}>;
2018-12-10 09:05:59 -08:00
const Flex = styled.div`
display: flex;
flex-direction: row;
2019-02-08 21:01:05 -08:00
align-items: ${(props: FlexProps) => String(props.alignItems)};
justify-content: ${(props: FlexProps) => String(props.justifyContent)};
2018-12-10 09:05:59 -08:00
`;
type Props = {
...ElementProps<'div'>,
2018-12-10 09:05:59 -08:00
alignItems?: string,
justifyContent?: string,
2018-12-12 13:14:12 -08:00
className?: string,
2018-12-10 09:05:59 -08:00
children: Node,
};
export const RowComponent = ({ children, ...props }: Props) => (
<Flex {...props}>{React.Children.map(children, (ch: Node) => ch)}</Flex>
2018-12-10 09:05:59 -08:00
);
RowComponent.defaultProps = {
alignItems: 'flex-start',
justifyContent: 'flex-start',
2018-12-12 13:14:12 -08:00
className: '',
2018-12-10 09:05:59 -08:00
};