1import React from 'react';
2import cn from 'classnames';
3import { useField } from 'react-final-form';
5import Flex from './Flex';
6import { ErrorText } from './Typography';
8export default function Input({
37 } = useField(name, config);
39 disabled = disabled || submitting;
41 // notify parent of enter keypress iff not disabled and passing
42 // TODO: integrate this into react-final-form submission
43 // const onKeyPress = useCallback(
44 // e => !disabled && valid && e.key === 'Enter' && onEnter && onEnter(),
45 // [disabled, valid] // eslint-disable-line react-hooks/exhaustive-deps
51 className={cn(className, 'mb1')}
54 pointerEvents: 'none',
55 cursor: 'not-allowed',
60 className={cn('f6 lh-tall', {
67 <Flex.Item as={Flex} row className="rel">
70 as={type === 'textarea' ? 'textarea' : 'input'}
72 // NOTE: 24px = 12px * 2 (from p3 styling)
73 style={type === 'textarea' ? { minHeight: 'calc(1rem + 24px)' } : {}}
75 'b b1 p3 outline-none',
78 'bg-white': !disabled,
82 gray4: !(active || touched),
83 black: active || touched,
87 'b-black': !valid && active,
88 'b-yellow3': !valid && !active && touched,
89 'b-gray2': !valid && !active && !touched,
95 type={type === 'textarea' ? undefined : type}
113 <Flex.Item as={ErrorText} className="mv1">
118 {touched && !active && error && (
119 <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