From eeb77a04d1e4d3c2fef98ec42031b348e7b6e46d Mon Sep 17 00:00:00 2001 From: Aleksandar Toplek Date: Tue, 17 Oct 2023 13:16:51 +0200 Subject: [PATCH] feat: Simplified PageDrawer component to use sitcky instead of absolute positioning --- apps/docs/components/ExamplePageDrawer.tsx | 6 +- packages/react-ui/PageDrawer/PageDrawer.tsx | 127 ++++++++---------- ...use sitcky instead of absolute positioning | 0 3 files changed, 62 insertions(+), 71 deletions(-) create mode 100644 packages/react-ui/changes/Changed Simplified PageDrawer component to use sitcky instead of absolute positioning diff --git a/apps/docs/components/ExamplePageDrawer.tsx b/apps/docs/components/ExamplePageDrawer.tsx index 80e88122..602f7bec 100644 --- a/apps/docs/components/ExamplePageDrawer.tsx +++ b/apps/docs/components/ExamplePageDrawer.tsx @@ -5,8 +5,10 @@ export function ExamplePageDrawer() { const [expanded, setExpanded] = useState(false); return ( -
- Page content +
+
+ {(Array(100).fill(0)).map((_, i) => (
Page content {i}
))} +
{/* // @highlight-start */} & { * @public */ export function PageDrawer({ expanded, onChange, children, color, ...rest }: PageDrawerProps): JSX.Element { - const [drawerSize, setDrawerSize] = useState(0); - const drawerSizeDebounced = useDebounce(drawerSize, 50); - const resizeObserverRef = useResizeObserver((_, entry) => { - setDrawerSize(entry.contentRect.height); - }); - return ( - <> - - + } sx={{ - position: 'absolute', - inset: 'auto 0 0 0', - bgcolor: 'transparent', - backgroundImage: 'none', - border: 'none', + position: 'relative', + minHeight: 32, + height: 32, + '.MuiAccordionSummary-expandIconWrapper': { + bgcolor: color ?? 'primary.dark', + color: 'primary.main', + borderRadius: 1 + }, + '&.Mui-expanded': { + minHeight: 24, + height: 24, + }, '&::before': { - display: 'none' + display: 'block', + content: '""', + position: 'absolute', + top: '40%', + left: 0, + right: 0, + bottom: 0, + bgcolor: 'background.default' } }} - expanded={expanded} - onChange={onChange} - {...rest} > - } + - - - - {children} - - - + /> + + + {children} + + ); }; diff --git a/packages/react-ui/changes/Changed Simplified PageDrawer component to use sitcky instead of absolute positioning b/packages/react-ui/changes/Changed Simplified PageDrawer component to use sitcky instead of absolute positioning new file mode 100644 index 00000000..e69de29b