From 016e357ebd9f51c6521ab036830e467d53573e20 Mon Sep 17 00:00:00 2001 From: keyan Date: Thu, 25 Aug 2022 13:46:07 -0500 Subject: [PATCH] clear inputs --- components/discussion-form.js | 1 + components/form.js | 21 ++++++++++++++++++--- components/form.module.css | 13 +++++++++++++ components/job-form.js | 6 +++++- components/link-form.js | 2 ++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/components/discussion-form.js b/components/discussion-form.js index 677fa585..f7d4f8e9 100644 --- a/components/discussion-form.js +++ b/components/discussion-form.js @@ -65,6 +65,7 @@ export function DiscussionForm ({ name='title' required autoFocus + clear /> @@ -179,11 +182,23 @@ function InputInner ({ onChange(formik, e) } }} - isInvalid={meta.touched && meta.error} + isInvalid={invalid} isValid={showValid && meta.initialValue !== meta.value && meta.touched && !meta.error} /> - {append && ( + {(append || (clear && field.value)) && ( + {(clear && field.value) && + } {append} )} diff --git a/components/form.module.css b/components/form.module.css index 95a321ef..ac2eff99 100644 --- a/components/form.module.css +++ b/components/form.module.css @@ -10,3 +10,16 @@ margin-top: -1px; height: auto; } + +.clearButton { + background-color: var(--theme-inputBg); + border: 1px solid var(--theme-borderColor); + padding: 0rem 0.5rem; + border-left: 0; + display: flex; + align-items: center; +} + +.clearButton.isInvalid { + border-color: #c03221; +} \ No newline at end of file diff --git a/components/job-form.js b/components/job-form.js index 122c2d35..12c2d99a 100644 --- a/components/job-form.js +++ b/components/job-form.js @@ -71,7 +71,7 @@ export default function JobForm ({ item, sub }) { text: Yup.string().required('required').trim(), url: Yup.string() .or([Yup.string().email(), Yup.string().url()], 'invalid url or email') - .required('Required'), + .required('required'), maxBid: Yup.number('must be number') .integer('must be whole').min(sub.baseCost, `must be at least ${sub.baseCost}`) .required('required'), @@ -153,17 +153,20 @@ export default function JobForm ({ item, sub }) { name='title' required autoFocus + clear /> how to apply url or email address} name='url' required + clear /> : null}