From 323d1621725aba931182e821a97db94bb2cec01c Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 23 Feb 2022 12:36:42 -0500 Subject: [PATCH] fix(striker-ui): isolate styled OutlinedInput --- striker-ui/components/Files/FileInfo.tsx | 35 +++---------------- .../OutlinedInput/OutlinedInput.tsx | 35 +++++++++++++++++++ striker-ui/components/OutlinedInput/index.tsx | 3 ++ 3 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 striker-ui/components/OutlinedInput/OutlinedInput.tsx create mode 100644 striker-ui/components/OutlinedInput/index.tsx diff --git a/striker-ui/components/Files/FileInfo.tsx b/striker-ui/components/Files/FileInfo.tsx index 31ef39a4..c901ba57 100644 --- a/striker-ui/components/Files/FileInfo.tsx +++ b/striker-ui/components/Files/FileInfo.tsx @@ -8,8 +8,6 @@ import { inputLabelClasses, MenuItem, menuItemClasses, - OutlinedInput, - outlinedInputClasses, Select, selectClasses, styled, @@ -27,10 +25,11 @@ import { GREY, RED, TEXT, - UNSELECTED, } from '../../lib/consts/DEFAULT_THEME'; import { UPLOAD_FILE_TYPES_ARRAY } from '../../lib/consts/UPLOAD_FILE_TYPES'; +import OutlinedInput from '../OutlinedInput'; + type FileInfoProps = Pick & Partial> & { isReadonly?: boolean; @@ -53,32 +52,6 @@ const StyledInputLabel = styled(InputLabel)({ }, }); -const StyledOutlinedInput = styled(OutlinedInput)({ - color: GREY, - - [`& .${outlinedInputClasses.notchedOutline}`]: { - borderColor: UNSELECTED, - }, - - '&:hover': { - [`& .${outlinedInputClasses.notchedOutline}`]: { - borderColor: GREY, - }, - }, - - [`&.${outlinedInputClasses.focused}`]: { - color: TEXT, - - [`& .${outlinedInputClasses.notchedOutline}`]: { - borderColor: GREY, - - '& legend': { - paddingRight: '1.2em', - }, - }, - }, -}); - const StyledSelect = styled(Select)({ [`& .${selectClasses.icon}`]: { color: GREY, @@ -134,7 +107,7 @@ const FileInfo = ( {fileNameElementLabel} - } + input={} onChange={({ target: { value } }) => onChange?.call(null, { fileType: value as FileType }) } diff --git a/striker-ui/components/OutlinedInput/OutlinedInput.tsx b/striker-ui/components/OutlinedInput/OutlinedInput.tsx new file mode 100644 index 00000000..85892710 --- /dev/null +++ b/striker-ui/components/OutlinedInput/OutlinedInput.tsx @@ -0,0 +1,35 @@ +import { + OutlinedInput as MUIOutlinedInput, + outlinedInputClasses as muiOutlinedInputClasses, + styled, +} from '@mui/material'; + +import { GREY, TEXT, UNSELECTED } from '../../lib/consts/DEFAULT_THEME'; + +const OutlinedInput = styled(MUIOutlinedInput)({ + color: GREY, + + [`& .${muiOutlinedInputClasses.notchedOutline}`]: { + borderColor: UNSELECTED, + }, + + '&:hover': { + [`& .${muiOutlinedInputClasses.notchedOutline}`]: { + borderColor: GREY, + }, + }, + + [`&.${muiOutlinedInputClasses.focused}`]: { + color: TEXT, + + [`& .${muiOutlinedInputClasses.notchedOutline}`]: { + borderColor: GREY, + + '& legend': { + paddingRight: '1.2em', + }, + }, + }, +}); + +export default OutlinedInput; diff --git a/striker-ui/components/OutlinedInput/index.tsx b/striker-ui/components/OutlinedInput/index.tsx new file mode 100644 index 00000000..181f02f9 --- /dev/null +++ b/striker-ui/components/OutlinedInput/index.tsx @@ -0,0 +1,3 @@ +import OutlinedInput from './OutlinedInput'; + +export default OutlinedInput;