From fb2ca29229b1944c960b9f62757c59308bbe83ed Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Fri, 30 Aug 2019 12:50:33 -0400 Subject: [PATCH] display error via tooltip --- src/components/base/TextField.jsx | 38 +++++++++++++++++++++++++ src/components/projects/FundProject.jsx | 17 ++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/components/base/TextField.jsx b/src/components/base/TextField.jsx index ad17023..e6861ac 100644 --- a/src/components/base/TextField.jsx +++ b/src/components/base/TextField.jsx @@ -73,7 +73,43 @@ const useStyles = makeStyles((theme) => ({ [theme.breakpoints.up('sm')]: { marginLeft: '1.3rem' } + }, + toolTip: { + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + gridColumn: '3 / 11', + backgroundColor: '#FFFFFF', + color: '#FF2D55', + textAlign: 'center', + borderRadius: '8px', + padding: '5px 0', + zIndex: 1, + boxShadow: '0px 4px 12px rgba(0, 34, 51, 0.08), 0px 2px 4px rgba(0, 34, 51, 0.16)', + minHeight: '3rem', + minWidth: '9rem', + '&:after': { + content: 'close-quote', + position: 'absolute', + top: '43%', + left: '50%', + marginLeft: '-5px', + borderWidth: '10px', + borderStyle: 'solid', + borderColor: '#FFFFFF transparent transparent transparent' + } + }, + toolTipNoArrow: { + gridColumn: '5 / 10', + backgroundColor: '#FFFFFF', + color: '#FF2D55', + textAlign: 'center', + borderRadius: '8px', + padding: '5px 0', + zIndex: 1, + boxShadow: '0px 4px 12px rgba(0, 34, 51, 0.08), 0px 2px 4px rgba(0, 34, 51, 0.16)' } + })) const renderLabel = (formLabelClass, idFor, label, isRequired) => ( @@ -100,6 +136,7 @@ function Input({ bottomRightError, bottomLeftLabel, disabled, + errorText, placeholder, className, name, @@ -122,6 +159,7 @@ function Input({ > { labelForm } { topRightLabel } + {!!errorText && {errorText}} { + return schema.validate(values) + .catch(function(err) { + let errors = {} + const { errors: errs, params: { path } } = err + errors[path] = errs[0] + throw errors + }) + }} onSubmit={async (values, { resetForm }) => { const activeStep = stepperProgress(values, projectData, submissionState) if (!activeStep) return enableEthereum() @@ -216,7 +231,7 @@ const SubmissionSection = ({ classes, projectData, projectId, profileData, start bottomRightLabel={usdValue} onChange={handleChange} onBlur={handleBlur} - errorBorder={touched.amount && errors.amount} + errorText={touched.amount && errors.amount} disabled={activeStep >= IS_SUBMITTED} value={values.amount || ''} />