|
1 | | -// ----- Imports ----- // |
2 | | -import type { Meta } from '@storybook/react-webpack5'; |
3 | | -import { StarRatingDeprecated } from './StarRatingDeprecated'; |
| 1 | +import type { Meta, StoryObj } from '@storybook/react-webpack5'; |
4 | 2 |
|
5 | | -// ----- Meta ----- // |
| 3 | +import { type Props, StarRating } from './StarRating'; |
6 | 4 |
|
7 | | -const meta: Meta<typeof StarRatingDeprecated> = { |
8 | | - title: 'components/StarRatingDeprecated', |
9 | | - component: StarRatingDeprecated, |
10 | | -}; |
| 5 | +const meta = { |
| 6 | + component: StarRating, |
| 7 | + title: 'Components/StarRating', |
| 8 | + render: (args) => <AllRatings {...args} />, |
| 9 | + parameters: { |
| 10 | + chromatic: { |
| 11 | + disableSnapshot: true, |
| 12 | + }, |
| 13 | + }, |
| 14 | +} satisfies Meta<typeof StarRating>; |
11 | 15 |
|
12 | 16 | export default meta; |
| 17 | +type Story = StoryObj<typeof StarRating>; |
13 | 18 |
|
14 | | -// ----- Stories ----- // |
| 19 | +const Ratings = [0, 1, 2, 3, 4, 5] as const; |
15 | 20 |
|
16 | | -export const AllSizeStars = () => ( |
17 | | - <> |
18 | | - <h1>Small</h1> |
19 | | - <br /> |
20 | | - <StarRatingDeprecated rating={3} size="small" /> |
21 | | - <br /> |
22 | | - <br /> |
23 | | - <h1>Large</h1> |
24 | | - <br /> |
25 | | - <StarRatingDeprecated rating={3} size="large" /> |
26 | | - </> |
27 | | -); |
28 | | -AllSizeStars.storyName = 'All Sizes'; |
| 21 | +const AllRatings = (args: Props) => { |
| 22 | + return Ratings.map((x) => <StarRating {...args} rating={x} key={x} />); |
| 23 | +}; |
29 | 24 |
|
30 | | -export const SmallStory = () => ( |
31 | | - <> |
32 | | - <h1>0 Star</h1> |
33 | | - <StarRatingDeprecated rating={0} size="small" /> |
34 | | - <br /> |
35 | | - <h1>1 Star</h1> |
36 | | - <StarRatingDeprecated rating={1} size="small" /> |
37 | | - <br /> |
38 | | - <h1>2 Star</h1> |
39 | | - <StarRatingDeprecated rating={2} size="small" /> |
40 | | - <br /> |
41 | | - <h1>3 Star</h1> |
42 | | - <StarRatingDeprecated rating={3} size="small" /> |
43 | | - <br /> |
44 | | - <h1>4 Star</h1> |
45 | | - <StarRatingDeprecated rating={4} size="small" /> |
46 | | - <br /> |
47 | | - <h1>5 Star</h1> |
48 | | - <StarRatingDeprecated rating={5} size="small" /> |
49 | | - </> |
50 | | -); |
51 | | -SmallStory.storyName = 'Small Stars'; |
| 25 | +export const SmallStars: Story = { |
| 26 | + args: { |
| 27 | + size: 'small', |
| 28 | + }, |
| 29 | +}; |
52 | 30 |
|
53 | | -export const LargeStory = () => ( |
54 | | - <> |
55 | | - <h1>0 Star</h1> |
56 | | - <StarRatingDeprecated rating={0} size="large" /> |
57 | | - <br /> |
58 | | - <h1>1 Star</h1> |
59 | | - <StarRatingDeprecated rating={1} size="large" /> |
60 | | - <br /> |
61 | | - <h1>2 Star</h1> |
62 | | - <StarRatingDeprecated rating={2} size="large" /> |
63 | | - <br /> |
64 | | - <h1>3 Star</h1> |
65 | | - <StarRatingDeprecated rating={3} size="large" /> |
66 | | - <br /> |
67 | | - <h1>4 Star</h1> |
68 | | - <StarRatingDeprecated rating={4} size="large" /> |
69 | | - <br /> |
70 | | - <h1>5 Star</h1> |
71 | | - <StarRatingDeprecated rating={5} size="large" /> |
72 | | - </> |
73 | | -); |
74 | | -LargeStory.storyName = 'Large stars'; |
| 31 | +export const MediumStars: Story = { |
| 32 | + args: { |
| 33 | + size: 'medium', |
| 34 | + }, |
| 35 | +}; |
75 | 36 |
|
76 | | -export const StarColours = () => ( |
77 | | - <> |
78 | | - <div style={{ backgroundColor: '#f6dde1' }}> |
79 | | - <p>Stars take the colour of the parent by default</p> |
80 | | - <div style={{ color: 'red' }}> |
81 | | - <StarRatingDeprecated rating={0} size="large" /> |
82 | | - </div> |
83 | | - <div style={{ color: 'orange' }}> |
84 | | - <StarRatingDeprecated rating={1} size="large" /> |
85 | | - </div> |
86 | | - <div style={{ color: 'yellow' }}> |
87 | | - <StarRatingDeprecated rating={2} size="large" /> |
88 | | - </div> |
89 | | - <div style={{ color: 'green' }}> |
90 | | - <StarRatingDeprecated rating={3} size="large" /> |
91 | | - </div> |
92 | | - <div style={{ color: 'blue' }}> |
93 | | - <StarRatingDeprecated rating={4} size="large" /> |
94 | | - </div> |
95 | | - <div style={{ color: 'purple' }}> |
96 | | - <StarRatingDeprecated rating={5} size="large" /> |
97 | | - </div> |
98 | | - </div> |
99 | | - </> |
100 | | -); |
101 | | -StarColours.storyName = 'Star colours'; |
| 37 | +export const LargeStars: Story = { |
| 38 | + args: { |
| 39 | + size: 'large', |
| 40 | + }, |
| 41 | +}; |
| 42 | + |
| 43 | +export const StarsWithSmallPadding: Story = { |
| 44 | + args: { |
| 45 | + size: 'large', |
| 46 | + paddingSize: 'small', |
| 47 | + }, |
| 48 | +}; |
| 49 | + |
| 50 | +export const StarsWithMediumPadding: Story = { |
| 51 | + args: { |
| 52 | + size: 'large', |
| 53 | + paddingSize: 'medium', |
| 54 | + }, |
| 55 | +}; |
| 56 | + |
| 57 | +export const StarsWithLargePadding: Story = { |
| 58 | + args: { |
| 59 | + size: 'large', |
| 60 | + paddingSize: 'large', |
| 61 | + }, |
| 62 | +}; |
| 63 | + |
| 64 | +export const StarsWithDarkTheme: Story = { |
| 65 | + args: { |
| 66 | + size: 'large', |
| 67 | + useDarkTheme: true, |
| 68 | + }, |
| 69 | +}; |
0 commit comments