Skip to content

Commit 7bc855e

Browse files
committed
chore: add optional imageWidth prop to CardList
1 parent 84bc3ed commit 7bc855e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/CardList.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type CardListItem = {
2424
link?: string
2525
id?: string
2626
image?: ImageProps["src"]
27+
imageWidth?: number
2728
alt?: string
2829
}
2930

@@ -51,6 +52,7 @@ const Card = ({
5152
caption,
5253
link,
5354
image,
55+
imageWidth = 20, // Set 20px as default image width, can be overrided if needed
5456
alt,
5557
...props
5658
}: CardProps) => {
@@ -62,7 +64,7 @@ const Card = ({
6264

6365
return (
6466
<CardContainer {...props}>
65-
{image && <Image src={image} alt={alt ?? ""} width={24} />}
67+
{image && <Image src={image} alt={alt ?? ""} width={imageWidth} />}
6668
<Flex flex="1 1 75%" direction="column">
6769
{isLink ? (
6870
<LinkOverlay
@@ -97,11 +99,13 @@ const Card = ({
9799

98100
export type CardListProps = BoxProps & {
99101
items: CardProps[]
102+
imageWidth?: number
100103
clickHandler?: (idx: string | number) => void
101104
}
102105

103106
const CardList = ({
104107
items,
108+
imageWidth,
105109
clickHandler = () => null,
106110
...props
107111
}: CardListProps) => (
@@ -112,7 +116,7 @@ const CardList = ({
112116

113117
return isLink ? (
114118
<LinkBox key={id || idx}>
115-
<Card {...listItem} />
119+
<Card {...listItem} imageWidth={imageWidth} />
116120
</LinkBox>
117121
) : (
118122
<Card

0 commit comments

Comments
 (0)