Skip to content

Commit d945a42

Browse files
committed
chore(Card): update to 5.0.0
1 parent 2c177d2 commit d945a42

1 file changed

Lines changed: 13 additions & 25 deletions

File tree

src/Card/Card.tsx

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import clsx from 'clsx'
33
import { twMerge } from 'tailwind-merge'
44

5-
import { IComponentBaseProps, ComponentSize } from '../types'
5+
import { IComponentBaseProps, ComponentSize, ComponentVariant } from '../types'
66

77
import CardActions, { CardActionsProps as ActionProps } from './CardActions'
88
import CardBody, { CardBodyProps as BodyProps } from './CardBody'
@@ -16,13 +16,12 @@ export type CardImageProps = ImageProps
1616

1717
export type CardProps = React.HTMLAttributes<HTMLDivElement> &
1818
IComponentBaseProps & {
19-
bordered?: boolean
19+
size?: ComponentSize
20+
border?: boolean
21+
variant?: Omit<ComponentVariant, 'soft'> | 'border'
2022
imageFull?: boolean
2123

22-
// responsive props
23-
normal?: ComponentSize | boolean // Applies default paddings
24-
compact?: ComponentSize | boolean // Applies smaller padding
25-
side?: ComponentSize | boolean // The image in <figure> will be on to the side
24+
side?: ComponentSize | boolean
2625
}
2726

2827
interface ModifierMap {
@@ -32,20 +31,6 @@ interface ModifierMap {
3231
}
3332

3433
const DYNAMIC_MODIFIERS: ModifierMap = {
35-
compact: {
36-
true: 'card-compact',
37-
xs: 'xs:card-compact',
38-
sm: 'sm:card-compact',
39-
md: 'md:card-compact',
40-
lg: 'lg:card-compact',
41-
},
42-
normal: {
43-
true: 'card-normal',
44-
xs: 'xs:card-normal',
45-
sm: 'sm:card-normal',
46-
md: 'md:card-normal',
47-
lg: 'lg:card-normal',
48-
},
4934
side: {
5035
true: 'card-side',
5136
xs: 'xs:card-side',
@@ -57,18 +42,21 @@ const DYNAMIC_MODIFIERS: ModifierMap = {
5742

5843
const Card = React.forwardRef<HTMLDivElement, CardProps>(
5944
(
60-
{ bordered = true, imageFull, normal, compact, side, className, ...props },
45+
{ size, border = true, variant, imageFull, side, className, ...props },
6146
ref
6247
): JSX.Element => {
6348
const classes = twMerge(
6449
'card',
6550
className,
6651
clsx({
67-
'card-bordered': bordered,
52+
'card-xl': size === 'xl',
53+
'card-lg': size === 'lg',
54+
'card-md': size === 'md',
55+
'card-sm': size === 'sm',
56+
'card-xs': size === 'xs',
57+
'card-dash': variant === 'dash',
58+
'card-border': border || variant === 'outline' || variant == 'border',
6859
'image-full': imageFull,
69-
[(compact && DYNAMIC_MODIFIERS.compact[compact.toString()]) || '']:
70-
compact,
71-
[(normal && DYNAMIC_MODIFIERS.normal[normal.toString()]) || '']: normal,
7260
[(side && DYNAMIC_MODIFIERS.side[side.toString()]) || '']: side,
7361
})
7462
)

0 commit comments

Comments
 (0)