aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/ui/input.tsx
blob: d21b9fd0e3d1c53e9ec2ac52100232ffcf72ee13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { colors } from '@0x/react-shared';
import * as React from 'react';
import { styled } from 'ts/style/theme';

export interface InputProps {
    className?: string;
    value?: string;
    width?: string;
    fontSize?: string;
    fontColor?: string;
    border?: string;
    padding?: string;
    placeholderColor?: string;
    placeholder?: string;
    backgroundColor?: string;
    onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
}

const PlainInput: React.StatelessComponent<InputProps> = ({ value, className, placeholder, onChange }) => (
    <input className={className} value={value} onChange={onChange} placeholder={placeholder} />
);

export const Input = styled(PlainInput)`
    font-size: ${props => props.fontSize};
    width: ${props => props.width};
    padding: ${props => props.padding};
    border-radius: 3px;
    box-sizing: border-box;
    font-family: 'Roboto Mono';
    color: ${props => props.fontColor};
    border: ${props => props.border};
    outline: none;
    background-color: ${props => props.backgroundColor};
    &::placeholder {
        color: ${props => props.placeholderColor};
    }
`;

Input.defaultProps = {
    width: 'auto',
    backgroundColor: colors.white,
    fontColor: colors.darkestGrey,
    placeholderColor: colors.darkGrey,
    fontSize: '12px',
    border: 'none',
    padding: '0.8em 1.2em',
};

Input.displayName = 'Input';