Skip to content

Commit b1925cd

Browse files
committed
feat: enhance SummaryCard with configurable description lines and loading skeletons
- Introduced a new `descriptionLines` prop to the SummaryCard component, allowing users to specify the number of lines for the description text, which applies to both the content and loading skeleton. - Updated CSS to support dynamic line clamping based on the new prop, improving layout consistency during loading states. - Added a fade-in animation for loading skeletons to enhance user experience during content transitions. - Implemented new skeleton image containers with aspect ratios to prevent layout shifts, ensuring a smoother loading experience. - Expanded Storybook examples to demonstrate the new features and their impact on layout stability. These updates improve the flexibility and visual consistency of the SummaryCard component, particularly in loading scenarios.
1 parent 90284d9 commit b1925cd

File tree

5 files changed

+766
-14
lines changed

5 files changed

+766
-14
lines changed

packages/ui/src/components/Card/SummaryCard.module.css

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,10 @@
234234
color: var(--ai-color-text-secondary);
235235
margin: 0; /* Remove default browser margin */
236236

237-
/* Clamp to 2 lines with ellipsis */
237+
/* Clamp to configurable number of lines with ellipsis */
238238
display: -webkit-box;
239-
-webkit-line-clamp: 2;
239+
-webkit-line-clamp: var(--description-lines, 2);
240+
line-clamp: var(--description-lines, 2);
240241
-webkit-box-orient: vertical;
241242
overflow: hidden;
242243
}
@@ -294,6 +295,36 @@
294295
display: flex;
295296
flex-direction: column;
296297
gap: var(--ai-spacing-8); /* 16px gap between major sections - same as card */
298+
animation: fadeInSkeleton 500ms ease-out forwards;
299+
animation-delay: 100ms; /* Prevents flash on fast loads */
300+
}
301+
302+
@keyframes fadeInSkeleton {
303+
0%, 50% { opacity: 0; }
304+
100% { opacity: 1; }
305+
}
306+
307+
/* Skeleton image containers with aspect-ratio to prevent layout shift */
308+
.skeletonImageContainer {
309+
width: 100%;
310+
border-radius: 16px;
311+
overflow: hidden;
312+
}
313+
314+
.skeletonImageContainer[data-aspect='auto'] {
315+
height: 244px;
316+
}
317+
318+
.skeletonImageContainer[data-aspect='16/9'] {
319+
aspect-ratio: 16 / 9;
320+
}
321+
322+
.skeletonImageContainer[data-aspect='4/3'] {
323+
aspect-ratio: 4 / 3;
324+
}
325+
326+
.skeletonImageContainer[data-aspect='1/1'] {
327+
aspect-ratio: 1 / 1;
297328
}
298329

299330
/* Empty State */

packages/ui/src/components/Card/SummaryCard.module.css.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ declare const styles: {
1818
readonly button: string;
1919
readonly overflowIndicator: string;
2020
readonly loadingContainer: string;
21+
readonly skeletonImageContainer: string;
2122
readonly visuallyHidden: string;
2223
readonly errorContainer: string;
2324
readonly emptyContainer: string;

0 commit comments

Comments
 (0)