1- import { ListItemProps , styled } from '@mui/material' ;
21import { Resizable } from 're-resizable' ;
32import React from 'react' ;
43import Draggable from 'react-draggable' ;
5- import { Box , BoxProps , IconButton , ListItem , Tooltip } from '../../base' ;
4+ import { Box , BoxProps , IconButton , Tooltip } from '../../base' ;
65import { CloseIcon , CollapseAllIcon , ExpandAllIcon } from '../../icons' ;
76import { PanelDragHandleIcon } from '../../icons/PanelDragHandle' ;
87import { useTheme } from '../../theme' ;
98import { ErrorBoundary } from '../ErrorBoundary' ;
10-
11- export const ListHeader = styled ( ListItem ) ( ( { theme } ) => ( {
12- padding : theme . spacing ( 0.5 , 0.5 ) ,
13- marginBlock : theme . spacing ( 1 ) ,
14- '& .MuiListItemText-primary' : {
15- fontSize : '1rem' ,
16- textTransform : 'capitalize' ,
17- fontWeight : 700
18- } ,
19- cursor : 'pointer' ,
20- '&:hover' : {
21- backgroundColor : theme . palette . action . hover
22- } ,
23- '& .MuiSvgIcon-root' : {
24- opacity : 0 ,
25- transition : 'opacity 0.2s'
26- } ,
27- '&:hover .MuiSvgIcon-root' : {
28- opacity : 1
29- }
30- } ) ) ;
31-
32- interface CustomListItemProps extends ListItemProps {
33- isVisible : boolean ;
34- }
35-
36- // Use the new interface in the styled component
37- export const StyledListItem = styled ( ListItem , {
38- shouldForwardProp : ( props ) => props !== 'isVisible'
39- } ) < CustomListItemProps > ( ( { theme, isVisible } ) => ( {
40- padding : theme . spacing ( 0.05 , 0.5 ) ,
41- fontStyle : isVisible ? 'normal' : 'italic' ,
42- overflow : 'hidden' ,
43- textOverflow : 'ellipsis' ,
44- whiteSpace : 'nowrap' ,
45- '& .MuiSvgIcon-root' : {
46- height : 20 ,
47- width : 20
48- } ,
49- '& .MuiListItemIcon-root' : {
50- minWidth : 0 ,
51- opacity : isVisible ? 0.8 : 0.3
52- } ,
53- '& .MuiTypography-root' : {
54- fontSize : '0.9rem' ,
55- opacity : isVisible ? 1 : 0.5
56- }
57- } ) ) ;
9+ import { DrawerHeader , PanelBody , ResizableContent } from './style' ;
5810
5911type PanelProps = {
6012 isOpen : boolean ;
@@ -72,60 +24,6 @@ type PanelProps = {
7224 } ;
7325} ;
7426
75- export const DrawerHeader = styled ( 'div' ) ( ( { theme } ) => ( {
76- display : 'flex' ,
77- alignItems : 'center' ,
78- padding : theme . spacing ( 4 , 2 ) ,
79- alignContent : 'stretch' ,
80- justifyContent : 'space-between' ,
81- cursor : 'move' ,
82- background :
83- theme . palette . mode === 'light'
84- ? 'linear-gradient(90deg, #3B687B 0%, #507D90 100%)'
85- : 'linear-gradient(90deg, #28353A 0%, #3D4F57 100%)' ,
86- height : '3rem' ,
87- flexShrink : 0
88- } ) ) ;
89-
90- const PanelBody = styled ( Box ) ( ( { theme } ) => ( {
91- padding : theme . spacing ( 2 ) ,
92- backgroundColor : theme . palette . background . surfaces ,
93- overflow : 'auto' ,
94- flex : 1 ,
95- minHeight : 0
96- } ) ) ;
97-
98- // New container for Resizable content
99- const ResizableContent = styled ( 'div' ) ( {
100- height : '100%' ,
101- display : 'flex' ,
102- flexDirection : 'column' ,
103- minHeight : '3rem'
104- } ) ;
105-
106- // // watches for the size of the element
107- // const useDimensions = (ref: React.RefObject<HTMLDivElement>) => {
108- // const [dimensions, setDimensions] = React.useState({ width: 0, height: 0 });
109- // React.useEffect(() => {
110- // const { current } = ref;
111- // if (current) {
112- // const resizeObserver = new ResizeObserver((entries) => {
113- // entries.forEach((entry) => {
114- // setDimensions({
115- // width: entry.contentRect.width,
116- // height: entry.contentRect.height
117- // });
118- // });
119- // });
120- // resizeObserver.observe(current);
121- // return () => {
122- // resizeObserver.unobserve(current);
123- // };
124- // }
125- // }, [ref]);
126- // return dimensions;
127- // };
128-
12927const Panel_ : React . FC < PanelProps > = ( {
13028 isOpen,
13129 id = 'panel' ,
@@ -137,10 +35,8 @@ const Panel_: React.FC<PanelProps> = ({
13735 sx
13836} ) => {
13937 const theme = useTheme ( ) ;
140- // const mode = theme?.palette?.type;
14138 if ( ! isOpen ) return null ;
14239 return (
143- // <SistentThemeProviderWithoutBaseLine initialMode={mode}>
14440 < Draggable handle = ".drag-handle" >
14541 < Box
14642 sx = { {
@@ -191,7 +87,6 @@ const Panel_: React.FC<PanelProps> = ({
19187 ) }
19288 </ Box >
19389 < PanelDragHandleIcon
194- fill = { theme . palette . icon . default }
19590 style = { { marginTop : '-3rem' , position : 'absolute' , left : '50%' } }
19691 />
19792 < div
@@ -212,26 +107,20 @@ const Panel_: React.FC<PanelProps> = ({
212107 } }
213108 > </ div >
214109 < IconButton onClick = { handleClose } >
215- < CloseIcon fill = { theme . palette . icon . default } />
110+ < CloseIcon />
216111 </ IconButton >
217112 </ div >
218113 </ DrawerHeader >
219114 </ div >
220-
221115 < PanelBody className = "panel-body" > { children } </ PanelBody >
222116 </ ErrorBoundary >
223117 </ ResizableContent >
224118 </ Resizable >
225119 </ Box >
226120 </ Draggable >
227- // </SistentThemeProviderWithoutBaseLine>
228121 ) ;
229122} ;
230123
231124export const Panel : React . FC < PanelProps > = ( { ...props } ) => {
232- return (
233- // <SistentThemeProviderWithoutBaseLine initialMode={mode}>
234- < Panel_ { ...props } />
235- // </SistentThemeProviderWithoutBaseLine>
236- ) ;
125+ return < Panel_ { ...props } /> ;
237126} ;
0 commit comments