Skip to content

Commit

Permalink
Merge pull request #906 from Vidit-Kushwaha/fix/panel
Browse files Browse the repository at this point in the history
fix: styling in panel component
  • Loading branch information
amitamrutiya authored Feb 4, 2025
2 parents 0fd31c7 + 989bc33 commit d579e08
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 21 deletions.
41 changes: 27 additions & 14 deletions src/custom/Panel/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { Resizable } from 're-resizable';
import React from 'react';
import Draggable from 'react-draggable';
import { Box, BoxProps, IconButton, Tooltip } from '../../base';
import { CloseIcon, CollapseAllIcon, ExpandAllIcon } from '../../icons';
import { PanelDragHandleIcon } from '../../icons/PanelDragHandle';
import { useTheme } from '../../theme';
import { Box, BoxProps, Tooltip } from '../../base';
import { CloseIcon, CollapseAllIcon, ExpandAllIcon, FullScreenIcon } from '../../icons';
import { SistentThemeProviderWithoutBaseLine, useTheme } from '../../theme';
import { ErrorBoundary } from '../ErrorBoundary';
import {
CustomIconButton,
DragHandle,
DrawerHeader,
HeaderActionsContainer,
HeaderContainer,
PanelBody,
PanelContainer,
PanelTitle,
ResizableContent
} from './style';

Expand All @@ -30,6 +31,8 @@ export type PanelProps = {
top?: string | number;
bottom?: string | number;
};
minimizePanel?: () => void;
title?: string;
};

const Panel_: React.FC<PanelProps> = ({
Expand All @@ -40,7 +43,9 @@ const Panel_: React.FC<PanelProps> = ({
toggleExpandAll,
handleClose,
intitialPosition,
sx
sx,
minimizePanel,
title = 'Debug Panel'
}) => {
const theme = useTheme();
if (!isOpen) return null;
Expand Down Expand Up @@ -70,22 +75,26 @@ const Panel_: React.FC<PanelProps> = ({
<Box display="flex" justifyContent="flex-end" padding="8px">
{toggleExpandAll && (
<Tooltip title={areAllExpanded ? 'Collapse All' : 'Expand All'}>
<IconButton onClick={toggleExpandAll}>
<CustomIconButton onClick={toggleExpandAll}>
{areAllExpanded ? <CollapseAllIcon /> : <ExpandAllIcon />}
</IconButton>
</CustomIconButton>
</Tooltip>
)}
</Box>
<DragHandle>
<PanelDragHandleIcon />
</DragHandle>
<DragHandle />
<HeaderContainer>
<HeaderActionsContainer
id={`${id}-panel-header-actions-container`}
></HeaderActionsContainer>
<IconButton onClick={handleClose}>
<CloseIcon />
</IconButton>
<PanelTitle>{title}</PanelTitle>
{minimizePanel && (
<CustomIconButton onClick={minimizePanel}>
<FullScreenIcon fill={theme.palette.common.white} />
</CustomIconButton>
)}
<CustomIconButton onClick={handleClose}>
<CloseIcon fill={theme.palette.common.white} />
</CustomIconButton>
</HeaderContainer>
</DrawerHeader>
</div>
Expand All @@ -99,5 +108,9 @@ const Panel_: React.FC<PanelProps> = ({
};

export const Panel: React.FC<PanelProps> = ({ ...props }) => {
return <Panel_ {...props} />;
return (
<SistentThemeProviderWithoutBaseLine>
<Panel_ {...props} />;
</SistentThemeProviderWithoutBaseLine>
);
};
28 changes: 21 additions & 7 deletions src/custom/Panel/style.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ListItemProps } from '@mui/material';
import { Box, ListItem } from '../../base';
import { styled } from '../../theme';
import { Box, IconButton, ListItem } from '../../base';
import { PanelDragHandleIcon } from '../../icons/PanelDragHandle';
import { accentGrey, black, styled } from '../../theme';
import { PanelProps } from './Panel';

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

export const PanelBody = styled(Box)(({ theme }) => ({
padding: theme.spacing(2),
backgroundColor: theme.palette.background.surfaces,
backgroundColor: accentGrey[10],
overflow: 'auto',
flex: 1,
minHeight: 0
Expand All @@ -88,19 +89,20 @@ export const PanelContainer = styled(Box)<{ intitialPosition: PanelProps['intiti
zIndex: 99999,
position: 'absolute',
backgroundColor: theme.palette.background.blur?.light,
boxShadow: '0 4px 16px #05003812',
boxShadow: `0 4px 16px ${black}`,
maxHeight: '80%',
display: 'flex',
boxSizing: 'border-box',
...intitialPosition
})
);

export const DragHandle = styled('div')({
export const DragHandle = styled(PanelDragHandleIcon)(({ theme }) => ({
fill: theme.palette.common.white,
position: 'absolute',
top: '-3rem',
top: '-0.3rem',
left: '50%'
});
}));

export const HeaderActionsContainer = styled('div')({
display: 'flex',
Expand All @@ -115,3 +117,15 @@ export const HeaderContainer = styled('div')({
alignItems: 'center',
flex: '1'
});

export const CustomIconButton = styled(IconButton)(({ theme }) => ({
color: theme.palette.common.white
}));

export const PanelTitle = styled('div')(() => ({
position: 'absolute',
left: '0',
right: '0',
marginInline: 'auto',
width: 'fit-content'
}));

0 comments on commit d579e08

Please sign in to comment.