1import React from 'react';
2import cn from 'classnames';
3import { useField } from 'react-final-form';
4import Flex from './Flex';
5import { ErrorText } from './Typography';
7export default function Input({
37 } = useField(name, config);
39 disabled = disabled || submitting || submitSucceeded;
41 // choose the base dom component
42 const BaseComponent = type === 'textarea' ? 'textarea' : 'input';
43 const showError = !!error;
44 const showSubmitError = !!submitError && !dirtySinceLastSubmit;
45 const indicateError = touched && !active && (showError || showSubmitError);
50 className={cn(className, 'mb1')}
53 pointerEvents: 'none',
54 cursor: 'not-allowed',
61 className={cn('f6 lh-tall', {
65 <Flex.Item as="label" justify="center" htmlFor={name}>
68 {labelAccessory && <Flex.Item>{labelAccessory}</Flex.Item>}
70 <Flex.Item as={Flex} row className="rel">
75 // NOTE: 1.15 from input line-height, 24px = 12px * 2 (from p3 styling)
76 style={type === 'textarea' ? { minHeight: 'calc(1.5rem * 3)' } : {}}
78 'b b1 p3 outline-none bs-none r4',
81 'bg-white': !disabled,
85 gray4: !(active || touched),
86 black: active || touched,
90 'b-black': !valid && active,
91 'b-yellow3': !valid && !active && touched,
92 'b-gray2': !valid && !active && !touched,
98 type={type === 'textarea' ? undefined : type}
107 width: 'calc(1.5em + 24px)',
116 <Flex.Item as={ErrorText} className="mv1">
117 {error ? error : submitError}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list