From d9685250b6fe9f7c6924094949a7eb140d0d2d16 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 15 Feb 2023 23:05:01 -0500 Subject: [PATCH] fix(striker-ui): revise inner and expandable panel types --- .../components/Panels/ExpandablePanel.tsx | 30 +++----------- striker-ui/components/Panels/InnerPanel.tsx | 40 +++++++++---------- striker-ui/types/ExpandablePanel.d.ts | 10 +++++ striker-ui/types/InnerPanel.d.ts | 1 + 4 files changed, 36 insertions(+), 45 deletions(-) create mode 100644 striker-ui/types/ExpandablePanel.d.ts create mode 100644 striker-ui/types/InnerPanel.d.ts diff --git a/striker-ui/components/Panels/ExpandablePanel.tsx b/striker-ui/components/Panels/ExpandablePanel.tsx index d64e6f97..e2ab8081 100644 --- a/striker-ui/components/Panels/ExpandablePanel.tsx +++ b/striker-ui/components/Panels/ExpandablePanel.tsx @@ -3,7 +3,7 @@ import { ExpandMore as ExpandMoreIcon, } from '@mui/icons-material'; import { Box, IconButton } from '@mui/material'; -import { FC, ReactNode, useMemo, useState } from 'react'; +import { FC, useMemo, useState } from 'react'; import { GREY } from '../../lib/consts/DEFAULT_THEME'; @@ -14,31 +14,15 @@ import InnerPanelHeader from './InnerPanelHeader'; import Spinner from '../Spinner'; import { BodyText } from '../Text'; -type ExpandablePanelOptionalProps = { - expandInitially?: boolean; - loading?: boolean; - showHeaderSpinner?: boolean; -}; - -type ExpandablePanelProps = ExpandablePanelOptionalProps & { - header: ReactNode; -}; - -const EXPANDABLE_PANEL_DEFAULT_PROPS: Required = { - expandInitially: false, - loading: false, - showHeaderSpinner: false, -}; const HEADER_SPINNER_LENGTH = '1.2em'; const ExpandablePanel: FC = ({ children, - expandInitially: - isExpandInitially = EXPANDABLE_PANEL_DEFAULT_PROPS.expandInitially, + expandInitially: isExpandInitially = false, header, - loading: isLoading = EXPANDABLE_PANEL_DEFAULT_PROPS.loading, - showHeaderSpinner: - isShowHeaderSpinner = EXPANDABLE_PANEL_DEFAULT_PROPS.showHeaderSpinner, + loading: isLoading = false, + panelProps, + showHeaderSpinner: isShowHeaderSpinner = false, }) => { const [isExpand, setIsExpand] = useState(isExpandInitially); @@ -76,7 +60,7 @@ const ExpandablePanel: FC = ({ ); return ( - + {headerElement} @@ -96,6 +80,4 @@ const ExpandablePanel: FC = ({ ); }; -ExpandablePanel.defaultProps = EXPANDABLE_PANEL_DEFAULT_PROPS; - export default ExpandablePanel; diff --git a/striker-ui/components/Panels/InnerPanel.tsx b/striker-ui/components/Panels/InnerPanel.tsx index 32896fef..65239514 100644 --- a/striker-ui/components/Panels/InnerPanel.tsx +++ b/striker-ui/components/Panels/InnerPanel.tsx @@ -1,28 +1,26 @@ -import { FC } from 'react'; -import { Box as MUIBox, BoxProps as MUIBoxProps } from '@mui/material'; +import { FC, useMemo } from 'react'; +import { Box as MUIBox, SxProps, Theme } from '@mui/material'; import { BORDER_RADIUS, DIVIDER } from '../../lib/consts/DEFAULT_THEME'; -type InnerPanelProps = MUIBoxProps; +const InnerPanel: FC = ({ sx, ...muiBoxRestProps }) => { + const combinedSx = useMemo>( + () => ({ + borderWidth: '1px', + borderRadius: BORDER_RADIUS, + borderStyle: 'solid', + borderColor: DIVIDER, + marginTop: '1.4em', + marginBottom: '1.4em', + paddingBottom: 0, + position: 'relative', -const InnerPanel: FC = ({ sx, ...muiBoxRestProps }) => ( - -); + return ; +}; export default InnerPanel; diff --git a/striker-ui/types/ExpandablePanel.d.ts b/striker-ui/types/ExpandablePanel.d.ts new file mode 100644 index 00000000..5bbc2d79 --- /dev/null +++ b/striker-ui/types/ExpandablePanel.d.ts @@ -0,0 +1,10 @@ +type ExpandablePanelOptionalProps = { + expandInitially?: boolean; + loading?: boolean; + panelProps?: InnerPanelProps; + showHeaderSpinner?: boolean; +}; + +type ExpandablePanelProps = ExpandablePanelOptionalProps & { + header: import('react').ReactNode; +}; diff --git a/striker-ui/types/InnerPanel.d.ts b/striker-ui/types/InnerPanel.d.ts new file mode 100644 index 00000000..0f0b3adb --- /dev/null +++ b/striker-ui/types/InnerPanel.d.ts @@ -0,0 +1 @@ +type InnerPanelProps = import('@mui/material').BoxProps;