Skip to content

Commit d579e08

Browse files
authored
Merge pull request #906 from Vidit-Kushwaha/fix/panel
fix: styling in panel component
2 parents 0fd31c7 + 989bc33 commit d579e08

File tree

2 files changed

+48
-21
lines changed

2 files changed

+48
-21
lines changed

src/custom/Panel/Panel.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import { Resizable } from 're-resizable';
22
import React from 'react';
33
import Draggable from 'react-draggable';
4-
import { Box, BoxProps, IconButton, Tooltip } from '../../base';
5-
import { CloseIcon, CollapseAllIcon, ExpandAllIcon } from '../../icons';
6-
import { PanelDragHandleIcon } from '../../icons/PanelDragHandle';
7-
import { useTheme } from '../../theme';
4+
import { Box, BoxProps, Tooltip } from '../../base';
5+
import { CloseIcon, CollapseAllIcon, ExpandAllIcon, FullScreenIcon } from '../../icons';
6+
import { SistentThemeProviderWithoutBaseLine, useTheme } from '../../theme';
87
import { ErrorBoundary } from '../ErrorBoundary';
98
import {
9+
CustomIconButton,
1010
DragHandle,
1111
DrawerHeader,
1212
HeaderActionsContainer,
1313
HeaderContainer,
1414
PanelBody,
1515
PanelContainer,
16+
PanelTitle,
1617
ResizableContent
1718
} from './style';
1819

@@ -30,6 +31,8 @@ export type PanelProps = {
3031
top?: string | number;
3132
bottom?: string | number;
3233
};
34+
minimizePanel?: () => void;
35+
title?: string;
3336
};
3437

3538
const Panel_: React.FC<PanelProps> = ({
@@ -40,7 +43,9 @@ const Panel_: React.FC<PanelProps> = ({
4043
toggleExpandAll,
4144
handleClose,
4245
intitialPosition,
43-
sx
46+
sx,
47+
minimizePanel,
48+
title = 'Debug Panel'
4449
}) => {
4550
const theme = useTheme();
4651
if (!isOpen) return null;
@@ -70,22 +75,26 @@ const Panel_: React.FC<PanelProps> = ({
7075
<Box display="flex" justifyContent="flex-end" padding="8px">
7176
{toggleExpandAll && (
7277
<Tooltip title={areAllExpanded ? 'Collapse All' : 'Expand All'}>
73-
<IconButton onClick={toggleExpandAll}>
78+
<CustomIconButton onClick={toggleExpandAll}>
7479
{areAllExpanded ? <CollapseAllIcon /> : <ExpandAllIcon />}
75-
</IconButton>
80+
</CustomIconButton>
7681
</Tooltip>
7782
)}
7883
</Box>
79-
<DragHandle>
80-
<PanelDragHandleIcon />
81-
</DragHandle>
84+
<DragHandle />
8285
<HeaderContainer>
8386
<HeaderActionsContainer
8487
id={`${id}-panel-header-actions-container`}
8588
></HeaderActionsContainer>
86-
<IconButton onClick={handleClose}>
87-
<CloseIcon />
88-
</IconButton>
89+
<PanelTitle>{title}</PanelTitle>
90+
{minimizePanel && (
91+
<CustomIconButton onClick={minimizePanel}>
92+
<FullScreenIcon fill={theme.palette.common.white} />
93+
</CustomIconButton>
94+
)}
95+
<CustomIconButton onClick={handleClose}>
96+
<CloseIcon fill={theme.palette.common.white} />
97+
</CustomIconButton>
8998
</HeaderContainer>
9099
</DrawerHeader>
91100
</div>
@@ -99,5 +108,9 @@ const Panel_: React.FC<PanelProps> = ({
99108
};
100109

101110
export const Panel: React.FC<PanelProps> = ({ ...props }) => {
102-
return <Panel_ {...props} />;
111+
return (
112+
<SistentThemeProviderWithoutBaseLine>
113+
<Panel_ {...props} />;
114+
</SistentThemeProviderWithoutBaseLine>
115+
);
103116
};

src/custom/Panel/style.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ListItemProps } from '@mui/material';
2-
import { Box, ListItem } from '../../base';
3-
import { styled } from '../../theme';
2+
import { Box, IconButton, ListItem } from '../../base';
3+
import { PanelDragHandleIcon } from '../../icons/PanelDragHandle';
4+
import { accentGrey, black, styled } from '../../theme';
45
import { PanelProps } from './Panel';
56

67
export const ListHeader = styled(ListItem)(({ theme }) => ({
@@ -67,7 +68,7 @@ export const DrawerHeader = styled('div')(({ theme }) => ({
6768

6869
export const PanelBody = styled(Box)(({ theme }) => ({
6970
padding: theme.spacing(2),
70-
backgroundColor: theme.palette.background.surfaces,
71+
backgroundColor: accentGrey[10],
7172
overflow: 'auto',
7273
flex: 1,
7374
minHeight: 0
@@ -88,19 +89,20 @@ export const PanelContainer = styled(Box)<{ intitialPosition: PanelProps['intiti
8889
zIndex: 99999,
8990
position: 'absolute',
9091
backgroundColor: theme.palette.background.blur?.light,
91-
boxShadow: '0 4px 16px #05003812',
92+
boxShadow: `0 4px 16px ${black}`,
9293
maxHeight: '80%',
9394
display: 'flex',
9495
boxSizing: 'border-box',
9596
...intitialPosition
9697
})
9798
);
9899

99-
export const DragHandle = styled('div')({
100+
export const DragHandle = styled(PanelDragHandleIcon)(({ theme }) => ({
101+
fill: theme.palette.common.white,
100102
position: 'absolute',
101-
top: '-3rem',
103+
top: '-0.3rem',
102104
left: '50%'
103-
});
105+
}));
104106

105107
export const HeaderActionsContainer = styled('div')({
106108
display: 'flex',
@@ -115,3 +117,15 @@ export const HeaderContainer = styled('div')({
115117
alignItems: 'center',
116118
flex: '1'
117119
});
120+
121+
export const CustomIconButton = styled(IconButton)(({ theme }) => ({
122+
color: theme.palette.common.white
123+
}));
124+
125+
export const PanelTitle = styled('div')(() => ({
126+
position: 'absolute',
127+
left: '0',
128+
right: '0',
129+
marginInline: 'auto',
130+
width: 'fit-content'
131+
}));

0 commit comments

Comments
 (0)