|
| 1 | +import type { Meta, StoryObj } from "@storybook/react"; |
| 2 | +import { EmptyState } from "./EmptyState"; |
| 3 | + |
| 4 | +/** |
| 5 | + * EmptyState is the generic "nothing to show yet" placeholder reused across |
| 6 | + * dashboard pages (wallets, transactions, etc.) whenever a data-fetching |
| 7 | + * view has no items to render but no error either. |
| 8 | + */ |
| 9 | +const meta = { |
| 10 | + title: "UI/EmptyState", |
| 11 | + component: EmptyState, |
| 12 | + tags: ["autodocs"], |
| 13 | + parameters: { |
| 14 | + layout: "padded", |
| 15 | + docs: { |
| 16 | + description: { |
| 17 | + component: |
| 18 | + "Empty state shown when a list or detail view has successfully loaded but has no data to display.", |
| 19 | + }, |
| 20 | + }, |
| 21 | + }, |
| 22 | + argTypes: { |
| 23 | + icon: { description: "Optional custom icon; defaults to a generic outline icon" }, |
| 24 | + title: { control: "text", description: "Short heading for the empty state" }, |
| 25 | + description: { |
| 26 | + control: "text", |
| 27 | + description: "Explains why there's nothing here / what to do next", |
| 28 | + }, |
| 29 | + action: { control: "object", description: "Optional call-to-action button" }, |
| 30 | + }, |
| 31 | +} satisfies Meta<typeof EmptyState>; |
| 32 | + |
| 33 | +export default meta; |
| 34 | +type Story = StoryObj<typeof meta>; |
| 35 | + |
| 36 | +/** Default empty state with the built-in icon and no action. */ |
| 37 | +export const Default: Story = { |
| 38 | + args: { |
| 39 | + title: "No data yet", |
| 40 | + description: "There's nothing to show here right now.", |
| 41 | + }, |
| 42 | +}; |
| 43 | + |
| 44 | +/** No wallets added — the state used on the wallets dashboard. */ |
| 45 | +export const NoWallets: Story = { |
| 46 | + args: { |
| 47 | + title: "No wallets found", |
| 48 | + description: |
| 49 | + "You haven't added any wallets to monitor yet. Add your first wallet to start tracking.", |
| 50 | + action: { |
| 51 | + label: "Add Wallet", |
| 52 | + onClick: () => console.log("Add wallet clicked"), |
| 53 | + }, |
| 54 | + }, |
| 55 | +}; |
| 56 | + |
| 57 | +/** No wallet data available for a single wallet detail view. */ |
| 58 | +export const NoWalletData: Story = { |
| 59 | + args: { |
| 60 | + title: "No wallet data", |
| 61 | + description: "This wallet has no data to display yet.", |
| 62 | + }, |
| 63 | +}; |
| 64 | + |
| 65 | +/** Filtered list with zero matches. */ |
| 66 | +export const NoFilteredResults: Story = { |
| 67 | + args: { |
| 68 | + title: "No matching wallets", |
| 69 | + description: |
| 70 | + "No wallets match the selected network filter. Try switching between testnet and mainnet.", |
| 71 | + action: { |
| 72 | + label: "Clear Filter", |
| 73 | + onClick: () => console.log("Clear filter clicked"), |
| 74 | + }, |
| 75 | + }, |
| 76 | +}; |
| 77 | + |
| 78 | +/** Custom icon overriding the default outline icon. */ |
| 79 | +export const CustomIcon: Story = { |
| 80 | + args: { |
| 81 | + title: "No transactions", |
| 82 | + description: "Transactions will appear here once this wallet is active.", |
| 83 | + icon: ( |
| 84 | + <svg |
| 85 | + className="h-10 w-10 text-blue-400" |
| 86 | + fill="none" |
| 87 | + viewBox="0 0 24 24" |
| 88 | + stroke="currentColor" |
| 89 | + strokeWidth={1.5} |
| 90 | + > |
| 91 | + <path |
| 92 | + strokeLinecap="round" |
| 93 | + strokeLinejoin="round" |
| 94 | + d="M3 7.5L7.5 3m0 0L12 7.5M7.5 3v13.5m13.5 0L16.5 21m0 0L12 16.5m4.5 4.5V7.5" |
| 95 | + /> |
| 96 | + </svg> |
| 97 | + ), |
| 98 | + }, |
| 99 | +}; |
| 100 | + |
| 101 | +/** No action button — purely informational. */ |
| 102 | +export const NoAction: Story = { |
| 103 | + args: { |
| 104 | + title: "Nothing to see here", |
| 105 | + description: "This section is intentionally empty for now.", |
| 106 | + }, |
| 107 | +}; |
| 108 | + |
| 109 | +/** Long title/description to check wrapping and max-width behavior. */ |
| 110 | +export const LongContent: Story = { |
| 111 | + args: { |
| 112 | + title: "No wallets match your current search and filter combination", |
| 113 | + description: |
| 114 | + "Try broadening your search terms, clearing the network filter, or removing the status filter to see more results. If you believe this is an error, contact support.", |
| 115 | + action: { |
| 116 | + label: "Reset all filters", |
| 117 | + onClick: () => console.log("Reset filters clicked"), |
| 118 | + }, |
| 119 | + }, |
| 120 | +}; |
| 121 | + |
| 122 | +/** Rendered inside a dark-mode wrapper to verify contrast. */ |
| 123 | +export const DarkMode: Story = { |
| 124 | + args: { |
| 125 | + title: "No wallets found", |
| 126 | + description: "Add your first wallet to start tracking.", |
| 127 | + action: { label: "Add Wallet", onClick: () => console.log("Add wallet") }, |
| 128 | + }, |
| 129 | + parameters: { backgrounds: { default: "dark" } }, |
| 130 | + decorators: [ |
| 131 | + (Story) => ( |
| 132 | + <div className="dark bg-zinc-950 p-6"> |
| 133 | + <Story /> |
| 134 | + </div> |
| 135 | + ), |
| 136 | + ], |
| 137 | +}; |
0 commit comments