Skip to content

The open alternative to Salesforce, designed for AI.

Stack SkeletonLine placeholders in a flex column (#28268)

Raphaël Bosiae80d0e4e91d
diff --git a/packages/twenty-front/.oxlintrc.json b/packages/twenty-front/.oxlintrc.json
index 2afbf7494cd..a90f01dacad 100644
--- a/packages/twenty-front/.oxlintrc.json
+++ b/packages/twenty-front/.oxlintrc.json
@@ -146,14 +146,6 @@
]
},
"overrides": [
- {
- "files": [
- "src/modules/ui/feedback/skeleton/constants/LEGACY_SKELETON_COLORS.ts"
- ],
- "rules": {
- "twenty/no-hardcoded-colors": "off"
- }
- },
{
"files": [
"src/modules/ui/input/components/NavigationButton.tsx",
diff --git a/packages/twenty-front/src/loading/components/MainNavigationDrawerItemsSkeletonLoader.tsx b/packages/twenty-front/src/loading/components/MainNavigationDrawerItemsSkeletonLoader.tsx
index 4ca252d5630..26bab2b9fbe 100644
--- a/packages/twenty-front/src/loading/components/MainNavigationDrawerItemsSkeletonLoader.tsx
+++ b/packages/twenty-front/src/loading/components/MainNavigationDrawerItemsSkeletonLoader.tsx
@@ -1,21 +1,14 @@
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
-import { css } from '@linaria/core';
import { styled } from '@linaria/react';
import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';
const StyledSkeletonContainer = styled.div`
- align-items: flex-start;
display: flex;
flex-direction: column;
gap: 6px;
width: 100%;
`;
-const fillSkeletonContainer = css`
- display: block;
- width: 100%;
-`;
-
export const MainNavigationDrawerItemsSkeletonLoader = ({
title,
length,
@@ -27,11 +20,7 @@ export const MainNavigationDrawerItemsSkeletonLoader = ({
<StyledSkeletonContainer>
{title && <SkeletonLine width={48} height={SKELETON_HEIGHT_SIZES.xs} />}
{Array.from({ length }).map((_, index) => (
- <SkeletonLine
- key={index}
- containerClassName={fillSkeletonContainer}
- height={SKELETON_HEIGHT_SIZES.s}
- />
+ <SkeletonLine key={index} height={SKELETON_HEIGHT_SIZES.s} />
))}
</StyledSkeletonContainer>
);
diff --git a/packages/twenty-front/src/modules/front-components/components/FrontComponentSkeletonLoader.tsx b/packages/twenty-front/src/modules/front-components/components/FrontComponentSkeletonLoader.tsx
index 16a05d03cfd..62a72b5a03c 100644
--- a/packages/twenty-front/src/modules/front-components/components/FrontComponentSkeletonLoader.tsx
+++ b/packages/twenty-front/src/modules/front-components/components/FrontComponentSkeletonLoader.tsx
@@ -1,4 +1,5 @@
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
+import { css } from '@linaria/core';
import { styled } from '@linaria/react';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -6,17 +7,17 @@ import { themeCssVariables } from 'twenty-ui/theme';
const StyledContainer = styled.div`
height: 100%;
width: 100%;
+`;
- & > span {
- display: block;
- height: 100%;
- }
+const skeletonLineContainerClassName = css`
+ height: 100%;
`;
export const FrontComponentSkeletonLoader = () => {
return (
<StyledContainer>
<SkeletonLine
+ containerClassName={skeletonLineContainerClassName}
height="100%"
borderRadius={themeCssVariables.border.radius.mdRound}
/>
diff --git a/packages/twenty-front/src/modules/object-core/agents/components/CoreAgentRunsTab.tsx b/packages/twenty-front/src/modules/object-core/agents/components/CoreAgentRunsTab.tsx
index 11377529309..64af5417db6 100644
--- a/packages/twenty-front/src/modules/object-core/agents/components/CoreAgentRunsTab.tsx
+++ b/packages/twenty-front/src/modules/object-core/agents/components/CoreAgentRunsTab.tsx
@@ -12,7 +12,6 @@ import { groupCoreAgentRunsByConversation } from '@/object-core/agents/utils/gro
import { AnimatedPlaceholder } from '@/ui/feedback/empty-state/components/AnimatedPlaceholder/AnimatedPlaceholder';
import { EmptyState } from '@/ui/feedback/empty-state/components/EmptyState';
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
-import { LEGACY_SKELETON_COLORS } from '@/ui/feedback/skeleton/constants/LEGACY_SKELETON_COLORS';
import { Table } from '@/ui/layout/table/components/Table';
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
import { TableRow } from '@/ui/layout/table/components/TableRow';
@@ -79,13 +78,7 @@ export const CoreAgentRunsTab = ({ agentId }: CoreAgentRunsTabProps) => {
<Table>
{header}
{Array.from({ length: 3 }).map((_, index) => (
- <SkeletonLine
- baseColor={LEGACY_SKELETON_COLORS.base}
- highlightColor={LEGACY_SKELETON_COLORS.highlight}
- height={32}
- borderRadius={4}
- key={index}
- />
+ <SkeletonLine height={32} key={index} />
))}
</Table>
</StyledTableContainer>
diff --git a/packages/twenty-front/src/modules/object-metadata/components/NavigationDrawerWorkspaceSectionSkeletonLoader.tsx b/packages/twenty-front/src/modules/object-metadata/components/NavigationDrawerWorkspaceSectionSkeletonLoader.tsx
index ce86062aa48..2110ef7aa3b 100644
--- a/packages/twenty-front/src/modules/object-metadata/components/NavigationDrawerWorkspaceSectionSkeletonLoader.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/components/NavigationDrawerWorkspaceSectionSkeletonLoader.tsx
@@ -1,6 +1,5 @@
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
import { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection';
-import { css } from '@linaria/core';
import { styled } from '@linaria/react';
import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -22,11 +21,6 @@ const StyledRowsContainer = styled.div`
width: 100%;
`;
-const fillSkeletonContainer = css`
- display: block;
- width: 100%;
-`;
-
export const NavigationDrawerWorkspaceSectionSkeletonLoader = () => {
return (
<NavigationDrawerSection>
@@ -39,17 +33,14 @@ export const NavigationDrawerWorkspaceSectionSkeletonLoader = () => {
</StyledTitleSkeleton>
<StyledRowsContainer>
<SkeletonLine
- containerClassName={fillSkeletonContainer}
height={SKELETON_HEIGHT_SIZES.s}
highlightColor={themeCssVariables.background.transparent.light}
/>
<SkeletonLine
- containerClassName={fillSkeletonContainer}
height={SKELETON_HEIGHT_SIZES.s}
highlightColor={themeCssVariables.background.transparent.light}
/>
<SkeletonLine
- containerClassName={fillSkeletonContainer}
height={SKELETON_HEIGHT_SIZES.s}
highlightColor={themeCssVariables.background.transparent.light}
/>
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsSectionSkeletonLoader.tsx b/packages/twenty-front/src/modules/settings/components/SettingsSectionSkeletonLoader.tsx
index c96afdfe4a7..f1287faf58b 100644
--- a/packages/twenty-front/src/modules/settings/components/SettingsSectionSkeletonLoader.tsx
+++ b/packages/twenty-front/src/modules/settings/components/SettingsSectionSkeletonLoader.tsx
@@ -1,5 +1,4 @@
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
-import { styled } from '@linaria/react';
import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -7,19 +6,14 @@ type SettingsSectionSkeletonLoaderProps = {
rowCount?: number;
};
-const StyledRows = styled.div`
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[2]};
- width: 100%;
-`;
-
export const SettingsSectionSkeletonLoader = ({
rowCount = 4,
}: SettingsSectionSkeletonLoaderProps) => {
return (
- <StyledRows>
- <SkeletonLine count={rowCount} height={SKELETON_HEIGHT_SIZES.l} />
- </StyledRows>
+ <SkeletonLine
+ count={rowCount}
+ height={SKELETON_HEIGHT_SIZES.l}
+ gap={themeCssVariables.spacing[2]}
+ />
);
};
diff --git a/packages/twenty-front/src/modules/settings/developers/components/RestPlayground.tsx b/packages/twenty-front/src/modules/settings/developers/components/RestPlayground.tsx
index 6ea76feec2d..ba98ec591a0 100644
--- a/packages/twenty-front/src/modules/settings/developers/components/RestPlayground.tsx
+++ b/packages/twenty-front/src/modules/settings/developers/components/RestPlayground.tsx
@@ -7,6 +7,7 @@ import {
import { type PlaygroundSchemas } from '@/settings/developers/types/PlaygroundSchemas';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useState, lazy, Suspense } from 'react';
+import { css } from '@linaria/core';
import { styled } from '@linaria/react';
import { SettingsPath } from 'twenty-shared/types';
@@ -41,6 +42,10 @@ const StyledContainer = styled.div`
}
`;
+const skeletonLineContainerClassName = css`
+ height: 100%;
+`;
+
const ApiReferenceReact = lazy(() =>
import('@scalar/api-reference-react').then((module) => {
import('@scalar/api-reference-react/style.css');
@@ -65,7 +70,13 @@ export const RestPlayground = ({ onError, schema }: RestPlaygroundProps) => {
return null;
}
- const fallback = <SkeletonLine width="100%" height="100%" />;
+ const fallback = (
+ <SkeletonLine
+ containerClassName={skeletonLineContainerClassName}
+ width="100%"
+ height="100%"
+ />
+ );
return (
<StyledContainer>
diff --git a/packages/twenty-front/src/modules/settings/translations/components/MetadataTranslationsTable.tsx b/packages/twenty-front/src/modules/settings/translations/components/MetadataTranslationsTable.tsx
index f5d4374decb..a2a7f15d47f 100644
--- a/packages/twenty-front/src/modules/settings/translations/components/MetadataTranslationsTable.tsx
+++ b/packages/twenty-front/src/modules/settings/translations/components/MetadataTranslationsTable.tsx
@@ -3,7 +3,6 @@ import { MetadataTranslationsTableRow } from '@/settings/translations/components
import { type MetadataTranslationLanguageRow } from '@/settings/translations/types/MetadataTranslationLanguageRow';
import { type MetadataTranslationRowValue } from '@/settings/translations/types/MetadataTranslationRowValue';
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
-import { LEGACY_SKELETON_COLORS } from '@/ui/feedback/skeleton/constants/LEGACY_SKELETON_COLORS';
import { Table } from '@/ui/layout/table/components/Table';
import { TableBody } from '@/ui/layout/table/components/TableBody';
import { TableCell } from '@/ui/layout/table/components/TableCell';
@@ -70,13 +69,7 @@ export const MetadataTranslationsTable = ({
<TableBody>
{showSkeleton
? Array.from({ length: 3 }).map((_, index) => (
- <SkeletonLine
- baseColor={LEGACY_SKELETON_COLORS.base}
- highlightColor={LEGACY_SKELETON_COLORS.highlight}
- height={32}
- borderRadius={4}
- key={index}
- />
+ <SkeletonLine height={32} key={index} />
))
: languageRows.map(({ locale, label, translations }) => (
<MetadataTranslationsTableRow
diff --git a/packages/twenty-front/src/modules/ui/feedback/skeleton/components/SkeletonLine.tsx b/packages/twenty-front/src/modules/ui/feedback/skeleton/components/SkeletonLine.tsx
index a6352cd1234..1fc9b7bf423 100644
--- a/packages/twenty-front/src/modules/ui/feedback/skeleton/components/SkeletonLine.tsx
+++ b/packages/twenty-front/src/modules/ui/feedback/skeleton/components/SkeletonLine.tsx
@@ -1,4 +1,5 @@
-import { type ComponentProps, Fragment } from 'react';
+import { styled } from '@linaria/react';
+import { type ComponentProps } from 'react';
import { Skeleton } from 'twenty-ui/primitives/feedback';
import { themeCssVariables } from 'twenty-ui/theme';
@@ -16,13 +17,21 @@ type SkeletonLineProps = Pick<
| 'ref'
> & {
count?: number;
+ gap?: string;
containerClassName?: string;
};
+const StyledSkeletonLineContainer = styled.div<{ gap?: string }>`
+ display: flex;
+ flex-direction: column;
+ gap: ${({ gap }) => gap ?? '0'};
+`;
+
export const SkeletonLine = ({
width,
height,
count = 1,
+ gap,
containerClassName,
className,
style,
@@ -33,24 +42,26 @@ export const SkeletonLine = ({
render,
ref,
}: SkeletonLineProps) => (
- <span className={containerClassName} aria-live="polite" aria-busy={animated}>
+ <StyledSkeletonLineContainer
+ className={containerClassName}
+ gap={gap}
+ aria-live="polite"
+ aria-busy={animated}
+ >
{Array.from({ length: count }, (_, index) => (
- <Fragment key={index}>
- <Skeleton
- layout="inline"
- width={width}
- height={height}
- className={className}
- style={style}
- baseColor={baseColor}
- highlightColor={highlightColor}
- borderRadius={borderRadius}
- animated={animated}
- render={render}
- ref={ref}
- />
- <br />
- </Fragment>
+ <Skeleton
+ key={index}
+ width={width}
+ height={height}
+ className={className}
+ style={style}
+ baseColor={baseColor}
+ highlightColor={highlightColor}
+ borderRadius={borderRadius}
+ animated={animated}
+ render={render}
+ ref={ref}
+ />
))}
- </span>
+ </StyledSkeletonLineContainer>
);
diff --git a/packages/twenty-front/src/modules/ui/feedback/skeleton/components/__tests__/SkeletonLine.test.tsx b/packages/twenty-front/src/modules/ui/feedback/skeleton/components/__tests__/SkeletonLine.test.tsx
index e9d8c3dfc9c..b9dee110d4f 100644
--- a/packages/twenty-front/src/modules/ui/feedback/skeleton/components/__tests__/SkeletonLine.test.tsx
+++ b/packages/twenty-front/src/modules/ui/feedback/skeleton/components/__tests__/SkeletonLine.test.tsx
@@ -3,22 +3,17 @@ import { render } from '@testing-library/react';
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
describe('SkeletonLine', () => {
- it('groups repeated placeholders and line breaks in one loading region', () => {
+ it('groups repeated placeholders in one loading region', () => {
const { container } = render(<SkeletonLine count={3} height={32} />);
const loadingRegions = container.querySelectorAll('[aria-live="polite"]');
const loadingRegion = loadingRegions[0];
expect(loadingRegions).toHaveLength(1);
expect(loadingRegion).toHaveAttribute('aria-busy', 'true');
- expect(loadingRegion.querySelectorAll('[aria-hidden="true"]')).toHaveLength(
- 3,
- );
- expect(loadingRegion.querySelectorAll('br')).toHaveLength(3);
+ expect(loadingRegion.children).toHaveLength(3);
- for (const placeholder of loadingRegion.querySelectorAll(
- '[aria-hidden="true"]',
- )) {
- expect(placeholder.nextElementSibling?.tagName).toBe('BR');
+ for (const placeholder of loadingRegion.children) {
+ expect(placeholder).toHaveAttribute('aria-hidden', 'true');
}
});
diff --git a/packages/twenty-front/src/modules/ui/feedback/skeleton/constants/LEGACY_SKELETON_COLORS.ts b/packages/twenty-front/src/modules/ui/feedback/skeleton/constants/LEGACY_SKELETON_COLORS.ts
deleted file mode 100644
index a7f252ae313..00000000000
--- a/packages/twenty-front/src/modules/ui/feedback/skeleton/constants/LEGACY_SKELETON_COLORS.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export const LEGACY_SKELETON_COLORS = {
- base: '#ebebeb',
- highlight: '#f5f5f5',
-};
diff --git a/packages/twenty-front/src/modules/ui/input/relation-picker/components/skeletons/DropdownMenuSkeletonItem.tsx b/packages/twenty-front/src/modules/ui/input/relation-picker/components/skeletons/DropdownMenuSkeletonItem.tsx
index 841965a1178..88969e274d7 100644
--- a/packages/twenty-front/src/modules/ui/input/relation-picker/components/skeletons/DropdownMenuSkeletonItem.tsx
+++ b/packages/twenty-front/src/modules/ui/input/relation-picker/components/skeletons/DropdownMenuSkeletonItem.tsx
@@ -5,19 +5,17 @@ import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';
import { themeCssVariables } from 'twenty-ui/theme';
const StyledDropdownMenuSkeletonContainer = styled.div`
--horizontal-padding: ${themeCssVariables.spacing[1]};
- --vertical-padding: ${themeCssVariables.spacing[2]};
border-radius: calc(
${themeCssVariables.border.radius.md} - ${themeCssVariables.spacing[1]}
);
box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
flex-shrink: 0;
-
- gap: ${themeCssVariables.spacing[2]};
-
height: ${themeCssVariables.spacing[8]};
+ justify-content: center;
padding-left: var(--horizontal-padding);
-
padding-right: var(--horizontal-padding);
`;
@@ -30,7 +28,6 @@ export const DropdownMenuSkeletonItem = ({
<StyledDropdownMenuSkeletonContainer>
<SkeletonLine
height={SKELETON_HEIGHT_SIZES.s}
- style={{ lineHeight: 0 }}
width={width}
baseColor={themeCssVariables.background.quaternary}
highlightColor={themeCssVariables.background.secondary}
diff --git a/packages/twenty-front/src/pages/auth/PasswordReset.tsx b/packages/twenty-front/src/pages/auth/PasswordReset.tsx
index df8fe6b000e..a9461f52206 100644
--- a/packages/twenty-front/src/pages/auth/PasswordReset.tsx
+++ b/packages/twenty-front/src/pages/auth/PasswordReset.tsx
@@ -222,12 +222,9 @@ export const PasswordReset = () => {
<StyledOnboardingContentContainer>
{!email ? (
<SkeletonLine
- borderRadius="0.25rem"
height={SKELETON_HEIGHT_SIZES.m}
count={2}
- style={{
- marginBottom: themeCssVariables.spacing[2],
- }}
+ gap={themeCssVariables.spacing[2]}
baseColor={themeCssVariables.background.quaternary}
highlightColor={themeCssVariables.background.secondary}
/>
diff --git a/packages/twenty-front/src/pages/settings/ai/SettingsSkillForm.tsx b/packages/twenty-front/src/pages/settings/ai/SettingsSkillForm.tsx
index 6e4985a0cab..fff723e0daa 100644
--- a/packages/twenty-front/src/pages/settings/ai/SettingsSkillForm.tsx
+++ b/packages/twenty-front/src/pages/settings/ai/SettingsSkillForm.tsx
@@ -9,7 +9,6 @@ import { useTheme } from 'twenty-ui/theme';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SettingsPageLayout } from '@/settings/components/layout/SettingsPageLayout';
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
-import { LEGACY_SKELETON_COLORS } from '@/ui/feedback/skeleton/constants/LEGACY_SKELETON_COLORS';
import { FindOneSkillDocument } from '~/generated-metadata/graphql';
import { SettingsSkillFormContent } from '~/pages/settings/ai/components/SettingsSkillFormContent';
import { useNavigateToNotFoundOnLoadFailure } from '~/pages/settings/ai/hooks/useNavigateToNotFoundOnLoadFailure';
@@ -55,12 +54,7 @@ export const SettingsSkillForm = ({ mode }: { mode: 'create' | 'edit' }) => {
>
<SettingsPageContainer>
<Section.Root>
- <SkeletonLine
- baseColor={LEGACY_SKELETON_COLORS.base}
- highlightColor={LEGACY_SKELETON_COLORS.highlight}
- height={400}
- borderRadius={4}
- />
+ <SkeletonLine height={400} />
</Section.Root>
</SettingsPageContainer>
</SettingsPageLayout>
diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTable.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTable.tsx
index ee83aed128f..7471a45bdd4 100644
--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTable.tsx
+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAgentSkillsTable.tsx
@@ -2,7 +2,6 @@ import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
-import { LEGACY_SKELETON_COLORS } from '@/ui/feedback/skeleton/constants/LEGACY_SKELETON_COLORS';
import { SortableTableHeader } from '@/ui/layout/table/components/SortableTableHeader';
import { Table } from '@/ui/layout/table/components/Table';
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
@@ -60,13 +59,7 @@ export const SettingsAgentSkillsTable = ({
</StyledTableHeaderRowContainer>
{showSkeleton
? Array.from({ length: 3 }).map((_, index) => (
- <SkeletonLine
- baseColor={LEGACY_SKELETON_COLORS.base}
- highlightColor={LEGACY_SKELETON_COLORS.highlight}
- height={32}
- borderRadius={4}
- key={index}
- />
+ <SkeletonLine height={32} key={index} />
))
: skills.map((skill) => (
<SettingsSkillTableRow