diff --git a/packages/ui/src/components/Card/Card.css.ts b/packages/ui/src/components/Card/Card.css.ts index dbefc9066e..effbb28e72 100644 --- a/packages/ui/src/components/Card/Card.css.ts +++ b/packages/ui/src/components/Card/Card.css.ts @@ -6,14 +6,10 @@ import { tokens } from '../../theme' const cardPadding = createVar() export const cardRoot = recipe({ - base: [ - yStack({ gap: 'md' }), - { - position: 'relative', - borderRadius: tokens.radius.xl, - padding: cardPadding, - }, - ], + base: { + position: 'relative', + padding: cardPadding, + }, variants: { variant: { primary: { @@ -28,17 +24,30 @@ export const cardRoot = recipe({ }, size: { - md: { - vars: { - [cardPadding]: tokens.space.lg, + md: [ + yStack({ gap: 'sm' }), + { + borderRadius: tokens.radius.md, + vars: { + [cardPadding]: tokens.space.md, + }, }, - }, + ], + lg: [ + yStack({ gap: 'md' }), + { + borderRadius: tokens.radius.xl, + vars: { + [cardPadding]: tokens.space.lg, + }, + }, + ], }, }, defaultVariants: { variant: 'primary', - size: 'md', + size: 'lg', }, }) diff --git a/packages/ui/src/components/Card/Card.stories.tsx b/packages/ui/src/components/Card/Card.stories.tsx index 02df90281d..0aaacac836 100644 --- a/packages/ui/src/components/Card/Card.stories.tsx +++ b/packages/ui/src/components/Card/Card.stories.tsx @@ -19,6 +19,10 @@ const meta: Meta = { options: ['primary', 'secondary'], control: { type: 'select' }, }, + size: { + options: ['md', 'lg'], + control: { type: 'radio' }, + }, }, parameters: { design: { @@ -35,7 +39,7 @@ type Story = StoryObj export const Default: Story = { render: (args: Controls) => (
- + @@ -57,13 +61,14 @@ export const Default: Story = { ), args: { variant: 'primary', + size: 'lg', }, } export const WithBadge: Story = { render: (args: Controls) => (
- + 20% @@ -83,13 +88,14 @@ export const WithBadge: Story = { ), args: { variant: 'primary', + size: 'lg', }, } export const WithoutAside: Story = { render: (args: Controls) => (
- + @@ -106,13 +112,14 @@ export const WithoutAside: Story = { ), args: { variant: 'primary', + size: 'lg', }, } export const WithoutPillow: Story = { render: (args: Controls) => (
- + Homeowner Insurance @@ -126,13 +133,14 @@ export const WithoutPillow: Story = { ), args: { variant: 'primary', + size: 'lg', }, } export const Secondary: Story = { render: (args: Controls) => (
- + @@ -151,5 +159,6 @@ export const Secondary: Story = { ), args: { variant: 'secondary', + size: 'md', }, } diff --git a/packages/ui/src/components/Card/Card.tsx b/packages/ui/src/components/Card/Card.tsx index 1e82dc3a97..d3b0fcdccb 100644 --- a/packages/ui/src/components/Card/Card.tsx +++ b/packages/ui/src/components/Card/Card.tsx @@ -1,20 +1,23 @@ import { Slot } from '@radix-ui/react-slot' import { type RecipeVariants } from '@vanilla-extract/recipes' import clsx from 'clsx' -import { type ComponentProps, type PropsWithChildren } from 'react' +import { forwardRef, type ComponentProps, type PropsWithChildren } from 'react' import { Heading } from '../Heading/Heading' import { Text } from '../Text/Text' import { cardAside, cardHeader, cardRoot } from './Card.css' type RootStyleProps = RecipeVariants type RootProps = ComponentProps<'article'> & RootStyleProps -function CardRoot({ variant, size, className, children, ...props }: RootProps) { +const CardRoot = forwardRef(function CardRoot( + { variant, size, className, children, ...props }: RootProps, + ref: RootProps['ref'], +) { return ( -
+
{children}
) -} +}) type HeaderProps = ComponentProps<'header'> function CardHeader({ className, children, ...props }: HeaderProps) {