UNPKG

1.36 kBTypeScriptView Raw
1import * as React from 'react';
2import * as PropTypes from 'prop-types';
3import { BoxProps as ReakitBoxProps } from 'reakit/ts';
4
5import { Breakpoint, breakpointPropType } from '../types';
6import _Container from './styled';
7
8export type LocalContainerProps = {
9 align?: 'left' | 'right' | 'center';
10 breakpoint?: Breakpoint;
11 children: React.ReactNode;
12 className?: string;
13 isFluid?: boolean;
14 isLayout?: boolean;
15};
16export type ContainerProps = LocalContainerProps & ReakitBoxProps;
17
18export const Container: React.FunctionComponent<LocalContainerProps> = ({ align, children, className, ...props }) => (
19 <_Container className={className} align={align} {...props}>
20 {children}
21 </_Container>
22);
23
24export const containerPropTypes = {
25 align: PropTypes.oneOf(['left', 'right', 'center']) as PropTypes.Validator<LocalContainerProps['align']>,
26 breakpoint: breakpointPropType,
27 children: PropTypes.node.isRequired,
28 className: PropTypes.string,
29 isFluid: PropTypes.bool,
30 isLayout: PropTypes.bool
31};
32Container.propTypes = containerPropTypes;
33
34export const containerDefaultProps: Partial<LocalContainerProps> = {
35 align: 'center',
36 breakpoint: undefined,
37 className: undefined,
38 isFluid: false,
39 isLayout: false
40};
41Container.defaultProps = containerDefaultProps;
42
43const C: React.FunctionComponent<ContainerProps> = Container;
44export default C;