From f5039b9877cda9942ecf226960a1037743e82bc4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 5 May 2022 16:35:30 -0500 Subject: [PATCH] SoapboxConfig: refactor inputs --- app/soapbox/components/ui/input/input.tsx | 6 +-- app/soapbox/features/soapbox_config/index.tsx | 39 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/soapbox/components/ui/input/input.tsx b/app/soapbox/components/ui/input/input.tsx index cab86e10e..75ab74601 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'> { +interface IInput extends Pick, 'maxLength' | 'onChange' | '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. */ @@ -27,11 +27,11 @@ interface IInput extends Pick, 'maxL /** Text to display before a value is entered. */ placeholder?: string, /** Text in the input. */ - value?: string, + value?: string | number, /** Change event handler for the input. */ onChange?: (event: React.ChangeEvent) => void, /** HTML input type. */ - type: 'text' | 'email' | 'tel' | 'password', + type: 'text' | 'number' | 'email' | 'tel' | 'password', } /** Form input element. */ diff --git a/app/soapbox/features/soapbox_config/index.tsx b/app/soapbox/features/soapbox_config/index.tsx index e44e4cbfd..9411212cb 100644 --- a/app/soapbox/features/soapbox_config/index.tsx +++ b/app/soapbox/features/soapbox_config/index.tsx @@ -5,12 +5,10 @@ import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { updateConfig } from 'soapbox/actions/admin'; import { uploadMedia } from 'soapbox/actions/media'; import snackbar from 'soapbox/actions/snackbar'; -import { Column, Form, FormActions, Button } from 'soapbox/components/ui'; +import { Column, Form, FormActions, FormGroup, Input, Button } from 'soapbox/components/ui'; import Streamfield from 'soapbox/components/ui/streamfield/streamfield'; import { FieldsGroup, - TextInput, - SimpleInput, SimpleTextarea, FileChooserLogo, Checkbox, @@ -220,15 +218,16 @@ const SoapboxConfig: React.FC = () => { - - + e.target.value)} /> - + + { onChange={handleChange(['singleUserMode'], (e) => e.target.checked)} /> {soapbox.get('singleUserMode') && ( - e.target.value)} - /> + + e.target.value)} + /> + )} @@ -303,18 +303,17 @@ const SoapboxConfig: React.FC = () => { onRemoveItem={deleteStreamItem(['cryptoAddresses'])} /> - - + Number(e.target.value))} /> - + +