mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-25 21:13:01 +03:00
Added skeleton loader on page load (#3740)
* #3722 added skeleton loader on page load * #3740 Resolved comment in loader
This commit is contained in:
parent
7001ca83d1
commit
ddc5165178
@ -1,4 +1,5 @@
|
||||
import { ComponentProps, ReactNode } from 'react';
|
||||
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
@ -71,11 +72,25 @@ const StyledTopBarButtonContainer = styled.div`
|
||||
margin-right: ${({ theme }) => theme.spacing(1)};
|
||||
`;
|
||||
|
||||
const StyledSkeletonLoader = () => {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<SkeletonTheme
|
||||
baseColor={theme.background.quaternary}
|
||||
highlightColor={theme.background.transparent.light}
|
||||
borderRadius={50}
|
||||
>
|
||||
<Skeleton height={24} width={108} />
|
||||
</SkeletonTheme>
|
||||
);
|
||||
};
|
||||
|
||||
type PageHeaderProps = ComponentProps<'div'> & {
|
||||
title: string;
|
||||
hasBackButton?: boolean;
|
||||
Icon: IconComponent;
|
||||
children?: ReactNode;
|
||||
loading?: boolean;
|
||||
};
|
||||
|
||||
export const PageHeader = ({
|
||||
@ -83,6 +98,7 @@ export const PageHeader = ({
|
||||
hasBackButton,
|
||||
Icon,
|
||||
children,
|
||||
loading,
|
||||
}: PageHeaderProps) => {
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
@ -105,12 +121,16 @@ export const PageHeader = ({
|
||||
variant="tertiary"
|
||||
/>
|
||||
)}
|
||||
<StyledTopBarIconStyledTitleContainer>
|
||||
{Icon && <Icon size={theme.icon.size.md} />}
|
||||
<StyledTitleContainer data-testid="top-bar-title">
|
||||
<OverflowingTextWithTooltip text={title} />
|
||||
</StyledTitleContainer>
|
||||
</StyledTopBarIconStyledTitleContainer>
|
||||
{loading ? (
|
||||
<StyledSkeletonLoader />
|
||||
) : (
|
||||
<StyledTopBarIconStyledTitleContainer>
|
||||
{Icon && <Icon size={theme.icon.size.md} />}
|
||||
<StyledTitleContainer data-testid="top-bar-title">
|
||||
<OverflowingTextWithTooltip text={title} />
|
||||
</StyledTitleContainer>
|
||||
</StyledTopBarIconStyledTitleContainer>
|
||||
)}
|
||||
</StyledLeftContainer>
|
||||
<StyledPageActionContainer>{children}</StyledPageActionContainer>
|
||||
</StyledTopBarContainer>
|
||||
|
@ -42,7 +42,7 @@ export const RecordShowPage = () => {
|
||||
recordStoreFamilyState(objectRecordId),
|
||||
);
|
||||
|
||||
const { record } = useFindOneRecord({
|
||||
const { record, loading } = useFindOneRecord({
|
||||
objectRecordId,
|
||||
objectNameSingular,
|
||||
});
|
||||
@ -80,6 +80,7 @@ export const RecordShowPage = () => {
|
||||
title={pageName ?? ''}
|
||||
hasBackButton
|
||||
Icon={IconBuildingSkyscraper}
|
||||
loading={loading}
|
||||
>
|
||||
{record && (
|
||||
<>
|
||||
|
Loading…
Reference in New Issue
Block a user