1
- import { ListItemProps , styled } from '@mui/material' ;
2
1
import { Resizable } from 're-resizable' ;
3
2
import React from 'react' ;
4
3
import Draggable from 'react-draggable' ;
5
- import { Box , BoxProps , IconButton , ListItem , Tooltip } from '../../base' ;
4
+ import { Box , BoxProps , IconButton , Tooltip } from '../../base' ;
6
5
import { CloseIcon , CollapseAllIcon , ExpandAllIcon } from '../../icons' ;
7
6
import { PanelDragHandleIcon } from '../../icons/PanelDragHandle' ;
8
7
import { useTheme } from '../../theme' ;
9
8
import { 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' ;
58
10
59
11
type PanelProps = {
60
12
isOpen : boolean ;
@@ -72,60 +24,6 @@ type PanelProps = {
72
24
} ;
73
25
} ;
74
26
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
-
129
27
const Panel_ : React . FC < PanelProps > = ( {
130
28
isOpen,
131
29
id = 'panel' ,
@@ -137,10 +35,8 @@ const Panel_: React.FC<PanelProps> = ({
137
35
sx
138
36
} ) => {
139
37
const theme = useTheme ( ) ;
140
- // const mode = theme?.palette?.type;
141
38
if ( ! isOpen ) return null ;
142
39
return (
143
- // <SistentThemeProviderWithoutBaseLine initialMode={mode}>
144
40
< Draggable handle = ".drag-handle" >
145
41
< Box
146
42
sx = { {
@@ -191,7 +87,6 @@ const Panel_: React.FC<PanelProps> = ({
191
87
) }
192
88
</ Box >
193
89
< PanelDragHandleIcon
194
- fill = { theme . palette . icon . default }
195
90
style = { { marginTop : '-3rem' , position : 'absolute' , left : '50%' } }
196
91
/>
197
92
< div
@@ -212,26 +107,20 @@ const Panel_: React.FC<PanelProps> = ({
212
107
} }
213
108
> </ div >
214
109
< IconButton onClick = { handleClose } >
215
- < CloseIcon fill = { theme . palette . icon . default } />
110
+ < CloseIcon />
216
111
</ IconButton >
217
112
</ div >
218
113
</ DrawerHeader >
219
114
</ div >
220
-
221
115
< PanelBody className = "panel-body" > { children } </ PanelBody >
222
116
</ ErrorBoundary >
223
117
</ ResizableContent >
224
118
</ Resizable >
225
119
</ Box >
226
120
</ Draggable >
227
- // </SistentThemeProviderWithoutBaseLine>
228
121
) ;
229
122
} ;
230
123
231
124
export const Panel : React . FC < PanelProps > = ( { ...props } ) => {
232
- return (
233
- // <SistentThemeProviderWithoutBaseLine initialMode={mode}>
234
- < Panel_ { ...props } />
235
- // </SistentThemeProviderWithoutBaseLine>
236
- ) ;
125
+ return < Panel_ { ...props } /> ;
237
126
} ;
0 commit comments