Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit 27dc342

Browse files
authored
Merge pull request #100 from inkonchain/feat/card-size
feat: remove card's rounded in favor of size rounding scaling
2 parents 954a83a + 584fe08 commit 27dc342

File tree

4 files changed

+92
-17
lines changed

4 files changed

+92
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inkonchain/ink-kit",
3-
"version": "0.8.0",
3+
"version": "0.8.2",
44
"description": "",
55
"main": "dist/index.cjs.js",
66
"module": "dist/index.es.js",

src/components/Card/Card.stories.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,59 @@ export const LargeCardInfo: Story = {
264264
),
265265
},
266266
};
267+
268+
export const FullCard: Story = {
269+
args: {
270+
size: "noPadding",
271+
image: (
272+
<CardContent.Image>
273+
<img
274+
src="https://picsum.photos/1024/576"
275+
alt="Card Image"
276+
width={1024}
277+
height={580}
278+
/>
279+
</CardContent.Image>
280+
),
281+
},
282+
};
283+
284+
export const FullCardWithImageOnTheRight: Story = {
285+
args: {
286+
size: "noPadding",
287+
imageLocation: "right",
288+
image: (
289+
<CardContent.Image>
290+
<img
291+
src="https://picsum.photos/1024/576"
292+
alt="Card Image"
293+
width={1024}
294+
height={580}
295+
/>
296+
</CardContent.Image>
297+
),
298+
},
299+
};
300+
301+
export const CardWithSmallImage: Story = {
302+
args: {
303+
size: "small",
304+
children: (
305+
<TitleAndDescription
306+
title="Card with small image"
307+
description="This is a card with a small image."
308+
size="small"
309+
/>
310+
),
311+
image: (
312+
<CardContent.Image variant="square">
313+
<img
314+
src="https://picsum.photos/1024/576"
315+
alt="Card Image"
316+
width={128}
317+
height={128}
318+
/>
319+
</CardContent.Image>
320+
),
321+
},
322+
};

src/components/Card/Card.tsx

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ export interface CardProps extends VariantProps<typeof cardVariants> {
1414
const cardVariants = cva(
1515
`
1616
ink:grid ink:grid-cols-1
17-
ink:p-2 ink:pb-3 ink:sm:p-3 ink:gap-3
17+
ink:gap-3
1818
ink:relative
1919
ink:bg-background-container
2020
ink:font-default
2121
ink:box-border
22+
ink:overflow-hidden
2223
`,
2324
{
2425
variants: {
@@ -36,10 +37,10 @@ ink:box-border
3637
true: "ink:cursor-pointer",
3738
false: "",
3839
},
39-
rounded: {
40-
lg: "ink:rounded-lg",
41-
xl: "ink:rounded-xl",
42-
xxl: "ink:rounded-xxl",
40+
size: {
41+
noPadding: "ink:rounded-lg",
42+
small: "ink:p-2 ink:pb-3 ink:sm:p-3 ink:rounded-lg",
43+
default: "ink:p-2 ink:pb-3 ink:sm:p-3 ink:rounded-xl",
4344
},
4445
},
4546
compoundVariants: [
@@ -48,9 +49,14 @@ ink:box-border
4849
clickable: true,
4950
className: "ink:hover:bg-button-secondary-hover",
5051
},
52+
{
53+
size: "small",
54+
imageLocation: "left",
55+
className: "ink:grid-cols-[128px_1fr] ink:sm:grid-cols-[128px_1fr]",
56+
},
5157
],
5258
defaultVariants: {
53-
rounded: "xl",
59+
size: "default",
5460
},
5561
}
5662
);
@@ -63,18 +69,17 @@ export const Card: React.FC<CardProps> = ({
6369
asChild,
6470
variant,
6571
clickable,
66-
rounded,
72+
size,
6773
}) => {
6874
const Component = asChild ? Slot : "div";
69-
const roundedValue = rounded || (image ? "xxl" : "lg");
7075
return (
7176
<Component
7277
className={classNames(
7378
cardVariants({
7479
variant,
7580
imageLocation: image ? imageLocation : undefined,
7681
clickable,
77-
rounded: roundedValue,
82+
size: size || (image ? "default" : "small"),
7883
className,
7984
}),
8085
className
@@ -89,10 +94,10 @@ export const Card: React.FC<CardProps> = ({
8994
variant === "light-purple"
9095
? "var(--ink-background-light)"
9196
: "var(--ink-text-muted)",
92-
"--ink-card-rounded": variantClassNames(roundedValue, {
93-
lg: "var(--ink-base-radius-sm)",
94-
xl: "var(--ink-base-radius-lg)",
95-
xxl: "var(--ink-base-radius-xl)",
97+
"--ink-card-rounded": variantClassNames(size || "default", {
98+
noPadding: "",
99+
small: "var(--ink-base-radius-sm)",
100+
default: "var(--ink-base-radius-lg)",
96101
}),
97102
} as React.CSSProperties
98103
}
@@ -103,10 +108,17 @@ export const Card: React.FC<CardProps> = ({
103108
{image}
104109
<div
105110
className={classNames(
106-
"ink:flex ink:flex-col ink:gap-2 ink:sm:gap-6 ink:text-text-default ink:box-border",
111+
"ink:flex ink:flex-col ink:gap-2 ink:sm:gap-6 ink:justify-center",
112+
"ink:text-text-default ink:box-border",
107113
!!image && "ink:p-2 ink:sm:p-3",
108114
imageLocation === "right" && "ink:sm:-order-1",
109-
imageLocation !== "top" && !!image && "ink:sm:py-[100px]"
115+
imageLocation !== "top" &&
116+
!!image &&
117+
variantClassNames(size || "default", {
118+
default: "ink:sm:py-[100px]",
119+
noPadding: "ink:sm:py-[100px]",
120+
small: "",
121+
})
110122
)}
111123
>
112124
{child}

src/components/Card/Content/Image.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { classNames } from "../../../util/classes";
33
import { Slot } from "../../Slot";
44

55
export interface ImageProps extends React.PropsWithChildren {
6+
variant?: "default" | "square";
67
className?: string;
78
mainLabels?: React.ReactNode;
89
secondaryLabels?: React.ReactNode;
910
}
1011

1112
export const Image: React.FC<ImageProps> = ({
1213
className,
14+
variant,
1315
mainLabels,
1416
secondaryLabels,
1517
children,
@@ -40,7 +42,12 @@ export const Image: React.FC<ImageProps> = ({
4042
)}
4143
</div>
4244
)}
43-
<Slot className="ink:object-cover ink:object-center ink:w-full ink:h-full">
45+
<Slot
46+
className={classNames(
47+
"ink:object-cover ink:object-center ink:w-full ink:h-full",
48+
variant === "square" && "ink:aspect-square"
49+
)}
50+
>
4451
{children}
4552
</Slot>
4653
</div>

0 commit comments

Comments
 (0)