1import React from 'react';
2import cn from 'classnames';
4import Flex from './Flex';
5import { ErrorText } from './Typography';
6import { useField } from 'react-final-form';
8export default function Input({
29 meta: { active, error, submitting, touched, valid },
30 } = useField(name, config);
32 disabled = disabled || submitting;
34 // notify parent of enter keypress iff not disabled and passing
35 // TODO: integrate this into react-final-form submission
36 // const onKeyPress = useCallback(
37 // e => !disabled && valid && e.key === 'Enter' && onEnter && onEnter(),
38 // [disabled, valid] // eslint-disable-line react-hooks/exhaustive-deps
44 className={cn(className, 'mb1')}
47 pointerEvents: 'none',
48 cursor: 'not-allowed',
53 className={cn('f6 lh-tall', {
60 <Flex.Item as={Flex} row className="rel">
63 as={type === 'textarea' ? 'textarea' : 'input'}
65 // NOTE: 24px = 12px * 2 (from p3 styling)
66 style={type === 'textarea' ? { minHeight: 'calc(1rem + 24px)' } : {}}
68 'b b1 p3 outline-none',
71 'bg-white': !disabled,
75 gray4: !(active || touched),
76 black: active || touched,
80 'b-black': !valid && active,
81 'b-yellow3': !valid && !active && touched && error,
82 'b-gray2': !valid && !active && !touched && !error,
88 type={type === 'textarea' ? undefined : type}
104 {touched && !active && error && (
105 <Flex.Item as={ErrorText} className="mv1">
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