|
1 | 1 | import { Centering, DateSelect } from '@solved-ac/ui-react' |
2 | | -import { Meta, StoryFn } from '@storybook/react' |
| 2 | +import { Meta, StoryObj } from '@storybook/react' |
3 | 3 | import React from 'react' |
4 | 4 |
|
5 | 5 | export default { |
6 | 6 | title: 'Components/DateSelect', |
7 | 7 | component: DateSelect, |
8 | | - argTypes: {}, |
| 8 | + argTypes: { |
| 9 | + locale: { |
| 10 | + control: 'text', |
| 11 | + description: 'The locale to use', |
| 12 | + }, |
| 13 | + weekStartsOn: { |
| 14 | + defaultValue: 0, |
| 15 | + options: [0, 1, 2, 3, 4, 5, 6], |
| 16 | + control: { |
| 17 | + type: 'select', |
| 18 | + }, |
| 19 | + description: 'The day of the week to start on', |
| 20 | + }, |
| 21 | + chunks: { |
| 22 | + defaultValue: 1, |
| 23 | + options: [1, 2, 3, 4, 5, 6], |
| 24 | + control: { |
| 25 | + type: 'select', |
| 26 | + }, |
| 27 | + description: 'The number of months to display at once', |
| 28 | + }, |
| 29 | + annotations: { |
| 30 | + control: 'array', |
| 31 | + description: 'The annotations to display', |
| 32 | + defaultValue: [], |
| 33 | + }, |
| 34 | + }, |
9 | 35 | } as Meta<typeof DateSelect> |
10 | 36 |
|
11 | | -const Template: StoryFn<typeof DateSelect> = (args) => ( |
12 | | - <Centering> |
13 | | - <DateSelect {...args} /> |
14 | | - </Centering> |
15 | | -) |
| 37 | +type Story = StoryObj<typeof DateSelect> |
16 | 38 |
|
17 | | -export const Default = Template.bind({}) |
| 39 | +export const Default: Story = { |
| 40 | + render: (args) => ( |
| 41 | + <Centering> |
| 42 | + <DateSelect {...args} /> |
| 43 | + </Centering> |
| 44 | + ), |
| 45 | +} |
| 46 | + |
| 47 | +const DAY = 1000 * 60 * 60 * 24 |
| 48 | + |
| 49 | +export const Annotations: Story = { |
| 50 | + render: (args) => ( |
| 51 | + <Centering> |
| 52 | + <DateSelect {...args} /> |
| 53 | + </Centering> |
| 54 | + ), |
| 55 | + args: { |
| 56 | + annotations: [ |
| 57 | + { |
| 58 | + title: "I'm a title", |
| 59 | + color: '#e3f44f', |
| 60 | + start: new Date().toISOString().split('T')[0], |
| 61 | + end: new Date(Date.now() + DAY * 7).toISOString().split('T')[0], |
| 62 | + }, |
| 63 | + { |
| 64 | + title: "I'm a title", |
| 65 | + color: '#c1ecff', |
| 66 | + start: new Date(Date.now() - DAY * 17).toISOString().split('T')[0], |
| 67 | + end: new Date(Date.now() - DAY * 5).toISOString().split('T')[0], |
| 68 | + }, |
| 69 | + { |
| 70 | + title: "I'm a title", |
| 71 | + color: '#ffd2bd', |
| 72 | + start: new Date(Date.now() + DAY * 4).toISOString().split('T')[0], |
| 73 | + end: new Date(Date.now() + DAY * 16).toISOString().split('T')[0], |
| 74 | + }, |
| 75 | + { |
| 76 | + title: "I'm a title", |
| 77 | + color: '#ffc8fb', |
| 78 | + start: new Date(Date.now() + DAY * 9).toISOString().split('T')[0], |
| 79 | + end: new Date(Date.now() + DAY * 9).toISOString().split('T')[0], |
| 80 | + }, |
| 81 | + { |
| 82 | + title: "I'm a title", |
| 83 | + color: '#f9ffc1', |
| 84 | + start: new Date(Date.now() + DAY * 16).toISOString().split('T')[0], |
| 85 | + end: new Date(Date.now() + DAY * 17).toISOString().split('T')[0], |
| 86 | + }, |
| 87 | + { |
| 88 | + title: "I'm a title", |
| 89 | + color: '#d7ffc0', |
| 90 | + start: new Date(Date.now() + DAY * 24).toISOString().split('T')[0], |
| 91 | + end: new Date(Date.now() + DAY * 28).toISOString().split('T')[0], |
| 92 | + }, |
| 93 | + { |
| 94 | + title: "I'm a title", |
| 95 | + color: '#b9b7b4', |
| 96 | + start: new Date(Date.now() + DAY * 21).toISOString().split('T')[0], |
| 97 | + end: new Date(Date.now() + DAY * 25).toISOString().split('T')[0], |
| 98 | + }, |
| 99 | + { |
| 100 | + title: "I'm a title", |
| 101 | + color: '#ffcbcb', |
| 102 | + start: new Date(Date.now() + DAY * 34).toISOString().split('T')[0], |
| 103 | + end: new Date(Date.now() + DAY * 36).toISOString().split('T')[0], |
| 104 | + }, |
| 105 | + ], |
| 106 | + }, |
| 107 | +} |
0 commit comments