From 5a2fa26dad4380d1bac3e796c4d92afb6957c7a7 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Sun, 15 Jun 2025 10:55:49 -0700 Subject: [PATCH] Drawer: optimize opening with css --- .../layout/optima/drawer/DesktopDrawer.tsx | 54 +++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/src/common/layout/optima/drawer/DesktopDrawer.tsx b/src/common/layout/optima/drawer/DesktopDrawer.tsx index e590ef6c6..32448b7a6 100644 --- a/src/common/layout/optima/drawer/DesktopDrawer.tsx +++ b/src/common/layout/optima/drawer/DesktopDrawer.tsx @@ -21,16 +21,25 @@ const DesktopDrawerFixRoot = styled(Box)({ width: 'var(--AGI-Desktop-Drawer-width)', flexShrink: 0, flexGrow: 0, + + // Base state + zIndex: themeZIndexDesktopDrawer, + + '&[aria-hidden="true"]': { + contain: 'strict', + pointerEvents: 'none', + }, + + '&.drawer-peeking': { + zIndex: themeZIndexDesktopDrawer + 1, // elevate z-index when peeking + }, }); const DesktopDrawerTranslatingSheet = styled(Sheet)(({ theme }) => ({ // layouting width: '100%', height: '100dvh', - - // sliding - moved to component props for dynamic timing - // transition: 'transform 0.42s cubic-bezier(.17,.84,.44,1)', - zIndex: themeZIndexDesktopDrawer, + zIndex: 1, // just to allocate a layer; this was: themeZIndexDesktopDrawer, but it's probably wrong to have it here? // styling backgroundColor: OPTIMA_DRAWER_BACKGROUND, @@ -46,6 +55,22 @@ const DesktopDrawerTranslatingSheet = styled(Sheet)(({ theme }) => ({ // content layout display: 'flex', flexDirection: 'column', + + // Base state with default transition + transform: 'none', + transition: 'transform 0.42s cubic-bezier(.17,.84,.44,1)', // Default: normal open/close, and peeking exit + willChange: 'transform', // Optimize for transform animations + + // Hidden state via aria attribute + '&[aria-hidden="true"]': { + transform: 'translateX(-100%)', + }, + + // Peek state overrides + '&.drawer-peeking': { + transition: 'transform 0.25s cubic-bezier(.4,0,.2,1)', // Faster enter animation + boxShadow: theme.shadow.lg, // Additional shadow when overlaying + }, })) as typeof Sheet; @@ -100,28 +125,15 @@ export function DesktopDrawer(props: { component: React.ElementType, currentApp? return ( {/* NOTE: this sort of algo was not used when we migrated this to Portals on 2024-07-30, so not restoring it ... */}