|
| 1 | +import type { Meta, StoryObj } from '@nuxtjs/storybook' |
| 2 | +import Component from './DownloadAnalytics.vue' |
| 3 | +import type { WeeklyDownloadPoint } from '~/composables/useCharts' |
| 4 | + |
| 5 | +const meta = { |
| 6 | + component: Component, |
| 7 | + tags: ['autodocs'], |
| 8 | + argTypes: { |
| 9 | + weeklyDownloads: { |
| 10 | + control: { type: 'object' }, |
| 11 | + description: 'Array of weekly download data points for single package mode', |
| 12 | + table: { |
| 13 | + type: { summary: 'WeeklyDownloadPoint[]' }, |
| 14 | + defaultValue: { summary: 'undefined' }, |
| 15 | + }, |
| 16 | + }, |
| 17 | + inModal: { |
| 18 | + control: { type: 'boolean' }, |
| 19 | + description: 'Whether the component is rendered within a modal', |
| 20 | + table: { |
| 21 | + type: { summary: 'boolean' }, |
| 22 | + defaultValue: { summary: 'false' }, |
| 23 | + }, |
| 24 | + }, |
| 25 | + packageName: { |
| 26 | + control: { type: 'text' }, |
| 27 | + description: 'Package name for single package mode (backward compatible)', |
| 28 | + table: { |
| 29 | + type: { summary: 'string' }, |
| 30 | + defaultValue: { summary: 'undefined' }, |
| 31 | + }, |
| 32 | + }, |
| 33 | + packageNames: { |
| 34 | + control: { type: 'object' }, |
| 35 | + description: 'Array of package names for multi-package comparison mode', |
| 36 | + table: { |
| 37 | + type: { summary: 'string[]' }, |
| 38 | + defaultValue: { summary: 'undefined' }, |
| 39 | + }, |
| 40 | + }, |
| 41 | + createdIso: { |
| 42 | + control: { type: 'text' }, |
| 43 | + description: 'ISO date string when the package was created (optional)', |
| 44 | + table: { |
| 45 | + type: { summary: 'string | null' }, |
| 46 | + defaultValue: { summary: 'null' }, |
| 47 | + }, |
| 48 | + }, |
| 49 | + }, |
| 50 | +} satisfies Meta<typeof Component> |
| 51 | + |
| 52 | +export default meta |
| 53 | +type Story = StoryObj<typeof meta> |
| 54 | + |
| 55 | +// Sample data for single package mode |
| 56 | +const sampleWeeklyDownloads: WeeklyDownloadPoint[] = [ |
| 57 | + { |
| 58 | + downloads: 1500, |
| 59 | + weekKey: '2024-W01', |
| 60 | + weekStart: '2024-01-01', |
| 61 | + weekEnd: '2024-01-07', |
| 62 | + timestampStart: 1704067200000, |
| 63 | + timestampEnd: 1704672000000, |
| 64 | + }, |
| 65 | + { |
| 66 | + downloads: 2100, |
| 67 | + weekKey: '2024-W02', |
| 68 | + weekStart: '2024-01-08', |
| 69 | + weekEnd: '2024-01-14', |
| 70 | + timestampStart: 1704672000000, |
| 71 | + timestampEnd: 1705276800000, |
| 72 | + }, |
| 73 | + { |
| 74 | + downloads: 1800, |
| 75 | + weekKey: '2024-W03', |
| 76 | + weekStart: '2024-01-15', |
| 77 | + weekEnd: '2024-01-21', |
| 78 | + timestampStart: 1705276800000, |
| 79 | + timestampEnd: 1705881600000, |
| 80 | + }, |
| 81 | + { |
| 82 | + downloads: 2300, |
| 83 | + weekKey: '2024-W04', |
| 84 | + weekStart: '2024-01-22', |
| 85 | + weekEnd: '2024-01-28', |
| 86 | + timestampStart: 1705881600000, |
| 87 | + timestampEnd: 1706486400000, |
| 88 | + }, |
| 89 | + { |
| 90 | + downloads: 2800, |
| 91 | + weekKey: '2024-W05', |
| 92 | + weekStart: '2024-01-29', |
| 93 | + weekEnd: '2024-02-04', |
| 94 | + timestampStart: 1706486400000, |
| 95 | + timestampEnd: 1707091200000, |
| 96 | + }, |
| 97 | +] |
| 98 | + |
| 99 | +export const Default: Story = { |
| 100 | + args: {}, |
| 101 | +} |
| 102 | + |
| 103 | +export const SinglePackageWithData: Story = { |
| 104 | + args: { |
| 105 | + packageName: 'vue', |
| 106 | + weeklyDownloads: sampleWeeklyDownloads, |
| 107 | + createdIso: '2014-02-25T00:00:00.000Z', |
| 108 | + }, |
| 109 | +} |
| 110 | + |
| 111 | +export const MultiPackageMode: Story = { |
| 112 | + args: { |
| 113 | + packageNames: ['vue', 'react', 'svelte'], |
| 114 | + createdIso: null, |
| 115 | + }, |
| 116 | +} |
| 117 | + |
| 118 | +export const InModal: Story = { |
| 119 | + args: { |
| 120 | + packageName: 'vue', |
| 121 | + weeklyDownloads: sampleWeeklyDownloads, |
| 122 | + inModal: true, |
| 123 | + createdIso: '2014-02-25T00:00:00.000Z', |
| 124 | + }, |
| 125 | +} |
0 commit comments