Field.tsx 570 字节
Newer Older
1 2 3
import React, {FunctionComponent} from 'react';
import {WithStyled, rem} from '~/utils/style';

4 5
import styled from 'styled-components';

6 7 8 9 10 11 12 13 14 15 16
const Wrapper = styled.div`
    & + & {
        margin-top: ${rem(20)};
    }
`;

const Label = styled.div`
    margin-bottom: ${rem(10)};
`;

type FieldProps = {
P
Peter Pan 已提交
17
    label?: string | JSX.Element;
18 19 20 21 22 23 24 25 26 27
};

const Field: FunctionComponent<FieldProps & WithStyled> = ({label, children, className}) => (
    <Wrapper className={className}>
        {label && <Label>{label}</Label>}
        {children}
    </Wrapper>
);

export default Field;