From 874ae980e6cb6af2d1e65e74ceef8854fb660f8b Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 5 May 2022 17:45:32 -0500 Subject: [PATCH] SoapboxConfig: refactor Textarea --- .../components/ui/form-group/form-group.tsx | 22 ++++++++++--------- .../components/ui/textarea/textarea.tsx | 7 ++++-- app/soapbox/features/soapbox_config/index.tsx | 12 +++++----- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/soapbox/components/ui/form-group/form-group.tsx b/app/soapbox/components/ui/form-group/form-group.tsx index e70bc5836..e90448e8c 100644 --- a/app/soapbox/components/ui/form-group/form-group.tsx +++ b/app/soapbox/components/ui/form-group/form-group.tsx @@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid'; interface IFormGroup { /** Input label message. */ - labelText: React.ReactNode, + labelText?: React.ReactNode, /** Input hint message. */ hintText?: React.ReactNode, /** Input errors. */ @@ -26,13 +26,15 @@ const FormGroup: React.FC = (props) => { return (
- + {labelText && ( + + )}
{firstChild} @@ -47,11 +49,11 @@ const FormGroup: React.FC = (props) => {

)} - {hintText ? ( + {hintText && (

{hintText}

- ) : null} + )}
); diff --git a/app/soapbox/components/ui/textarea/textarea.tsx b/app/soapbox/components/ui/textarea/textarea.tsx index fbd8ba86f..b181fc848 100644 --- a/app/soapbox/components/ui/textarea/textarea.tsx +++ b/app/soapbox/components/ui/textarea/textarea.tsx @@ -1,7 +1,7 @@ import classNames from 'classnames'; import React from 'react'; -interface ITextarea extends Pick, 'maxLength' | 'onChange' | 'required' | 'disabled'> { +interface ITextarea extends Pick, 'maxLength' | 'onChange' | 'required' | 'disabled' | 'rows'> { /** Put the cursor into the input on mount. */ autoFocus?: boolean, /** The initial text in the input. */ @@ -16,11 +16,13 @@ interface ITextarea extends Pick) => { + ({ isCodeEditor = false, hasError = false, ...props }: ITextarea, ref: React.ForwardedRef) => { return (