Skip to content

Commit 55ad437

Browse files
author
Roman Snapko
authored
Make OverviewCard props optional and styles update (#2166)
<!-- Ensure the title clearly reflects what was changed. Provide a clear and concise description of the changes made. The PR should only contain the changes related to the issue, and no other unrelated changes. --> Fixes OPS-3930
1 parent dcaff09 commit 55ad437

2 files changed

Lines changed: 51 additions & 6 deletions

File tree

packages/ui-components/src/components/overview-card/overview-card.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ type OverviewCardProps = {
55
title: string;
66
icon: ReactNode;
77
value: string | number;
8-
bottomLineText: string;
9-
onClick: () => void;
8+
bottomLineText?: string;
9+
onClick?: () => void;
1010
iconWrapperClassName?: string;
11+
titleClassName?: string;
1112
className?: string;
1213
};
1314

@@ -18,28 +19,36 @@ const OverviewCard = ({
1819
bottomLineText,
1920
onClick,
2021
iconWrapperClassName,
22+
titleClassName,
2123
className,
2224
}: OverviewCardProps) => (
2325
<div
2426
className={cn(
25-
'w-full h-full p-[22px] flex flex-col gap-4 bg-background border rounded-2xl shadow-template cursor-pointer',
27+
'w-full h-full p-[22px] flex flex-col gap-4 bg-background border rounded-2xl shadow-template',
28+
{ 'cursor-pointer': !!onClick },
2629
className,
2730
)}
2831
onClick={onClick}
2932
>
3033
<div className="flex items-center gap-[9px]">
3134
<div
3235
className={cn(
33-
'size-10 flex items-center justify-center rounded-full font-bold text-base text-background bg-blue-400',
36+
'size-10 shrink-0 flex items-center justify-center rounded-full font-bold text-base text-background bg-blue-400',
3437
iconWrapperClassName,
3538
)}
3639
>
3740
{icon}
3841
</div>
39-
<span className="font-bold text-base text-foreground">{title}</span>
42+
<span
43+
className={cn('text-[14px] font-bold text-foreground', titleClassName)}
44+
>
45+
{title}
46+
</span>
4047
</div>
4148
<p className="font-bold text-[32px]/[32px] text-foreground">{value}</p>
42-
<p className="font-normal text-sm text-gray-400">{bottomLineText}</p>
49+
{bottomLineText && (
50+
<p className="font-normal text-sm text-gray-400">{bottomLineText}</p>
51+
)}
4352
</div>
4453
);
4554

packages/ui-components/src/stories/overview-card/overview-card.stories.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,39 @@ type Story = StoryObj<typeof meta>;
3131
* The default card displaying one item.
3232
*/
3333
export const Default: Story = {};
34+
35+
/**
36+
* Card without a bottom line text.
37+
*/
38+
export const WithoutBottomLineText: Story = {
39+
args: {
40+
bottomLineText: undefined,
41+
},
42+
};
43+
44+
/**
45+
* Card without an onClick handler — no pointer cursor is shown.
46+
*/
47+
export const NonClickable: Story = {
48+
args: {
49+
onClick: undefined,
50+
},
51+
};
52+
53+
/**
54+
* Card with a custom title class name.
55+
*/
56+
export const CustomTitleClassName: Story = {
57+
args: {
58+
titleClassName: 'text-blue-400',
59+
},
60+
};
61+
62+
/**
63+
* Card with a custom icon wrapper class name.
64+
*/
65+
export const CustomIconWrapperClassName: Story = {
66+
args: {
67+
iconWrapperClassName: 'bg-green-400',
68+
},
69+
};

0 commit comments

Comments
 (0)