Files
twenty_crm/packages/twenty-front/src/loading/components/LeftPanelSkeletonLoader.tsx
Paul Rastoin 4a4e65fe4a [REFACTOR] Twenty UI multi barrel (#11301)
# Introduction
closes https://github.com/twentyhq/core-team-issues/issues/591
Same than for `twenty-shared` made in
https://github.com/twentyhq/twenty/pull/11083.

## TODO
- [x] Manual migrate twenty-website twenty-ui imports

## What's next:
- Generate barrel and migration script factorization within own package
+ tests
- Refactoring using preconstruct ? TimeBox
- Lint circular dependencies
- Lint import from barrel and forbid them

### Preconstruct
We need custom rollup plugins addition, but preconstruct does not expose
its rollup configuration. It might be possible to handle this using the
babel overrides. But was a big tunnel.
We could give it a try afterwards ! ( allowing cjs interop and stuff
like that )
Stuck to vite lib app

Closed related PRs:
- https://github.com/twentyhq/twenty/pull/11294
- https://github.com/twentyhq/twenty/pull/11203
2025-04-03 09:47:55 +00:00

86 lines
2.5 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 { NAV_DRAWER_WIDTHS } from '@/ui/navigation/navigation-drawer/constants/NavDrawerWidths';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { useTheme } from '@emotion/react';
import { MainNavigationDrawerItemsSkeletonLoader } from '~/loading/components/MainNavigationDrawerItemsSkeletonLoader';
import { ANIMATION } from 'twenty-ui/theme';
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
? NAV_DRAWER_WIDTHS.menu.mobile.collapsed
: NAV_DRAWER_WIDTHS.menu.desktop.expanded,
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>
);
};