import { Meta, StoryObj } from '@storybook/react-webpack5'; import { FastFlag as FastFlagIcon } from '@transferwise/icons'; import { useState } from 'react'; import { fn } from 'storybook/test'; import Card from '.'; type Story = StoryObj; /** * ⚠️ This component is **deprecated** and superseded by the [new ListItem component](?path=/docs/content-listitem--docs). * * @see https://transferwise.atlassian.net/wiki/spaces/DS/pages/2387314550/Instructions+for+killing+expanding+cards+on+web+design+pattern */ const meta: Meta = { component: Card, title: 'Layouts/Card', tags: ['deprecated'], args: { title: 'A card', details: 'Some details about this card', children: 'Lorem ipsum dolor sit amet.', onClick: fn(), as: 'div', }, }; export default meta; export const Basic: Story = { render: function Render(args) { const [isExpanded, setIsExpanded] = useState(false); const handleClick = (isCurrentExpanded: boolean) => { setIsExpanded(isCurrentExpanded); args?.onClick?.(!isExpanded); }; return ; }, }; export const Multiple: Story = { render: function Render(args) { const [expandedCardIndex, setExpandedCardIndex] = useState(0); const handleOnCardClick = (index: number) => { args?.onClick?.(index !== expandedCardIndex); setExpandedCardIndex(index !== expandedCardIndex ? index : null); }; return ( <> } isExpanded={expandedCardIndex === 0} onClick={() => handleOnCardClick(0)} /> } isExpanded={expandedCardIndex === 1} onClick={() => handleOnCardClick(1)} /> } isExpanded={expandedCardIndex === 2} onClick={() => handleOnCardClick(2)} /> ); }, };