// // Copyright 2025 DXOS.org // import { type Meta, type StoryObj } from '@storybook/react-vite'; import React, { useRef } from 'react'; import { random } from '@dxos/random'; import { Icon, IconButton } from '@dxos/react-ui'; import { withLayout, withTheme } from '@dxos/react-ui/testing'; import { Card } from './Card'; random.seed(0); type StoryArgs = { title: string; description?: string; image?: string; fullWidth?: boolean; }; const DefaultStory = ({ title, description, image, fullWidth }: StoryArgs) => { const handleRef = useRef(null); console.log(title); return ( {title} console.log('close')} /> Card.Text (default) Card.Text (description)
{description}
console.log('action')} />
); }; const meta = { title: 'ui/react-ui-core/components/Card', render: DefaultStory, decorators: [ withTheme(), withLayout({ layout: 'centered', classNames: 'grid w-[30rem] place-items-center bg-transparent', }), ], } satisfies Meta; export default meta; type Story = StoryObj; const image = random.image.url(); export const Default: Story = { args: { title: random.commerce.productName(), description: random.lorem.paragraph(3), image, }, }; export const FullWidth: Story = { args: { title: random.commerce.productName(), description: random.lorem.paragraph(3), image, fullWidth: true, }, }; export const Simple: Story = { args: { title: random.commerce.productName(), }, render: ({ title }) => { const handleRef = useRef(null); return ( {title} console.log('close')} /> ); }, }; export const Section: Story = { args: { title: random.commerce.productName(), }, render: ({ title }) => { const handleRef = useRef(null); return ( {title} console.log('close')} /> console.log('1')} /> console.log('2')} /> console.log('3')} /> ); }, }; export const Description: Story = { args: { title: random.commerce.productName(), description: random.lorem.paragraph(3), }, render: ({ title, description }) => { const handleRef = useRef(null); return ( {title} console.log('close')} /> {description} ); }, }; export const Slots: Story = { args: { title: random.commerce.productName(), }, render: ({ title }) => { const showLeading = true; return ( {title} console.log('close')} /> {/* Leading passive icon. */} Start slot — passive Icon {/* Passive icon + trailing IconButton: the two gutters align to the pixel. */} Start Icon + end IconButton (aligned) {}} /> {/* Conditional leading slot: when falsy, content stays in the center track. */} {showLeading && ( )} Conditional start slot {/* asChild: the anchor itself becomes the trailing gutter cell. */} Trailing link via asChild ); }, };