import type { Meta, StoryObj } from '@storybook/react-vite'
import { ArrowRight, ArrowUpRight, BookOpen, MapPin, MoreHorizontal, TrendingUp, Users } from 'lucide-react'
import { fn } from 'storybook/test'
import { Avatar, AvatarGroup } from './Avatar'
import { Badge } from './Badge'
import { Button, IconButton } from './Button'
import { Card } from './Card'
import { CARD_LAYOUTS, CARD_PADDINGS, CARD_VARIANTS } from './card.tokens'
import { PORTRAITS, landscape } from './display.fixtures'
const meta = {
title: 'Layout/Card',
component: Card,
subcomponents: {
'Card.Header': Card.Header,
'Card.Title': Card.Title,
'Card.Description': Card.Description,
'Card.Body': Card.Body,
'Card.Footer': Card.Footer,
'Card.Media': Card.Media,
},
tags: ['autodocs'],
parameters: {
docs: {
description: {
component:
'A surface that groups related content. Compose `Card.Media`, `Card.Header` (with `Card.Title`, `Card.Description` and an optional `action`), `Card.Body` and `Card.Footer`; the card spaces them by `padding`. `layout="horizontal"` puts the media beside the text. Pass `href` (or `render={}`) to make the whole card a link or button with a hover lift and focus ring. `headingLevel` fits the title into the page outline.',
},
},
},
argTypes: {
variant: { control: 'inline-radio', options: CARD_VARIANTS, table: { defaultValue: { summary: 'outline' } } },
padding: { control: 'inline-radio', options: CARD_PADDINGS, table: { defaultValue: { summary: 'md' } } },
layout: { control: 'inline-radio', options: CARD_LAYOUTS, table: { defaultValue: { summary: 'vertical' } } },
interactive: { control: 'boolean' },
href: { control: 'text' },
headingLevel: { control: 'inline-radio', options: [2, 3, 4, 5, 6], table: { defaultValue: { summary: '3' } } },
render: { control: false },
children: { control: false },
},
args: {
variant: 'outline',
padding: 'md',
layout: 'vertical',
headingLevel: 3,
},
} satisfies Meta
export default meta
type Story = StoryObj
const title = (s: string) => s[0].toUpperCase() + s.slice(1)
export const Playground: Story = {
render: (args) => (
Quarterly reviewAcme Corporation · Due 14 October
Collect the self-assessments from your team and schedule a 30-minute conversation with each person before the
end of the month.
),
}
export const Variants: Story = {
render: (args) => (
{CARD_VARIANTS.map((variant) => (
{title(variant)}
{variant === 'outline'
? 'A bordered surface for most content.'
: variant === 'elevated'
? 'A soft shadow lifts it off the page.'
: 'A quiet fill for secondary content.'}
Cards group related content and actions about a single subject.
))}
),
}
export const HorizontalMedia: Story = {
args: { layout: 'horizontal' },
render: (args) => (
Offsite
Team offsite in the Sintra hills12–14 November · 24 attending
Three days of planning, workshops and long walks. Travel and accommodation are booked; bring layers, the
evenings get cold.
} onClick={fn()}>
Details
),
}
export const VerticalMedia: Story = {
render: (args) => (
{[
{ t: 'Designing for dark mode', d: 'Five rules for surfaces, borders and text that hold up at night.', sky: '#fde68a', hills: '#d97706', tag: 'Guide' },
{ t: 'Accessible data tables', d: 'Captions, header scopes and sort state that screen readers announce.', sky: '#a7f3d0', hills: '#047857', tag: 'Article' },
].map((p) => (
{p.t}{p.d}
{p.tag}
6 min read
))}
),
}
export const InteractiveLink: Story = {
parameters: {
docs: {
description: {
story:
'With `href` the whole card is one link: it lifts on hover and shows a focus ring. Keep other interactive elements out of a link card. `render={}` makes a button card.',
},
},
},
render: (args) => (
Getting startedInstall the kit and render your first component.ThemingSwap palettes and switch to dark mode.}>
Invite your teamA button card that opens a dialog.