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 | import type { Meta, StoryObj } from '@storybook/react';
import { MetricCard } from './MetricCard';
import {
Users as UsersIcon,
DollarSign,
Activity as ActivityIcon,
CreditCard
} from 'lucide-react';
const meta = {
title: 'Dashboard/MetricCard',
component: MetricCard,
parameters: {
layout: 'padded',
},
tags: ['autodocs'],
argTypes: {
trend: {
control: 'object',
},
},
} satisfies Meta<typeof MetricCard>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Revenue: Story = {
args: {
title: 'Total Revenue',
value: 45231.89,
valuePrefix: '$',
description: 'Revenue this month',
trend: {
value: 20.1,
isPositive: true,
label: 'from last month',
},
icon: <DollarSign className="h-4 w-4" />,
},
};
export const Users: Story = {
args: {
title: 'Total Users',
value: 2350,
description: 'Active users',
trend: {
value: 12.5,
isPositive: true,
label: 'from last month',
},
icon: <UsersIcon className="h-4 w-4" />,
},
};
export const Subscriptions: Story = {
args: {
title: 'Subscriptions',
value: 12234,
description: 'Active subscriptions',
trend: {
value: 19.2,
isPositive: true,
label: 'from last month',
},
icon: <CreditCard className="h-4 w-4" />,
},
};
export const Activity: Story = {
args: {
title: 'Active Now',
value: 573,
description: 'Users online',
trend: {
value: 201,
isPositive: true,
label: 'from last hour',
},
icon: <ActivityIcon className="h-4 w-4" />,
},
};
export const NegativeTrend: Story = {
args: {
title: 'Bounce Rate',
value: 45.2,
valueSuffix: '%',
description: 'Average bounce rate',
trend: {
value: 5.4,
isPositive: false,
label: 'from last month',
},
icon: <ActivityIcon className="h-4 w-4" />,
},
};
export const NoTrend: Story = {
args: {
title: 'Total Orders',
value: 1234,
description: 'Orders processed',
icon: <CreditCard className="h-4 w-4" />,
},
};
export const ZeroTrend: Story = {
args: {
title: 'Conversion Rate',
value: 3.2,
valueSuffix: '%',
description: 'Visitors to customers',
trend: {
value: 0,
isPositive: true,
label: 'no change',
},
icon: <ActivityIcon className="h-4 w-4" />,
},
};
export const LargeNumber: Story = {
args: {
title: 'Page Views',
value: 1543829,
description: 'Total page views',
trend: {
value: 8.7,
isPositive: true,
label: 'from last month',
},
icon: <ActivityIcon className="h-4 w-4" />,
},
};
export const AllMetrics: Story = {
render: () => (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<MetricCard
title="Total Revenue"
value={45231.89}
valuePrefix="$"
description="Revenue this month"
trend={{ value: 20.1, isPositive: true, label: 'from last month' }}
icon={<DollarSign className="h-4 w-4" />}
/>
<MetricCard
title="Subscriptions"
value={2350}
description="Active subscriptions"
trend={{ value: 12.5, isPositive: true, label: 'from last month' }}
icon={<UsersIcon className="h-4 w-4" />}
/>
<MetricCard
title="Sales"
value={12234}
description="Total sales"
trend={{ value: 19.2, isPositive: true, label: 'from last month' }}
icon={<CreditCard className="h-4 w-4" />}
/>
<MetricCard
title="Active Now"
value={573}
description="Users online"
trend={{ value: 5.4, isPositive: false, label: 'from last hour' }}
icon={<ActivityIcon className="h-4 w-4" />}
/>
</div>
),
}; |