Skip to content

Commit dc94487

Browse files
committed
✨ Add ability to select card body through prop
1 parent 3be1540 commit dc94487

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/components/Card/Card.astro

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
titleTag = 'span',
1212
compact,
1313
className,
14+
bodyClassName,
1415
secondary,
1516
...rest
1617
} = Astro.props
@@ -19,7 +20,13 @@ const classes = [
1920
styles.card,
2021
secondary && styles.secondary,
2122
className
22-
].filter(Boolean).join(' ')
23+
]
24+
25+
const bodyClasses = [
26+
styles.body,
27+
compact && styles.compact,
28+
bodyClassName
29+
]
2330
2431
const Component = element
2532
const Title = titleTag
@@ -29,7 +36,7 @@ const Title = titleTag
2936
{title && (
3037
<Title class:list={styles.title}>{title}</Title>
3138
)}
32-
<div class:list={[styles.body, compact && styles.compact]}>
39+
<div class:list={bodyClasses}>
3340
<slot />
3441
</div>
3542
</Component>

src/components/Card/Card.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
export let titleTag: CardProps['titleTag'] = 'span'
1111
export let compact: CardProps['compact'] = false
1212
export let className: CardProps['className'] = ''
13+
export let bodyClassName: CardProps['bodyClassName'] = ''
1314
export let secondary: CardProps['secondary'] = false
1415
1516
const classes = classNames([
@@ -20,7 +21,8 @@
2021
2122
const bodyClasses = classNames([
2223
styles.body,
23-
compact && styles.compact
24+
compact && styles.compact,
25+
bodyClassName
2426
])
2527
</script>
2628

src/components/Card/Card.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Card = ({
1111
TitleTag = 'span',
1212
compact,
1313
className,
14+
bodyClassName,
1415
secondary,
1516
children,
1617
...rest
@@ -23,7 +24,8 @@ const Card = ({
2324

2425
const bodyClasses = classNames([
2526
styles.body,
26-
compact && styles.compact
27+
compact && styles.compact,
28+
bodyClassName
2729
])
2830

2931
return (

src/components/Card/card.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type CardProps = {
44
titleTag?: string
55
compact?: boolean
66
className?: string
7+
bodyClassName?: string
78
secondary?: boolean
89
[key: string]: any
910
}

0 commit comments

Comments
 (0)