|
| 1 | +import { MoreHorizontal } from "lucide-react"; |
| 2 | + |
| 3 | +import { RichListItem, RichListItemAvatar } from "./RichListItem"; |
| 4 | + |
| 5 | +import type { Meta, StoryObj } from "@storybook/react-vite"; |
| 6 | + |
| 7 | +import { Badge } from "@/components/ui/badge"; |
| 8 | +import { Button } from "@/components/ui/button"; |
| 9 | + |
| 10 | +const meta: Meta<typeof RichListItem> = { |
| 11 | + title: "Design Patterns/RichListItem", |
| 12 | + component: RichListItem, |
| 13 | + parameters: { |
| 14 | + layout: "centered", |
| 15 | + }, |
| 16 | + tags: ["autodocs"], |
| 17 | + decorators: [ |
| 18 | + (Story) => ( |
| 19 | + <div className="w-full max-w-[30rem] rounded-lg border bg-card"> |
| 20 | + <Story /> |
| 21 | + </div> |
| 22 | + ), |
| 23 | + ], |
| 24 | +}; |
| 25 | + |
| 26 | +export default meta; |
| 27 | +type Story = StoryObj<typeof meta>; |
| 28 | + |
| 29 | +export const Default: Story = { |
| 30 | + parameters: { |
| 31 | + zephyr: { testCaseId: "SW-T5122" }, |
| 32 | + }, |
| 33 | + args: { |
| 34 | + leading: <RichListItemAvatar initials="JS" />, |
| 35 | + primary: "Dr. Jane Smith", |
| 36 | + secondary: "Principal Scientist · Biology Platform", |
| 37 | + trailing: ( |
| 38 | + <> |
| 39 | + <Badge variant="positive" className="text-xs"> |
| 40 | + Active |
| 41 | + </Badge> |
| 42 | + <span className="text-xs leading-tight text-muted-foreground">Last active 2h ago</span> |
| 43 | + </> |
| 44 | + ), |
| 45 | + actions: ( |
| 46 | + <Button aria-label="More actions" variant="ghost" size="icon-sm"> |
| 47 | + <MoreHorizontal className="h-4 w-4" /> |
| 48 | + </Button> |
| 49 | + ), |
| 50 | + }, |
| 51 | +}; |
| 52 | + |
| 53 | +export const TeamList: Story = { |
| 54 | + parameters: { |
| 55 | + zephyr: { testCaseId: "SW-T3579" }, |
| 56 | + }, |
| 57 | + render: () => { |
| 58 | + const members = [ |
| 59 | + { |
| 60 | + initials: "JS", |
| 61 | + name: "Dr. Jane Smith", |
| 62 | + role: "Principal Scientist · Biology Platform", |
| 63 | + meta: "Last active 2h ago", |
| 64 | + status: "Active", |
| 65 | + statusVariant: "positive" as const, |
| 66 | + fallbackClassName: "bg-violet-100 text-violet-700 dark:bg-violet-950 dark:text-violet-300", |
| 67 | + }, |
| 68 | + { |
| 69 | + initials: "MT", |
| 70 | + name: "Mark Thompson", |
| 71 | + role: "Data Engineer · Informatics", |
| 72 | + meta: "Last active 5h ago", |
| 73 | + status: "Active", |
| 74 | + statusVariant: "positive" as const, |
| 75 | + fallbackClassName: "bg-blue-100 text-blue-700 dark:bg-blue-950 dark:text-blue-300", |
| 76 | + }, |
| 77 | + { |
| 78 | + initials: "SC", |
| 79 | + name: "Sarah Chen", |
| 80 | + role: "Research Associate · Chemistry", |
| 81 | + meta: "Invited 3 days ago", |
| 82 | + status: "Invited", |
| 83 | + statusVariant: "warning" as const, |
| 84 | + fallbackClassName: "bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300", |
| 85 | + }, |
| 86 | + { |
| 87 | + initials: "RJ", |
| 88 | + name: "Robert Johnson", |
| 89 | + role: "Lab Manager · Operations", |
| 90 | + meta: "Inactive since Jan 2024", |
| 91 | + status: "Inactive", |
| 92 | + statusVariant: "outline" as const, |
| 93 | + fallbackClassName: "", |
| 94 | + }, |
| 95 | + ]; |
| 96 | + |
| 97 | + return ( |
| 98 | + <div className="divide-y divide-border"> |
| 99 | + {members.map((m, i) => ( |
| 100 | + <RichListItem |
| 101 | + key={i} |
| 102 | + leading={<RichListItemAvatar initials={m.initials} fallbackClassName={m.fallbackClassName || undefined} />} |
| 103 | + primary={m.name} |
| 104 | + secondary={m.role} |
| 105 | + trailing={ |
| 106 | + <> |
| 107 | + <Badge variant={m.statusVariant}>{m.status}</Badge> |
| 108 | + <span className="text-xs leading-tight text-muted-foreground">{m.meta}</span> |
| 109 | + </> |
| 110 | + } |
| 111 | + actions={ |
| 112 | + <Button aria-label="More actions" variant="ghost" size="icon-sm"> |
| 113 | + <MoreHorizontal className="h-4 w-4" /> |
| 114 | + </Button> |
| 115 | + } |
| 116 | + /> |
| 117 | + ))} |
| 118 | + </div> |
| 119 | + ); |
| 120 | + }, |
| 121 | +}; |
| 122 | + |
| 123 | +export const MinimalList: Story = { |
| 124 | + parameters: { |
| 125 | + zephyr: { testCaseId: "SW-T3580" }, |
| 126 | + }, |
| 127 | + render: () => ( |
| 128 | + <div className="divide-y divide-border"> |
| 129 | + {["Dataset Alpha", "Dataset Beta", "Dataset Gamma"].map((name) => ( |
| 130 | + <RichListItem |
| 131 | + key={name} |
| 132 | + primary={name} |
| 133 | + secondary="Last modified 1 day ago" |
| 134 | + trailing={<Badge variant="secondary">CSV</Badge>} |
| 135 | + /> |
| 136 | + ))} |
| 137 | + </div> |
| 138 | + ), |
| 139 | +}; |
0 commit comments