1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
| import React from 'react'; import { Meta, StoryObj } from '@storybook/react'; import { Card } from '@hardyhu-ui/core'; import { Button } from '@hardyhu-ui/core';
const meta: Meta<typeof Card> = { title: 'Components/Card', component: Card, argTypes: { variant: { control: { type: 'select' }, options: ['default', 'elevated', 'outlined', 'flat'], description: 'Card style variant', table: { type: { summary: 'string' }, defaultValue: { summary: 'default' }, }, }, padding: { control: { type: 'select' }, options: ['normal', 'compact', 'spacious'], description: 'Card padding size', table: { type: { summary: 'string' }, defaultValue: { summary: 'normal' }, }, }, colorAccent: { control: { type: 'select' }, options: ['none', 'primary', 'secondary', 'accent'], description: 'Color accent on top of card', table: { type: { summary: 'string' }, defaultValue: { summary: 'none' }, }, }, hover: { control: 'boolean', description: 'Enables hover effect', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, interactive: { control: 'boolean', description: 'Makes card clickable', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, horizontal: { control: 'boolean', description: 'Makes card layout horizontal', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, disabled: { control: 'boolean', description: 'Disables the card', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, }, }, onClick: { action: 'clicked' }, }, parameters: { docs: { description: { component: 'A versatile card component with various styles and layouts.', }, }, }, };
export default meta; type Story = StoryObj<typeof Card>;
export const Default: Story = { args: { title: 'Card Title', subtitle: 'Card Subtitle', children: ( <p>This is a simple card with title and subtitle. Cards can be used to group related content and actions.</p> ), }, };
export const WithFooter: Story = { args: { title: 'Card with Footer', children: ( <p>This card has a footer with action buttons.</p> ), footer: ( <div style={{ display: 'flex', justifyContent: 'flex-end', gap: '0.5rem' }}> <Button variant="outline" size="small">Cancel</Button> <Button size="small">Save</Button> </div> ), }, };
export const WithImage: Story = { args: { title: 'Card with Image', subtitle: 'Feature image at the top', image: { src: 'https://picsum.photos/800/400', alt: 'Feature image', cover: true, }, children: ( <p>This card includes an image at the top. Images help provide visual context to your content.</p> ), }, };
export const Variants: Story = { render: (args) => ( <div style={{ display: 'flex', gap: '1rem', flexWrap: 'wrap' }}> <Card {...args} variant="default" title="Default Card"> <p>Standard card with border</p> </Card>
<Card {...args} variant="elevated" title="Elevated Card"> <p>Card with shadow</p> </Card>
<Card {...args} variant="outlined" title="Outlined Card"> <p>Transparent with border</p> </Card>
<Card {...args} variant="flat" title="Flat Card"> <p>Card with background color</p> </Card> </div> ), };
export const ColorAccents: Story = { render: (args) => ( <div style={{ display: 'flex', gap: '1rem', flexWrap: 'wrap' }}> <Card {...args} colorAccent="primary" title="Primary Accent"> <p>Card with primary color accent</p> </Card>
<Card {...args} colorAccent="secondary" title="Secondary Accent"> <p>Card with secondary color accent</p> </Card>
<Card {...args} colorAccent="accent" title="Accent Color"> <p>Card with accent color</p> </Card> </div> ), };
export const Interactive: Story = { args: { title: 'Interactive Card', subtitle: 'Click me', children: ( <p>This card is interactive and can be clicked like a button.</p> ), interactive: true, hover: true, onClick: () => alert('Card clicked!'), }, };
export const Horizontal: Story = { args: { title: 'Horizontal Layout', subtitle: 'Image on the left side', children: ( <p>This card uses a horizontal layout with the image on the left side. This layout is useful for list items or content where the image should be displayed alongside text.</p> ), image: { src: 'https://picsum.photos/400/300', alt: 'Card image', cover: true, }, horizontal: true, variant: 'elevated', }, };
export const CustomContent: Story = { render: () => ( <Card variant="elevated" hover> <div style={{ padding: '1rem' }}> <div style={{ marginBottom: '1rem' }}> <h3 style={{ margin: '0 0 0.5rem 0', fontSize: '1.5rem' }}>Custom Content</h3> <p style={{ margin: '0', color: '#666' }}>Card with custom styled content</p> </div>
<div style={{ display: 'flex', gap: '1rem', marginBottom: '1rem' }}> <div style={{ backgroundColor: '#f0f0f0', padding: '1rem', borderRadius: '4px', flex: 1 }}> <h4 style={{ margin: '0 0 0.5rem 0' }}>Feature 1</h4> <p style={{ margin: '0', fontSize: '0.875rem' }}>Description of feature one.</p> </div> <div style={{ backgroundColor: '#f0f0f0', padding: '1rem', borderRadius: '4px', flex: 1 }}> <h4 style={{ margin: '0 0 0.5rem 0' }}>Feature 2</h4> <p style={{ margin: '0', fontSize: '0.875rem' }}>Description of feature two.</p> </div> </div>
<Button fullWidth>Learn More</Button> </div> </Card> ), };
export const GridLayout: Story = { render: () => ( <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))', gap: '1rem' }}> {Array(6).fill(0).map((_, i) => ( <Card key={i} variant="elevated" hover interactive image={{ src: `https://picsum.photos/300/${200 + i * 10}`, alt: `Card ${i + 1}`, cover: true, height: 150, }} onClick={() => alert(`Card ${i + 1} clicked!`)} > <h3 style={{ margin: '0 0 0.5rem 0' }}>Card {i + 1}</h3> <p style={{ margin: '0 0 1rem 0' }}>This is a grid of interactive cards with images.</p> <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> <span style={{ fontSize: '0.875rem', color: '#666' }}>Item #{i + 1}</span> <Button size="small" variant="outline">View</Button> </div> </Card> ))} </div> ), };
|