feat: keep text black after has been touched
commitdf16638e27a1eab3fe4975a0ba8f8a3424f073ae
authorMatt Condon (shrugs) <mattgcondon@gmail.com>
dateTue 23 Jul 2019, 14:24 (7 years ago)
parentfdc3dab
src/indigo-react/components/CheckboxInput.js+1
@@ -23,6 +23,7 @@ export default function CheckboxInput({
2323 bind,
2424 autoFocus,
2525 disabled,
26+ touched,
2627
2728 // ignored
2829 initialValue,
src/indigo-react/components/Input.js+3−2
@@ -27,6 +27,7 @@ export default React.memo(function Input({
2727 bind,
2828 autoFocus,
2929 disabled,
30+ touched,
3031
3132 // ignored
3233 initialValue,
@@ -82,8 +83,8 @@ export default React.memo(function Input({
8283 'bg-gray1': disabled,
8384 },
8485 {
85− gray4: !focused,
86− black: focused,
86+ gray4: !focused && !touched,
87+ black: focused || touched,
8788 },
8889 {
8990 'b-green3': visiblyPassed,
src/indigo-react/components/SelectInput.js+1
@@ -31,6 +31,7 @@ export default function SelectInput({
3131 autoFocus,
3232 disabled,
3333 options,
34+ touched,
3435
3536 // ignored
3637 initialValue,
src/indigo-react/components/ToggleInput.js+1
@@ -25,6 +25,7 @@ export default function ToggleInput({
2525 bind,
2626 autoFocus,
2727 disabled,
28+ touched,
2829
2930 // ignored
3031 initialValue,
src/indigo-react/lib/useForm.js+2
@@ -217,6 +217,7 @@ export default function useForm(inputConfigs = []) {
217217 error: errors[i],
218218 hintError: hintErrors[i],
219219 focused: focuses[i],
220+ touched: hasBeenTouched[name],
220221 autoFocus: autoFocus && !disabled,
221222 disabled,
222223 ...rest,
@@ -241,6 +242,7 @@ export default function useForm(inputConfigs = []) {
241242 errors,
242243 hintErrors,
243244 focuses,
245+ hasBeenTouched,
244246 onChange,
245247 onFocus,
246248 onBlur,