Skip to content

Commit 50da678

Browse files
rorychattgithub-actions[bot]claude
authored
fix(card): improve density scaling for icons and spacing (#2596)
* fix(card): improve density scaling for icons and spacing - Add density-aware icon sizing in card headers (h-4/h-5/h-6 for small/medium/large) - Adjust header spacing for better visual harmony (small: pt-2 pb-1, large: pt-6) - Make content padding density-aware when no header is present Fixes #2593 Co-authored-by: Mikael Rinne <rorychatt@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: promote ivy ask alias for ivy question (#2594) --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Mikael Rinne <rorychatt@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8bca7a2 commit 50da678

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/frontend/src/widgets/card/CardWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const CardWidget: React.FC<CardWidgetProps> = ({
8686
className={cn(
8787
cardStyles.content.base,
8888
sizeClasses.content,
89-
headerIsEmpty && cardStyles.content.noHeader
89+
headerIsEmpty && sizeClasses.contentNoHeader
9090
)}
9191
>
9292
{slots?.Content}

src/frontend/src/widgets/card/styles.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Densities } from '@/types/density';
33
interface CardSizeClasses {
44
header: string;
55
content: string;
6+
contentNoHeader: string;
67
footer: string;
78
title: string;
89
description: string;
@@ -12,6 +13,12 @@ interface CardSizeClasses {
1213
const baseHeaderClasses =
1314
'items-center [&>*]:w-full [&>*]:min-w-0 [&_:is(p,span)]:!pt-1 [&_:is(h1,h2,h3,h4,h5,h6)]:!my-0 [&_:is(h1,h2,h3,h4,h5,h6)]:!font-normal [&_:is(h1,h2,h3,h4,h5,h6)]:!min-h-9 [&_:is(h1,h2,h3,h4,h5,h6)]:!leading-9 [&_:is(h1,h2,h3,h4,h5,h6)]:!items-center [&_:is(h1,h2,h3,h4,h5,h6)]:!min-w-0 [&_:is(h1,h2,h3,h4,h5,h6)]:!truncate';
1415

16+
const iconSizeClasses = {
17+
small: '[&_svg]:!h-4 [&_svg]:!w-4 [&_svg]:!min-h-4 [&_svg]:!min-w-4',
18+
medium: '[&_svg]:!h-5 [&_svg]:!w-5 [&_svg]:!min-h-5 [&_svg]:!min-w-5',
19+
large: '[&_svg]:!h-6 [&_svg]:!w-6 [&_svg]:!min-h-6 [&_svg]:!min-w-6',
20+
};
21+
1522
const baseContentClasses = 'break-words whitespace-normal';
1623

1724
export const cardStyles = {
@@ -23,7 +30,6 @@ export const cardStyles = {
2330

2431
content: {
2532
base: 'flex-1',
26-
noHeader: 'pt-6',
2733
},
2834

2935
footer: {
@@ -42,26 +48,29 @@ export const getSizeClasses = (density?: Densities): CardSizeClasses => {
4248
switch (density) {
4349
case Densities.Small:
4450
return {
45-
header: `px-3 pt-1 pb-0 ${baseHeaderClasses} [&_:is(h1,h2,h3,h4,h5,h6)]:!text-sm`,
51+
header: `px-3 pt-2 pb-1 ${baseHeaderClasses} ${iconSizeClasses.small} [&_:is(h1,h2,h3,h4,h5,h6)]:!text-sm [&_:is(h1,h2,h3,h4,h5,h6)]:!min-h-6 [&_:is(h1,h2,h3,h4,h5,h6)]:!leading-6`,
4652
content: `p-3 pt-0 [&_*]:!text-sm ${baseContentClasses}`,
53+
contentNoHeader: 'pt-3',
4754
footer: 'p-3 pt-0',
4855
title: 'text-sm',
4956
description: 'text-xs mt-1',
5057
icon: 'h-4 w-4',
5158
};
5259
case Densities.Large:
5360
return {
54-
header: `px-8 pt-5 pb-4 ${baseHeaderClasses} [&_:is(h1,h2,h3,h4,h5,h6)]:!text-lg`,
61+
header: `px-8 pt-6 pb-4 ${baseHeaderClasses} ${iconSizeClasses.large} [&_:is(h1,h2,h3,h4,h5,h6)]:!text-lg`,
5562
content: `p-8 pt-0 ${baseContentClasses}`,
63+
contentNoHeader: 'pt-8',
5664
footer: 'p-8 pt-0',
5765
title: 'text-lg',
5866
description: 'text-base mt-3',
5967
icon: 'h-6 w-6',
6068
};
6169
default:
6270
return {
63-
header: `px-6 pt-4 pb-2 ${baseHeaderClasses} [&_:is(h1,h2,h3,h4,h5,h6,p)]:!text-base`,
71+
header: `px-6 pt-4 pb-2 ${baseHeaderClasses} ${iconSizeClasses.medium} [&_:is(h1,h2,h3,h4,h5,h6,p)]:!text-base`,
6472
content: `p-6 pt-0 ${baseContentClasses}`,
73+
contentNoHeader: 'pt-6',
6574
footer: 'p-6 pt-0',
6675
title: 'text-base',
6776
description: 'text-sm',

0 commit comments

Comments
 (0)