|
| 1 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 2 | + |
| 3 | +import { default as DateComponent } from './Date'; |
| 4 | +import { DateFormat } from './Date.types'; |
| 5 | + |
| 6 | +const meta = { |
| 7 | + title: 'Components/Date', |
| 8 | + component: DateComponent, |
| 9 | + parameters: { |
| 10 | + layout: 'centered', |
| 11 | + }, |
| 12 | + tags: ['autodocs'], |
| 13 | + argTypes: { |
| 14 | + date: { description: 'The text to display.' }, |
| 15 | + className: { description: 'Additional CSS classes.' }, |
| 16 | + testId: { description: 'Unit test identifier.' }, |
| 17 | + format: { |
| 18 | + control: { |
| 19 | + type: 'select', |
| 20 | + labels: { |
| 21 | + 'MM/DD/YYYY': 'Date', |
| 22 | + dddd: 'Day of the Week', |
| 23 | + 'H[h] mm[m]': 'Hours and Minutes', |
| 24 | + 'h:mma': 'Time', |
| 25 | + 'h:mma ddd MMM D': 'Timestamp Short', |
| 26 | + 'dddd MMMM D [at] h:mma': 'Timestamp', |
| 27 | + }, |
| 28 | + }, |
| 29 | + options: [ |
| 30 | + DateFormat.DATE, |
| 31 | + DateFormat.DAY_OF_WEEK, |
| 32 | + DateFormat.HOURS_AND_MINUTES, |
| 33 | + DateFormat.TIME, |
| 34 | + DateFormat.TIMESTAMP, |
| 35 | + DateFormat.TIMESTAMP_SHORT, |
| 36 | + ], |
| 37 | + description: 'The date format.', |
| 38 | + }, |
| 39 | + }, |
| 40 | +} satisfies Meta<typeof DateComponent>; |
| 41 | + |
| 42 | +export default meta; |
| 43 | + |
| 44 | +type Story = StoryObj<typeof meta>; |
| 45 | + |
| 46 | +export const FormatDate: Story = { |
| 47 | + args: { |
| 48 | + date: new Date().toISOString(), |
| 49 | + }, |
| 50 | +}; |
| 51 | + |
| 52 | +export const FormatDayOfWeek: Story = { |
| 53 | + args: { |
| 54 | + date: new Date().toISOString(), |
| 55 | + format: DateFormat.DAY_OF_WEEK, |
| 56 | + }, |
| 57 | +}; |
| 58 | + |
| 59 | +export const FormatHoursAndMinutes: Story = { |
| 60 | + args: { |
| 61 | + date: new Date().toISOString(), |
| 62 | + format: DateFormat.HOURS_AND_MINUTES, |
| 63 | + }, |
| 64 | +}; |
| 65 | + |
| 66 | +export const FormatTime: Story = { |
| 67 | + args: { |
| 68 | + date: new Date().toISOString(), |
| 69 | + format: DateFormat.TIME, |
| 70 | + }, |
| 71 | +}; |
| 72 | + |
| 73 | +export const FormatTimestamp: Story = { |
| 74 | + args: { |
| 75 | + date: new Date().toISOString(), |
| 76 | + format: DateFormat.TIMESTAMP, |
| 77 | + }, |
| 78 | +}; |
| 79 | + |
| 80 | +export const FormatTimestampShort: Story = { |
| 81 | + args: { |
| 82 | + date: new Date().toISOString(), |
| 83 | + format: DateFormat.TIMESTAMP_SHORT, |
| 84 | + }, |
| 85 | +}; |
0 commit comments