|
| 1 | +import Skeleton, { SkeletonTheme } from 'react-loading-skeleton'; |
| 2 | +import styled from '@emotion/styled'; |
| 3 | +import { motion } from 'framer-motion'; |
| 4 | +import { ANIMATION, BACKGROUND_LIGHT, GRAY_SCALE } from 'twenty-ui'; |
| 5 | + |
| 6 | +import { DESKTOP_NAV_DRAWER_WIDTHS } from '@/ui/navigation/navigation-drawer/constants/DesktopNavDrawerWidths'; |
| 7 | +import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; |
| 8 | +import { MainNavigationDrawerItemsSkeletonLoader } from '~/loading/components/MainNavigationDrawerItemsSkeletonLoader'; |
| 9 | + |
| 10 | +const StyledAnimatedContainer = styled(motion.div)` |
| 11 | + display: flex; |
| 12 | + justify-content: end; |
| 13 | +`; |
| 14 | + |
| 15 | +const StyledItemsContainer = styled.div` |
| 16 | + display: flex; |
| 17 | + flex-direction: column; |
| 18 | + gap: 32px; |
| 19 | + margin-bottom: auto; |
| 20 | + overflow-y: auto; |
| 21 | + height: calc(100vh - 32px); |
| 22 | + min-width: 216px; |
| 23 | + max-width: 216px; |
| 24 | +`; |
| 25 | + |
| 26 | +const StyledSkeletonContainer = styled.div` |
| 27 | + display: flex; |
| 28 | + flex-direction: column; |
| 29 | + gap: 32px; |
| 30 | +`; |
| 31 | + |
| 32 | +const StyledSkeletonTitleContainer = styled.div` |
| 33 | + display: flex; |
| 34 | + flex-direction: column; |
| 35 | + gap: 6px; |
| 36 | + margin-left: 12px; |
| 37 | + margin-top: 8px; |
| 38 | +`; |
| 39 | + |
| 40 | +export const LeftPanelSkeletonLoader = () => { |
| 41 | + const isMobile = useIsMobile(); |
| 42 | + const mobileWidth = isMobile ? 0 : '100%'; |
| 43 | + const desktopWidth = !mobileWidth ? 12 : DESKTOP_NAV_DRAWER_WIDTHS.menu; |
| 44 | + |
| 45 | + return ( |
| 46 | + <StyledAnimatedContainer |
| 47 | + initial={false} |
| 48 | + animate={{ |
| 49 | + width: isMobile ? mobileWidth : desktopWidth, |
| 50 | + opacity: isMobile ? 0 : 1, |
| 51 | + }} |
| 52 | + transition={{ |
| 53 | + duration: ANIMATION.duration.fast, |
| 54 | + }} |
| 55 | + > |
| 56 | + <StyledItemsContainer> |
| 57 | + <StyledSkeletonContainer> |
| 58 | + <StyledSkeletonTitleContainer> |
| 59 | + <SkeletonTheme |
| 60 | + baseColor={GRAY_SCALE.gray15} |
| 61 | + highlightColor={BACKGROUND_LIGHT.transparent.lighter} |
| 62 | + borderRadius={4} |
| 63 | + > |
| 64 | + <Skeleton width={96} height={16} /> |
| 65 | + </SkeletonTheme> |
| 66 | + </StyledSkeletonTitleContainer> |
| 67 | + <MainNavigationDrawerItemsSkeletonLoader length={4} /> |
| 68 | + <MainNavigationDrawerItemsSkeletonLoader title length={2} /> |
| 69 | + <MainNavigationDrawerItemsSkeletonLoader title length={3} /> |
| 70 | + </StyledSkeletonContainer> |
| 71 | + </StyledItemsContainer> |
| 72 | + </StyledAnimatedContainer> |
| 73 | + ); |
| 74 | +}; |
0 commit comments