Skip to content

Commit

Permalink
Merge pull request #143 from Enterwell/stage
Browse files Browse the repository at this point in the history
Stage
  • Loading branch information
AleksandarDev authored Oct 17, 2023
2 parents 007b035 + eeb77a0 commit e24d1f2
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 138 deletions.
6 changes: 4 additions & 2 deletions apps/docs/components/ExamplePageDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ export function ExamplePageDrawer() {
const [expanded, setExpanded] = useState(false);

return (
<div className="flex flex-col items-center justify-center relative h-72 overflow-hidden rounded-lg">
<span>Page content</span>
<div className="max-h-72 overflow-y-auto">
<div className='flex flex-col items-center justify-center'>
{(Array(100).fill(0)).map((_, i) => (<div>Page content {i}</div>))}
</div>
{/* // @highlight-start */}
<PageDrawer
expanded={expanded}
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@mdx-js/mdx": "2.3.0",
"@mdx-js/react": "2.3.0",
"@mui/icons-material": "5.14.13",
"@mui/lab": "5.0.0-alpha.148",
"@mui/lab": "5.0.0-alpha.149",
"@mui/material": "5.14.13",
"@mui/system": "5.14.13",
"@mui/x-date-pickers-pro": "5.0.20",
Expand All @@ -36,7 +36,7 @@
"@mui/x-data-grid-pro": "6.16.2",
"classix": "2.1.35",
"comment-parser": "1.4.0",
"next": "13.5.4",
"next": "13.5.5",
"nextra": "2.13.2",
"nextra-theme-docs": "2.13.2",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"turbo": "1.10.15",
"@turbo/gen": "1.10.15"
},
"packageManager": "[email protected].0",
"packageManager": "[email protected].2",
"name": "ui"
}
127 changes: 58 additions & 69 deletions packages/react-ui/PageDrawer/PageDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { type HTMLAttributes, useState } from 'react';
import { Accordion, AccordionDetails, AccordionSummary } from '@mui/material';
import { Box } from '@mui/system';
import { ExpandMore } from '@mui/icons-material';
import { useDebounce, useResizeObserver } from '@enterwell/react-hooks';

/**
* The PageDrawer component props.
Expand All @@ -22,81 +21,71 @@ export type PageDrawerProps = HTMLAttributes<HTMLDivElement> & {
* @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 (
<>
<Box sx={{ height: drawerSizeDebounced }} />
<Accordion
ref={resizeObserverRef}
<Accordion
sx={{
position: 'sticky',
inset: 'auto 0 0 0',
bgcolor: 'transparent',
backgroundImage: 'none',
border: 'none',
'&::before': {
display: 'none'
}
}}
expanded={expanded}
onChange={onChange}
{...rest}
>
<AccordionSummary
expandIcon={<ExpandMore />}
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}
>
<AccordionSummary
expandIcon={<ExpandMore />}
<Box
sx={{
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: 'block',
content: '""',
position: 'absolute',
top: '40%',
left: 0,
right: 0,
bottom: 0,
bgcolor: 'background.default'
}
borderTop: '1px solid',
borderBottom: '1px solid',
borderColor: color ?? 'primary.dark',
height: 3,
width: '100%',
position: 'absolute',
left: 0,
right: 0,
}}
>
<Box
sx={{
borderTop: '1px solid',
borderBottom: '1px solid',
borderColor: color ?? 'primary.dark',
height: 3,
width: '100%',
position: 'absolute',
left: 0,
right: 0,
}}
/>
</AccordionSummary>
<AccordionDetails sx={{
bgcolor: 'background.default',
maxHeight: '40vh',
overflowX: 'hidden',
overflowY: 'auto'
}}
>
{children}
</AccordionDetails>
</Accordion>
</>
/>
</AccordionSummary>
<AccordionDetails sx={{
bgcolor: 'background.default',
maxHeight: '40vh',
overflowX: 'hidden',
overflowY: 'auto'
}}
>
{children}
</AccordionDetails>
</Accordion>
);
};
4 changes: 2 additions & 2 deletions packages/react-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@mui/icons-material": "5.14.13",
"@mui/material": "5.14.13",
"@mui/system": "5.14.13",
"@mui/lab": "5.0.0-alpha.148",
"@mui/lab": "5.0.0-alpha.149",
"@mui/x-date-pickers-pro": "5.0.20",
"@mui/x-date-pickers": "5.0.20",
"@types/node": "18.18.5",
Expand All @@ -50,7 +50,7 @@
"@emotion/styled": "11.11.0",
"@mui/material": "5.14.13",
"@mui/system": "5.14.13",
"@mui/lab": "5.0.0-alpha.148",
"@mui/lab": "5.0.0-alpha.149",
"@mui/x-date-pickers-pro": "5.0.20",
"@mui/x-date-pickers": "5.0.20",
"react": "18.2.0",
Expand Down
Loading

0 comments on commit e24d1f2

Please sign in to comment.