Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | import type { Meta, StoryObj } from '@storybook/react';
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './Card';
import { Button } from './Button';
const meta = {
title: 'UI/Card',
component: Card,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
} satisfies Meta<typeof Card>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
render: () => (
<Card className="w-[350px]">
<CardHeader>
<CardTitle>Card Title</CardTitle>
<CardDescription>Card Description</CardDescription>
</CardHeader>
<CardContent>
<p>Card content goes here.</p>
</CardContent>
<CardFooter>
<p>Card footer</p>
</CardFooter>
</Card>
),
};
export const WithButton: Story = {
render: () => (
<Card className="w-[350px]">
<CardHeader>
<CardTitle>Create Project</CardTitle>
<CardDescription>Deploy your new project in one-click.</CardDescription>
</CardHeader>
<CardContent>
<p>
Get started by creating a new project. You can always change these settings later.
</p>
</CardContent>
<CardFooter className="flex justify-between">
<Button variant="outline">Cancel</Button>
<Button>Deploy</Button>
</CardFooter>
</Card>
),
};
export const SimpleCard: Story = {
render: () => (
<Card className="w-[350px]">
<CardContent className="p-6">
<div className="text-center">
<h3 className="text-lg font-semibold">Simple Card</h3>
<p className="text-sm text-muted-foreground mt-2">
This is a simple card with just content.
</p>
</div>
</CardContent>
</Card>
),
};
export const ProfileCard: Story = {
render: () => (
<Card className="w-[350px]">
<CardHeader>
<div className="flex items-center space-x-4">
<div className="w-12 h-12 bg-gradient-to-br from-purple-500 to-pink-500 rounded-full flex items-center justify-center text-white font-bold">
JD
</div>
<div>
<CardTitle>John Doe</CardTitle>
<CardDescription>Software Engineer</CardDescription>
</div>
</div>
</CardHeader>
<CardContent>
<p className="text-sm text-muted-foreground">
Passionate about creating amazing user experiences with modern web technologies.
</p>
</CardContent>
<CardFooter>
<Button className="w-full">View Profile</Button>
</CardFooter>
</Card>
),
};
export const NotificationCard: Story = {
render: () => (
<Card className="w-[350px]">
<CardHeader className="pb-3">
<div className="flex items-center justify-between">
<CardTitle className="text-sm font-medium">Notifications</CardTitle>
<Button variant="ghost" size="sm">
Mark all as read
</Button>
</div>
</CardHeader>
<CardContent className="grid gap-4">
<div className="flex items-center space-x-4 rounded-md border p-4">
<div className="flex-1 space-y-1">
<p className="text-sm font-medium leading-none">
Your call has been confirmed.
</p>
<p className="text-xs text-muted-foreground">
5 min ago
</p>
</div>
</div>
<div className="flex items-center space-x-4 rounded-md border p-4">
<div className="flex-1 space-y-1">
<p className="text-sm font-medium leading-none">
You have a new message!
</p>
<p className="text-xs text-muted-foreground">
1 hour ago
</p>
</div>
</div>
</CardContent>
</Card>
),
};
export const StatsCard: Story = {
render: () => (
<Card className="w-[350px]">
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Total Revenue</CardTitle>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
className="h-4 w-4 text-muted-foreground"
>
<path d="M12 2v20m9-9H3" />
</svg>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">$45,231.89</div>
<p className="text-xs text-muted-foreground">
+20.1% from last month
</p>
</CardContent>
</Card>
),
};
export const AllCardComponents: Story = {
render: () => (
<div className="grid gap-4">
<div className="text-lg font-semibold">Card Components</div>
<div className="grid gap-4 md:grid-cols-2">
<Card>
<CardHeader>
<CardTitle>Card Title</CardTitle>
</CardHeader>
<CardContent>
<p>Card with title only</p>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Card Title</CardTitle>
<CardDescription>Card Description</CardDescription>
</CardHeader>
<CardContent>
<p>Card with title and description</p>
</CardContent>
</Card>
<Card>
<CardContent>
<p>Card with content only</p>
</CardContent>
<CardFooter>
<p>And footer</p>
</CardFooter>
</Card>
<Card>
<CardHeader>
<CardTitle>Complete Card</CardTitle>
<CardDescription>With all components</CardDescription>
</CardHeader>
<CardContent>
<p>This card has all components.</p>
</CardContent>
<CardFooter>
<Button size="sm">Action</Button>
</CardFooter>
</Card>
</div>
</div>
),
}; |