From 165ddc91bdb6c089098480ad458e63e363bac1bb Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 6 May 2022 17:13:00 -0500 Subject: [PATCH] RegistrationForm: use ui form inputs --- app/soapbox/components/ui/input/input.tsx | 4 +- .../components/registration_form.tsx | 88 ++++++++++--------- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/app/soapbox/components/ui/input/input.tsx b/app/soapbox/components/ui/input/input.tsx index 75ab74601..20c7804ae 100644 --- a/app/soapbox/components/ui/input/input.tsx +++ b/app/soapbox/components/ui/input/input.tsx @@ -11,7 +11,7 @@ const messages = defineMessages({ hidePassword: { id: 'input.password.hide_password', defaultMessage: 'Hide password' }, }); -interface IInput extends Pick, 'maxLength' | 'onChange' | 'type' | 'autoComplete' | 'autoCorrect' | 'autoCapitalize' | 'required' | 'disabled' | 'onClick' | 'readOnly' | 'min' | 'pattern'> { +interface IInput extends Pick, 'maxLength' | 'onChange' | 'onBlur' | 'type' | 'autoComplete' | 'autoCorrect' | 'autoCapitalize' | 'required' | 'disabled' | 'onClick' | 'readOnly' | 'min' | 'pattern'> { /** Put the cursor into the input on mount. */ autoFocus?: boolean, /** The initial text in the input. */ @@ -32,6 +32,8 @@ interface IInput extends Pick, 'maxL onChange?: (event: React.ChangeEvent) => void, /** HTML input type. */ type: 'text' | 'number' | 'email' | 'tel' | 'password', + /** Whether to display the input in red. */ + hasError?: boolean, } /** Form input element. */ diff --git a/app/soapbox/features/auth_login/components/registration_form.tsx b/app/soapbox/features/auth_login/components/registration_form.tsx index ccbd64c04..65c3c3e6d 100644 --- a/app/soapbox/features/auth_login/components/registration_form.tsx +++ b/app/soapbox/features/auth_login/components/registration_form.tsx @@ -10,15 +10,9 @@ import { accountLookup } from 'soapbox/actions/accounts'; import { register, verifyCredentials } from 'soapbox/actions/auth'; import { openModal } from 'soapbox/actions/modals'; import BirthdayInput from 'soapbox/components/birthday_input'; -import ShowablePassword from 'soapbox/components/showable_password'; +import { Form, FormGroup, Input, Textarea } from 'soapbox/components/ui'; import CaptchaField from 'soapbox/features/auth_login/components/captcha'; -import { - SimpleForm, - SimpleInput, - TextInput, - SimpleTextarea, - Checkbox, -} from 'soapbox/features/forms'; +import { Checkbox } from 'soapbox/features/forms'; import { useAppSelector, useAppDispatch, useSettings, useFeatures } from 'soapbox/hooks'; const messages = defineMessages({ @@ -232,8 +226,8 @@ const RegistrationForm: React.FC = ({ inviteToken }) => { const isLoading = captchaLoading || submissionLoading; return ( - -
+
+
{usernameUnavailable && ( @@ -241,23 +235,25 @@ const RegistrationForm: React.FC = ({ inviteToken }) => {
)} - - + + + = ({ inviteToken }) => {
)} - - {birthdayRequired && @@ -299,16 +297,20 @@ const RegistrationForm: React.FC = ({ inviteToken }) => { onChange={onBirthdayChange} required />} - {instance.get('approval_required') && - } - hint={} - name='reason' - maxLength={500} - onChange={onInputChange} - value={params.get('reason', '')} - required - />} + {needsApproval && ( + } + hintText={} + > +