Skip to content

Commit ffa3213

Browse files
authored
Merge pull request #910 from Vidit-Kushwaha/fix/panel
feat: added default size to Panel and remove default title
2 parents c534644 + 314860e commit ffa3213

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/custom/Panel/Panel.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import Draggable from 'react-draggable';
44
import { Box, BoxProps, Tooltip } from '../../base';
55
import { CloseIcon, CollapseAllIcon, ExpandAllIcon, FullScreenIcon } from '../../icons';
6-
import { SistentThemeProviderWithoutBaseLine, useTheme } from '../../theme';
6+
import { useTheme } from '../../theme';
77
import { ErrorBoundary } from '../ErrorBoundary';
88
import {
99
CustomIconButton,
@@ -31,6 +31,10 @@ export type PanelProps = {
3131
top?: string | number;
3232
bottom?: string | number;
3333
};
34+
defaultSize?: {
35+
width?: string | number;
36+
height?: string | number;
37+
};
3438
minimizePanel?: () => void;
3539
title?: string;
3640
};
@@ -42,18 +46,22 @@ const Panel_: React.FC<PanelProps> = ({
4246
areAllExpanded,
4347
toggleExpandAll,
4448
handleClose,
49+
defaultSize,
4550
intitialPosition,
4651
sx,
4752
minimizePanel,
48-
title = 'Debug Panel'
53+
title = ''
4954
}) => {
5055
const theme = useTheme();
5156
if (!isOpen) return null;
5257
return (
5358
<Draggable handle=".drag-handle">
5459
<PanelContainer theme={theme} intitialPosition={intitialPosition} sx={sx}>
5560
<Resizable
56-
defaultSize={{ width: '18rem', height: 'auto' }}
61+
defaultSize={{
62+
width: defaultSize?.width || '18rem',
63+
height: defaultSize?.height || 'auto'
64+
}}
5765
onResize={() => {
5866
window.dispatchEvent(new Event('panel-resize'));
5967
}}
@@ -98,7 +106,9 @@ const Panel_: React.FC<PanelProps> = ({
98106
</HeaderContainer>
99107
</DrawerHeader>
100108
</div>
101-
<PanelBody className="panel-body">{children}</PanelBody>
109+
<PanelBody className="panel-body" theme={theme}>
110+
{children}
111+
</PanelBody>
102112
</ErrorBoundary>
103113
</ResizableContent>
104114
</Resizable>
@@ -108,9 +118,5 @@ const Panel_: React.FC<PanelProps> = ({
108118
};
109119

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

src/custom/Panel/style.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const DrawerHeader = styled('div')(({ theme }) => ({
6868

6969
export const PanelBody = styled(Box)(({ theme }) => ({
7070
padding: theme.spacing(2),
71-
backgroundColor: accentGrey[10],
71+
backgroundColor: theme.palette.mode === 'light' ? accentGrey[10] : accentGrey[100],
7272
overflow: 'auto',
7373
flex: 1,
7474
minHeight: 0

0 commit comments

Comments
 (0)