Skip to content

Commit 8f39c25

Browse files
authored
Feature/product card improvements (#490)
* feat: enhance ProductCard component with new layout adjustments * chore: add changeset for ProductCard layout enhancements
1 parent e3043ff commit 8f39c25

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

.changeset/dry-rockets-kick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@o2s/ui': minor
3+
---
4+
5+
feat: enhance ProductCard component with new layout adjustments

packages/ui/src/components/Cards/ProductCard/ProductCard.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ export const WithoutAction: Story = {
120120
},
121121
};
122122

123+
export const WithoutActionAndLink: Story = {
124+
args: {
125+
...Default.args,
126+
action: undefined,
127+
link: undefined,
128+
},
129+
};
130+
123131
export const WithCustomAction: Story = {
124132
args: {
125133
...Default.args,

packages/ui/src/components/Cards/ProductCard/ProductCard.tsx

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export const ProductCard: React.FC<ProductCardProps> = ({
2727
return (
2828
<div className={cn('flex flex-col bg-card rounded-lg border border-border shadow-sm relative w-full h-full')}>
2929
{/* Image section */}
30-
<div className="relative overflow-hidden h-[180px] flex-shrink-0 rounded-t-lg">
31-
{image?.url && image?.alt && (
30+
{image?.url && image?.alt && (
31+
<div className="relative overflow-hidden h-[180px] shrink-0 rounded-t-lg">
3232
<Image
3333
src={image.url}
3434
alt={image.alt}
@@ -37,8 +37,8 @@ export const ProductCard: React.FC<ProductCardProps> = ({
3737
className="object-cover object-center"
3838
priority={image.priority}
3939
/>
40-
)}
41-
</div>
40+
</div>
41+
)}
4242
<div className="p-6 flex flex-col gap-6 h-full">
4343
{/* Content section */}
4444
<div className="flex flex-col h-full">
@@ -48,7 +48,12 @@ export const ProductCard: React.FC<ProductCardProps> = ({
4848
</Typography>
4949

5050
{tags && tags.length > 0 && (
51-
<ul className="flex flex-wrap gap-2 absolute top-[165px] left-6">
51+
<ul
52+
className={cn(
53+
'flex flex-wrap gap-2',
54+
image?.url && image?.alt && 'absolute top-[165px] left-6',
55+
)}
56+
>
5257
{tags.map((tag) => (
5358
<li key={tag.label}>
5459
<Badge variant={tag.variant}>{tag.label}</Badge>
@@ -67,26 +72,32 @@ export const ProductCard: React.FC<ProductCardProps> = ({
6772
<Separator />
6873

6974
{/* Footer section */}
70-
<div className="flex items-start sm:items-center justify-between gap-4 sm:flex-row flex-col w-full">
71-
<Typography variant="highlightedSmall" className="w-full">
72-
<Price price={price} />
73-
</Typography>
75+
<div className="flex items-start sm:items-center justify-between gap-6 sm:flex-row flex-col w-full">
76+
<div className="flex flex-row gap-2 w-full sm:justify-start justify-between items-center">
77+
<Typography variant="highlightedSmall" className="shrink-0">
78+
<Price price={price} />
79+
</Typography>
7480

75-
<div className="flex sm:items-center gap-4 sm:flex-row flex-col w-full justify-end">
7681
{status && (
77-
<Badge key={status.label} variant={status.variant} className="w-fit">
78-
{status.label}
79-
</Badge>
82+
<div className="">
83+
<Badge key={status.label} variant={status.variant} className="w-fit">
84+
{status.label}
85+
</Badge>
86+
</div>
8087
)}
88+
</div>
8189

82-
{action}
90+
{(action || link) && (
91+
<div className="flex sm:items-center gap-4 sm:flex-row flex-col w-full justify-end">
92+
{action}
8393

84-
{link && (
85-
<Link asChild variant="primary" size="default">
86-
<LinkComponent href={link.url}>{link.label}</LinkComponent>
87-
</Link>
88-
)}
89-
</div>
94+
{link && (
95+
<Link asChild variant="primary" size="default">
96+
<LinkComponent href={link.url}>{link.label}</LinkComponent>
97+
</Link>
98+
)}
99+
</div>
100+
)}
90101
</div>
91102
</div>
92103
</div>

0 commit comments

Comments
 (0)