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({
29 meta: { active, error, submitting, submitSucceeded, touched, valid },
30 } = useField(name, config);
32 disabled = disabled || submitting || submitSucceeded;
34 // choose the base dom component
35 const BaseComponent = type === 'textarea' ? 'textarea' : 'input';
37 // notify parent of enter keypress iff not disabled and passing
38 // TODO: integrate this into react-final-form submission
39 // const onKeyPress = useCallback(
40 // e => !disabled && valid && e.key === 'Enter' && onEnter && onEnter(),
41 // [disabled, valid] // eslint-disable-line react-hooks/exhaustive-deps
44 // console.log(input);
49 className={cn(className, 'mb1')}
52 pointerEvents: 'none',
53 cursor: 'not-allowed',
58 className={cn('f6 lh-tall', {
65 <Flex.Item as={Flex} row className="rel">
70 // NOTE: 24px = 12px * 2 (from p3 styling)
71 style={type === 'textarea' ? { minHeight: 'calc(1rem + 24px)' } : {}}
73 'b b1 p3 outline-none',
76 'bg-white': !disabled,
80 gray4: !(active || touched),
81 black: active || touched,
85 'b-black': !valid && active,
86 'b-yellow3': !valid && !active && touched,
87 'b-gray2': !valid && !active && !touched,
93 type={type === 'textarea' ? undefined : type}
110 {touched && !active && error && (
111 <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