Add common loader (#18556)

To avoid white screens on reload, building a shared skeleton.

Before

https://github.com/user-attachments/assets/42bd0667-141d-4df4-9072-4077192cc71d

After

https://github.com/user-attachments/assets/e6031a72-2e25-47e3-a873-b89aaddfbd3a
This commit is contained in:
Thomas Trompette
2026-03-11 14:56:49 +01:00
committed by GitHub
parent 2c5af2654d
commit b346f4fb59
6 changed files with 87 additions and 95 deletions
@@ -0,0 +1,56 @@
import { SKELETON_LOADER_HEIGHT_SIZES } from '@/activities/components/SkeletonLoader';
import { PageBody } from '@/ui/layout/page/components/PageBody';
import { PAGE_BAR_MIN_HEIGHT } from '@/ui/layout/page/constants/PageBarMinHeight';
import { styled } from '@linaria/react';
import { useContext } from 'react';
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
const StyledHeaderSkeleton = styled.div`
align-items: center;
background: ${themeCssVariables.background.noisy};
display: flex;
flex-direction: row;
gap: ${themeCssVariables.spacing[2]};
justify-content: space-between;
min-height: ${PAGE_BAR_MIN_HEIGHT}px;
padding: ${themeCssVariables.spacing[3]};
`;
const StyledHeaderLeft = styled.div`
flex: 1;
`;
export const PageContentSkeletonLoader = () => {
const { theme } = useContext(ThemeContext);
return (
<>
<StyledHeaderSkeleton>
<StyledHeaderLeft>
<SkeletonTheme
baseColor={theme.background.tertiary}
highlightColor={theme.background.transparent.lighter}
borderRadius={4}
>
<Skeleton
height={SKELETON_LOADER_HEIGHT_SIZES.standard.s}
width={104}
/>
</SkeletonTheme>
</StyledHeaderLeft>
<SkeletonTheme
baseColor={theme.background.tertiary}
highlightColor={theme.background.transparent.lighter}
borderRadius={4}
>
<Skeleton
width={132}
height={SKELETON_LOADER_HEIGHT_SIZES.standard.s}
/>
</SkeletonTheme>
</StyledHeaderSkeleton>
<PageBody>{null}</PageBody>
</>
);
};