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