4fe8e3d3b6
## Summary Adds Notion-style resizable panels for the navigation drawer (left sidebar) and command menu (right panel). ## Behavior - **Hover** at panel edge → resize cursor appears - **Click** → collapse/close the panel - **Drag** → resize the panel (5px movement threshold to distinguish from click) ## Constraints | Panel | Min | Max | Default | Collapse Threshold | |-------|-----|-----|---------|-------------------| | Navigation Drawer | 180px | 350px | 220px | 150px | | Command Menu | 320px | 600px | 400px | 250px | ## Performance Optimizations - **CSS variables** for smooth 60fps resize (no React re-renders during drag) - **Table resize observer disabled** during panel resize to prevent expensive recalculations - **React.memo wrapper** on page body to prevent unnecessary re-renders ## Architecture - `useResizablePanel` hook following the same pattern as `useResizeTableHeader` - `ResizablePanelEdge` - resize handle positioned at panel edge - `ResizablePanelGap` - resize handle in the gap between panels - `cssVariableEffect` - Recoil effect to sync CSS variables with state ## Refactoring - Split `recoil-effects.ts` into separate files in `utils/recoil/` (one export per file) - Persist panel widths to localStorage via existing `localStorageEffect`
84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
import styled from '@emotion/styled';
|
|
import { motion } from 'framer-motion';
|
|
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
|
|
|
import { SKELETON_LOADER_HEIGHT_SIZES } from '@/activities/components/SkeletonLoader';
|
|
import { NAVIGATION_DRAWER_CONSTRAINTS } from '@/ui/layout/resizable-panel/constants/NavigationDrawerConstraints';
|
|
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
|
import { useTheme } from '@emotion/react';
|
|
import { ANIMATION } from 'twenty-ui/theme';
|
|
import { MainNavigationDrawerItemsSkeletonLoader } from '~/loading/components/MainNavigationDrawerItemsSkeletonLoader';
|
|
|
|
const StyledAnimatedContainer = styled(motion.div)`
|
|
align-items: center;
|
|
display: flex;
|
|
justify-content: end;
|
|
`;
|
|
|
|
const StyledItemsContainer = styled.div`
|
|
align-items: center;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 14px;
|
|
height: calc(100dvh - 32px);
|
|
margin-bottom: auto;
|
|
max-width: 204px;
|
|
min-width: 204px;
|
|
overflow-y: auto;
|
|
`;
|
|
|
|
const StyledSkeletonContainer = styled.div`
|
|
align-items: center;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 32px;
|
|
`;
|
|
|
|
const StyledSkeletonTitleContainer = styled.div`
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: flex-start;
|
|
gap: 10px;
|
|
height: 32px;
|
|
|
|
max-width: 196px;
|
|
min-width: 196px;
|
|
`;
|
|
|
|
export const LeftPanelSkeletonLoader = () => {
|
|
const isMobile = useIsMobile();
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
<StyledAnimatedContainer
|
|
initial={false}
|
|
animate={{
|
|
width: isMobile ? 0 : NAVIGATION_DRAWER_CONSTRAINTS.default,
|
|
opacity: isMobile ? 0 : 1,
|
|
}}
|
|
transition={{ duration: ANIMATION.duration.fast }}
|
|
>
|
|
<StyledItemsContainer>
|
|
<StyledSkeletonTitleContainer>
|
|
<SkeletonTheme
|
|
baseColor={theme.background.tertiary}
|
|
highlightColor={theme.background.transparent.lighter}
|
|
borderRadius={4}
|
|
>
|
|
<Skeleton
|
|
width={96}
|
|
height={SKELETON_LOADER_HEIGHT_SIZES.standard.s}
|
|
/>
|
|
</SkeletonTheme>
|
|
</StyledSkeletonTitleContainer>
|
|
<StyledSkeletonContainer>
|
|
<MainNavigationDrawerItemsSkeletonLoader length={3} />
|
|
<MainNavigationDrawerItemsSkeletonLoader title length={2} />
|
|
<MainNavigationDrawerItemsSkeletonLoader title length={3} />
|
|
</StyledSkeletonContainer>
|
|
</StyledItemsContainer>
|
|
</StyledAnimatedContainer>
|
|
);
|
|
};
|