From 8c4f62c8620dd1ad7e242fb4c06cf847b515309d Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 5 May 2022 16:59:22 -0400 Subject: [PATCH] fix(striker-ui): apply InputMessageBox to Slider and labeled input --- .../components/OutlinedInputWithLabel.tsx | 59 +++++++------------ striker-ui/components/Slider.tsx | 37 ++++-------- 2 files changed, 34 insertions(+), 62 deletions(-) diff --git a/striker-ui/components/OutlinedInputWithLabel.tsx b/striker-ui/components/OutlinedInputWithLabel.tsx index 5165a947..ed28ef11 100644 --- a/striker-ui/components/OutlinedInputWithLabel.tsx +++ b/striker-ui/components/OutlinedInputWithLabel.tsx @@ -3,7 +3,8 @@ import { FormControlProps as MUIFormControlProps, } from '@mui/material'; -import MessageBox, { MessageBoxProps } from './MessageBox'; +import InputMessageBox from './InputMessageBox'; +import { MessageBoxProps } from './MessageBox'; import OutlinedInput, { OutlinedInputProps } from './OutlinedInput'; import OutlinedInputLabel, { OutlinedInputLabelProps, @@ -37,42 +38,26 @@ const OutlinedInputWithLabel = ({ inputLabelProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.inputLabelProps, label, messageBoxProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.messageBoxProps, -}: OutlinedInputWithLabelProps): JSX.Element => { - const { - sx: messageBoxSx, - text: messageBoxText, - ...messageBoxRestProps - } = messageBoxProps; - - return ( - // eslint-disable-next-line react/jsx-props-no-spreading - - {/* eslint-disable-next-line react/jsx-props-no-spreading */} - - {label} - - - {messageBoxText && ( - - )} - - ); -}; +}: OutlinedInputWithLabelProps): JSX.Element => ( + // eslint-disable-next-line react/jsx-props-no-spreading + + {/* eslint-disable-next-line react/jsx-props-no-spreading */} + + {label} + + + {/* eslint-disable-next-line react/jsx-props-no-spreading */} + + +); OutlinedInputWithLabel.defaultProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS; diff --git a/striker-ui/components/Slider.tsx b/striker-ui/components/Slider.tsx index 523b5bf3..06c7b8e5 100644 --- a/striker-ui/components/Slider.tsx +++ b/striker-ui/components/Slider.tsx @@ -7,15 +7,17 @@ import { Slider as MUISlider, sliderClasses as muiSliderClasses, SliderProps as MUISliderProps, - TypographyProps as MUITypographyProps, FormControl, } from '@mui/material'; import { BORDER_RADIUS, GREY } from '../lib/consts/DEFAULT_THEME'; -import MessageBox, { MessageBoxProps } from './MessageBox'; +import InputMessageBox from './InputMessageBox'; +import { MessageBoxProps } from './MessageBox'; import OutlinedInput from './OutlinedInput'; -import OutlinedInputLabel from './OutlinedInputLabel'; +import OutlinedInputLabel, { + OutlinedInputLabelProps, +} from './OutlinedInputLabel'; import { BodyText } from './Text'; type SliderOnBlur = Exclude; @@ -24,9 +26,9 @@ type SliderOnFocus = Exclude; type SliderValue = Exclude; type SliderOptionalProps = { + inputLabelProps?: Partial; isAllowTextInput?: boolean; labelId?: string; - labelProps?: MUITypographyProps; messageBoxProps?: Partial; sliderProps?: Omit & { onChange?: (value: number | number[]) => void; @@ -41,9 +43,9 @@ type SliderProps = { type TextInputOnChange = Exclude; const SLIDER_DEFAULT_PROPS: Required = { + inputLabelProps: {}, isAllowTextInput: false, labelId: '', - labelProps: {}, messageBoxProps: {}, sliderProps: {}, }; @@ -154,16 +156,10 @@ const Slider = ({ isAllowTextInput = SLIDER_DEFAULT_PROPS.isAllowTextInput, label, labelId = SLIDER_DEFAULT_PROPS.labelId, - labelProps = SLIDER_DEFAULT_PROPS.labelProps, + inputLabelProps = SLIDER_DEFAULT_PROPS.inputLabelProps, sliderProps = SLIDER_DEFAULT_PROPS.sliderProps, value, }: SliderProps): JSX.Element => { - const { - sx: messageBoxSx, - text: messageBoxText, - ...messageBoxRestProps - } = messageBoxProps; - const { sx: labelSx } = labelProps; const { max, min, @@ -195,12 +191,11 @@ const Slider = ({ return ( {label} @@ -254,16 +249,8 @@ const Slider = ({ }, })} - {messageBoxText && ( - - )} + {/* eslint-disable-next-line react/jsx-props-no-spreading */} + ); };