|
1 | 1 | import type { Meta, StoryObj } from "@storybook/react" |
2 | 2 |
|
3 | 3 | import type { InfoCardsProps } from "~/interfaces" |
| 4 | +import type { IsomerPageLayoutType } from "~/types" |
4 | 5 | import InfoCards from "./InfoCards" |
5 | 6 |
|
6 | 7 | const meta: Meta<InfoCardsProps> = { |
@@ -45,137 +46,121 @@ const meta: Meta<InfoCardsProps> = { |
45 | 46 | export default meta |
46 | 47 | type Story = StoryObj<typeof InfoCards> |
47 | 48 |
|
48 | | -export const WithImage: Story = { |
49 | | - args: { |
| 49 | +const generateArgs = ({ |
| 50 | + layout = "content", |
| 51 | + maxColumns, |
| 52 | + withoutImage = false, |
| 53 | + isImageFitContain = false, |
| 54 | +}: { |
| 55 | + layout?: IsomerPageLayoutType |
| 56 | + maxColumns: "1" | "2" | "3" |
| 57 | + withoutImage?: boolean |
| 58 | + isImageFitContain?: boolean |
| 59 | +}): InfoCardsProps => { |
| 60 | + const cards = [ |
| 61 | + { |
| 62 | + title: |
| 63 | + "Testing for a card with a long line length that spans across two lines or more", |
| 64 | + description: |
| 65 | + "Explore Duxton with us and leave with a full belly, tipsy mind, and a happy smile.", |
| 66 | + imageUrl: "https://placehold.co/200x300", |
| 67 | + imageAlt: "alt text", |
| 68 | + imageFit: "contain", |
| 69 | + url: "https://www.google.com", |
| 70 | + }, |
| 71 | + { |
| 72 | + title: "Card with short title", |
| 73 | + description: |
| 74 | + "Card description, 200 chars. In the kingdom of Veridonia, the government operates as a benevolent monarchy, guided by ancient traditions and the wisdom of its sovereign.", |
| 75 | + imageUrl: |
| 76 | + "https://craftypixels.com/placeholder-image/800x400/ffffff/000000&text=Image+with+white+background", |
| 77 | + imageAlt: "alt text", |
| 78 | + imageFit: "contain", |
| 79 | + }, |
| 80 | + { |
| 81 | + title: "Hover on me to see me change colors", |
| 82 | + description: |
| 83 | + "Card description, 200 chars. In the kingdom of Veridonia, the government operates as a benevolent monarchy, guided by ancient traditions and the wisdom of its sovereign.", |
| 84 | + imageUrl: "https://placehold.co/800x200", |
| 85 | + imageAlt: "alt text", |
| 86 | + imageFit: "contain", |
| 87 | + url: "https://www.google.com", |
| 88 | + }, |
| 89 | + { |
| 90 | + title: "Testing a card with a larger image and no description", |
| 91 | + imageUrl: "https://placehold.co/500x500", |
| 92 | + imageAlt: "alt text", |
| 93 | + imageFit: "contain", |
| 94 | + }, |
| 95 | + { |
| 96 | + title: "A non-placeholder image version", |
| 97 | + description: "This is an image that is added using a URL.", |
| 98 | + imageUrl: |
| 99 | + "https://images.unsplash.com/photo-1722260613137-f8f5ac432d69?q=80&w=3570&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", |
| 100 | + imageAlt: "alt text", |
| 101 | + imageFit: "contain", |
| 102 | + url: "https://www.google.com", |
| 103 | + }, |
| 104 | + ] |
| 105 | + |
| 106 | + if (withoutImage) { |
| 107 | + cards.forEach((card) => { |
| 108 | + delete (card as any).imageAlt |
| 109 | + delete (card as any).imageUrl |
| 110 | + }) |
| 111 | + } |
| 112 | + |
| 113 | + if (!isImageFitContain) { |
| 114 | + cards.forEach((card) => { |
| 115 | + delete (card as any).imageFit |
| 116 | + }) |
| 117 | + } |
| 118 | + |
| 119 | + return { |
| 120 | + layout: layout, |
50 | 121 | title: "Section title ministry highlights", |
51 | 122 | subtitle: |
52 | 123 | "Section subtitle, maximum 150 chars. These are some of the things we are working on. As a ministry, we focus on delivering value to the members of public.", |
53 | | - variant: "cardsWithImages", |
54 | | - cards: [ |
55 | | - { |
56 | | - title: |
57 | | - "Testing for a card with a long line length that spans across two lines or more", |
58 | | - description: |
59 | | - "Explore Duxton with us and leave with a full belly, tipsy mind, and a happy smile.", |
60 | | - imageUrl: "https://placehold.co/200x300", |
61 | | - imageAlt: "alt text", |
62 | | - url: "https://www.google.com", |
63 | | - }, |
64 | | - { |
65 | | - title: "Card with short title", |
66 | | - description: |
67 | | - "Card description, 200 chars. In the kingdom of Veridonia, the government operates as a benevolent monarchy, guided by ancient traditions and the wisdom of its sovereign.", |
68 | | - imageUrl: |
69 | | - "https://craftypixels.com/placeholder-image/800x400/ffffff/000000&text=Image+with+white+background", |
70 | | - imageAlt: "alt text", |
71 | | - }, |
72 | | - { |
73 | | - title: "Hover on me to see me change colors", |
74 | | - description: |
75 | | - "Card description, 200 chars. In the kingdom of Veridonia, the government operates as a benevolent monarchy, guided by ancient traditions and the wisdom of its sovereign.", |
76 | | - imageUrl: "https://placehold.co/800x200", |
77 | | - imageAlt: "alt text", |
78 | | - url: "https://www.google.com", |
79 | | - }, |
80 | | - { |
81 | | - title: "Testing a card with a larger image and no description", |
82 | | - imageUrl: "https://placehold.co/500x500", |
83 | | - imageAlt: "alt text", |
84 | | - }, |
85 | | - { |
86 | | - title: "A non-placeholder image version", |
87 | | - description: "This is an image that is added using a URL.", |
88 | | - imageUrl: |
89 | | - "https://images.unsplash.com/photo-1722260613137-f8f5ac432d69?q=80&w=3570&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", |
90 | | - imageAlt: "alt text", |
91 | | - url: "https://www.google.com", |
92 | | - }, |
93 | | - ], |
94 | | - }, |
| 124 | + maxColumns: maxColumns, |
| 125 | + variant: withoutImage ? "cardsWithoutImages" : "cardsWithImages", |
| 126 | + cards: cards, |
| 127 | + } as InfoCardsProps |
| 128 | +} |
| 129 | + |
| 130 | +export const WithImage3Columns: Story = { |
| 131 | + name: "With Image (3 Cols)", |
| 132 | + args: generateArgs({ maxColumns: "3" }), |
| 133 | +} |
| 134 | + |
| 135 | +export const WithImage3ColumnsHomepage: Story = { |
| 136 | + name: "With Image (3 Cols) Homepage", |
| 137 | + args: generateArgs({ maxColumns: "3", layout: "homepage" }), |
| 138 | +} |
| 139 | + |
| 140 | +export const WithImage2Columns: Story = { |
| 141 | + name: "With Image (2 Cols)", |
| 142 | + args: generateArgs({ maxColumns: "2" }), |
| 143 | +} |
| 144 | + |
| 145 | +export const WithImage2ColumnsHomepage: Story = { |
| 146 | + name: "With Image (2 Cols) Homepage", |
| 147 | + args: generateArgs({ maxColumns: "2", layout: "homepage" }), |
| 148 | +} |
| 149 | + |
| 150 | +export const WithImage1Columns: Story = { |
| 151 | + name: "With Image (1 Col)", |
| 152 | + args: generateArgs({ maxColumns: "1" }), |
| 153 | +} |
| 154 | + |
| 155 | +export const WithImage1ColumnsHomepage: Story = { |
| 156 | + name: "With Image (1 Col) Homepage", |
| 157 | + args: generateArgs({ maxColumns: "1", layout: "homepage" }), |
95 | 158 | } |
96 | 159 |
|
97 | 160 | export const NoImage: Story = { |
98 | | - args: { |
99 | | - title: "Section title ministry highlights", |
100 | | - subtitle: |
101 | | - "Section subtitle, maximum 150 chars. These are some of the things we are working on. As a ministry, we focus on delivering value to the members of public.", |
102 | | - variant: "cardsWithoutImages", |
103 | | - cards: [ |
104 | | - { |
105 | | - title: |
106 | | - "Testing for a card with a long line length that spans across two lines or more", |
107 | | - description: |
108 | | - "Explore Duxton with us and leave with a full belly, tipsy mind, and a happy smile.", |
109 | | - url: "https://www.google.com", |
110 | | - }, |
111 | | - { |
112 | | - title: "Card with short title", |
113 | | - description: |
114 | | - "Card description, 200 chars. In the kingdom of Veridonia, the government operates as a benevolent monarchy, guided by ancient traditions and the wisdom of its sovereign.", |
115 | | - }, |
116 | | - { |
117 | | - title: "Hover on me to see me change colors", |
118 | | - description: |
119 | | - "Card description, 200 chars. In the kingdom of Veridonia, the government operates as a benevolent monarchy, guided by ancient traditions and the wisdom of its sovereign.", |
120 | | - url: "https://www.google.com", |
121 | | - }, |
122 | | - { |
123 | | - title: "A yummy, tipsy evening at Duxton", |
124 | | - }, |
125 | | - ], |
126 | | - }, |
| 161 | + args: generateArgs({ maxColumns: "3", withoutImage: true }), |
127 | 162 | } |
128 | 163 |
|
129 | 164 | export const WithContainImageFit: Story = { |
130 | | - args: { |
131 | | - title: "Section title ministry highlights", |
132 | | - subtitle: |
133 | | - "Section subtitle, maximum 150 chars. These are some of the things we are working on. As a ministry, we focus on delivering value to the members of public.", |
134 | | - variant: "cardsWithImages", |
135 | | - cards: [ |
136 | | - { |
137 | | - title: |
138 | | - "Testing for a card with a long line length that spans across two lines or more", |
139 | | - description: |
140 | | - "Explore Duxton with us and leave with a full belly, tipsy mind, and a happy smile.", |
141 | | - imageUrl: "https://placehold.co/200x300", |
142 | | - imageAlt: "alt text", |
143 | | - imageFit: "contain", |
144 | | - url: "https://www.google.com", |
145 | | - }, |
146 | | - { |
147 | | - title: "Card with short title", |
148 | | - description: |
149 | | - "Card description, 200 chars. In the kingdom of Veridonia, the government operates as a benevolent monarchy, guided by ancient traditions and the wisdom of its sovereign.", |
150 | | - imageUrl: |
151 | | - "https://craftypixels.com/placeholder-image/800x400/ffffff/000000&text=Image+with+white+background", |
152 | | - imageAlt: "alt text", |
153 | | - imageFit: "contain", |
154 | | - }, |
155 | | - { |
156 | | - title: "Hover on me to see me change colors", |
157 | | - description: |
158 | | - "Card description, 200 chars. In the kingdom of Veridonia, the government operates as a benevolent monarchy, guided by ancient traditions and the wisdom of its sovereign.", |
159 | | - imageUrl: "https://placehold.co/800x200", |
160 | | - imageAlt: "alt text", |
161 | | - url: "https://www.google.com", |
162 | | - imageFit: "contain", |
163 | | - }, |
164 | | - { |
165 | | - title: "Testing a card with a larger image and no description", |
166 | | - imageUrl: "https://placehold.co/500x500", |
167 | | - imageAlt: "alt text", |
168 | | - imageFit: "contain", |
169 | | - }, |
170 | | - { |
171 | | - title: "A non-placeholder image version", |
172 | | - description: "This is an image that is added using a URL.", |
173 | | - imageUrl: |
174 | | - "https://images.unsplash.com/photo-1722260613137-f8f5ac432d69?q=80&w=3570&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", |
175 | | - imageAlt: "alt text", |
176 | | - url: "https://www.google.com", |
177 | | - imageFit: "contain", |
178 | | - }, |
179 | | - ], |
180 | | - }, |
| 165 | + args: generateArgs({ maxColumns: "3", isImageFitContain: true }), |
181 | 166 | } |
0 commit comments