Prefetch Skeleton Loading on Indexes and Shows (#5545)
### Description Prefetch Skeleton Loading on Indexes and Shows ### Refs #4458 ### Demo https://jam.dev/c/a1ad04e1-80b6-4b2a-b7df-373f52f4b169 https://jam.dev/c/c5038b97-2f18-4c29-8dee-18c09376e5ee Fixes: #4458 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { TimelineCreateButtonGroup } from '@/activities/timeline/components/TimelineCreateButtonGroup';
|
||||
import { TimelineSkeletonLoader } from '@/activities/timeline/components/TimelineSkeletonLoader';
|
||||
import { timelineActivitiesForGroupState } from '@/activities/timeline/states/timelineActivitiesForGroupState';
|
||||
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
|
||||
import AnimatedPlaceholder from '@/ui/layout/animated-placeholder/components/AnimatedPlaceholder';
|
||||
@ -29,82 +28,19 @@ const StyledMainContainer = styled.div`
|
||||
justify-content: center;
|
||||
`;
|
||||
|
||||
const StyledSkeletonContainer = styled.div`
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: ${({ theme }) => theme.spacing(8)};
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: ${({ theme }) => theme.spacing(4)};
|
||||
flex-wrap: wrap;
|
||||
align-content: flex-start;
|
||||
`;
|
||||
|
||||
const StyledSkeletonSubSection = styled.div`
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(4)};
|
||||
`;
|
||||
|
||||
const StyledSkeletonColumn = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: ${({ theme }) => theme.spacing(3)};
|
||||
justify-content: center;
|
||||
`;
|
||||
|
||||
const StyledSkeletonLoader = () => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<SkeletonTheme
|
||||
baseColor={theme.background.tertiary}
|
||||
highlightColor={theme.background.transparent.lighter}
|
||||
borderRadius={80}
|
||||
>
|
||||
<Skeleton width={24} height={84} />
|
||||
</SkeletonTheme>
|
||||
);
|
||||
};
|
||||
|
||||
const StyledTimelineSkeletonLoader = () => {
|
||||
const theme = useTheme();
|
||||
const skeletonItems = Array.from({ length: 3 }).map((_, index) => ({
|
||||
id: `skeleton-item-${index}`,
|
||||
}));
|
||||
return (
|
||||
<SkeletonTheme
|
||||
baseColor={theme.background.tertiary}
|
||||
highlightColor={theme.background.transparent.lighter}
|
||||
borderRadius={4}
|
||||
>
|
||||
<StyledSkeletonContainer>
|
||||
<Skeleton width={440} height={16} />
|
||||
{skeletonItems.map(({ id }) => (
|
||||
<StyledSkeletonSubSection key={id}>
|
||||
<StyledSkeletonLoader />
|
||||
<StyledSkeletonColumn>
|
||||
<Skeleton width={400} height={24} />
|
||||
<Skeleton width={400} height={24} />
|
||||
</StyledSkeletonColumn>
|
||||
</StyledSkeletonSubSection>
|
||||
))}
|
||||
</StyledSkeletonContainer>
|
||||
</SkeletonTheme>
|
||||
);
|
||||
};
|
||||
|
||||
export const Timeline = ({
|
||||
targetableObject,
|
||||
loading,
|
||||
}: {
|
||||
targetableObject: ActivityTargetableObject;
|
||||
loading?: boolean;
|
||||
loading: boolean;
|
||||
}) => {
|
||||
const timelineActivitiesForGroup = useRecoilValue(
|
||||
timelineActivitiesForGroupState,
|
||||
);
|
||||
|
||||
if (loading === true) {
|
||||
return <StyledTimelineSkeletonLoader />;
|
||||
if (loading) {
|
||||
return <TimelineSkeletonLoader />;
|
||||
}
|
||||
|
||||
if (timelineActivitiesForGroup.length === 0) {
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
const StyledSkeletonContainer = styled.div`
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: ${({ theme }) => theme.spacing(8)};
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: ${({ theme }) => theme.spacing(4)};
|
||||
flex-wrap: wrap;
|
||||
align-content: flex-start;
|
||||
`;
|
||||
|
||||
const StyledSkeletonSubSection = styled.div`
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(4)};
|
||||
`;
|
||||
|
||||
const StyledSkeletonColumn = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: ${({ theme }) => theme.spacing(3)};
|
||||
justify-content: center;
|
||||
`;
|
||||
|
||||
const StyledSkeletonLoader = ({
|
||||
isSecondColumn,
|
||||
}: {
|
||||
isSecondColumn: boolean;
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<SkeletonTheme
|
||||
baseColor={theme.background.tertiary}
|
||||
highlightColor={theme.background.transparent.lighter}
|
||||
borderRadius={80}
|
||||
>
|
||||
<Skeleton width={24} height={isSecondColumn ? 120 : 84} />
|
||||
</SkeletonTheme>
|
||||
);
|
||||
};
|
||||
|
||||
export const TimelineSkeletonLoader = () => {
|
||||
const theme = useTheme();
|
||||
const skeletonItems = Array.from({ length: 3 }).map((_, index) => ({
|
||||
id: `skeleton-item-${index}`,
|
||||
}));
|
||||
|
||||
return (
|
||||
<SkeletonTheme
|
||||
baseColor={theme.background.tertiary}
|
||||
highlightColor={theme.background.transparent.lighter}
|
||||
borderRadius={4}
|
||||
>
|
||||
<StyledSkeletonContainer>
|
||||
<Skeleton width={440} height={16} />
|
||||
{skeletonItems.map(({ id }, index) => (
|
||||
<StyledSkeletonSubSection key={id}>
|
||||
<StyledSkeletonLoader isSecondColumn={index === 1} />
|
||||
<StyledSkeletonColumn>
|
||||
<Skeleton width={400} height={24} />
|
||||
<Skeleton width={400} height={24} />
|
||||
{index === 1 && <Skeleton width={400} height={24} />}
|
||||
</StyledSkeletonColumn>
|
||||
</StyledSkeletonSubSection>
|
||||
))}
|
||||
</StyledSkeletonContainer>
|
||||
</SkeletonTheme>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user