Skip to content

Commit 045c35f

Browse files
committed
feat(components): add border option for Card component
1 parent cbc8111 commit 045c35f

File tree

1 file changed

+13
-4
lines changed
  • packages/components/src/components/Card

1 file changed

+13
-4
lines changed

packages/components/src/components/Card/Card.tsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ export const allowedCardFrameProps = [
3434
] as const satisfies FramePropsKeys[];
3535
type AllowedFrameProps = Pick<FrameProps, (typeof allowedCardFrameProps)[number]>;
3636

37-
const Container = styled.div<{ $fillType: FillType } & TransientProps<AllowedFrameProps>>`
37+
const Container = styled.div<
38+
{ $fillType: FillType; $border?: string } & TransientProps<AllowedFrameProps>
39+
>`
3840
width: 100%;
3941
border-radius: ${borders.radii.md};
4042
background: ${({ theme, $fillType }) =>
4143
$fillType !== 'none' && theme.backgroundTertiaryDefaultOnElevation0};
4244
padding: ${spacingsPx.xxxs};
43-
45+
border: ${({ $border }) => $border || 'none'};
4446
${withFrameProps}
4547
`;
4648

@@ -57,6 +59,7 @@ const CardContainer = styled.div<
5759
$isClickable: boolean;
5860
$variant?: CardVariant;
5961
$hasLabel: boolean;
62+
$border?: string;
6063
} & TransientProps<AllowedFrameProps>
6164
>`
6265
width: 100%;
@@ -65,6 +68,7 @@ const CardContainer = styled.div<
6568
position: relative;
6669
padding: ${mapPaddingTypeToPadding};
6770
border-radius: ${borders.radii.md};
71+
border: ${({ $border }) => $border || 'none'};
6872
transition:
6973
background 0.3s,
7074
box-shadow 0.2s,
@@ -103,6 +107,7 @@ type CommonCardProps = AccessibilityProps & {
103107
label?: ReactNode;
104108
variant?: CardVariant;
105109
'data-testid'?: string;
110+
border?: string;
106111
};
107112

108113
export type CardPropsWithTransientProps = CommonCardProps & TransientProps<AllowedFrameProps>;
@@ -122,6 +127,7 @@ const CardComponent = forwardRef<HTMLDivElement, CardPropsWithTransientProps>(
122127
label,
123128
variant,
124129
'data-testid': dataTest,
130+
border,
125131
...rest
126132
},
127133
ref,
@@ -137,6 +143,7 @@ const CardComponent = forwardRef<HTMLDivElement, CardPropsWithTransientProps>(
137143
$isClickable={Boolean(onClick)}
138144
$variant={variant}
139145
$hasLabel={Boolean(label)}
146+
$border={border}
140147
onClick={onClick}
141148
onMouseEnter={onMouseEnter}
142149
className={className}
@@ -165,6 +172,7 @@ export const Card = forwardRef<HTMLDivElement, CardProps>(
165172
children,
166173
variant,
167174
'data-testid': dataTest,
175+
border,
168176
...rest
169177
},
170178
ref,
@@ -181,16 +189,17 @@ export const Card = forwardRef<HTMLDivElement, CardProps>(
181189
label,
182190
variant,
183191
'data-testid': dataTest,
192+
border,
184193
};
185194
const frameProps = pickAndPrepareFrameProps(rest, allowedCardFrameProps);
186195

187196
return label ? (
188-
<Container $fillType={fillType} {...frameProps}>
197+
<Container $fillType={fillType} {...frameProps} $border={border}>
189198
<LabelContainer $paddingType={paddingType}>{label}</LabelContainer>
190199
<CardComponent {...commonProps} ref={ref} />
191200
</Container>
192201
) : (
193-
<CardComponent {...commonProps} {...frameProps} ref={ref} />
202+
<CardComponent {...commonProps} {...frameProps} border={border} ref={ref} />
194203
);
195204
},
196205
);

0 commit comments

Comments
 (0)