Skip to content

Commit 4682797

Browse files
Merge pull request #14946 from guardian/filter/carousel-card
Product carousel card - V1
2 parents fa9e508 + f584b66 commit 4682797

File tree

3 files changed

+443
-0
lines changed

3 files changed

+443
-0
lines changed
Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
import { css } from '@emotion/react';
2+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
3+
import { productImage } from '../../fixtures/manual/productImage';
4+
import { ArticleDesign, ArticleDisplay, Pillar } from '../lib/articleFormat';
5+
import type { ProductBlockElement } from '../types/content';
6+
import { ProductCarouselCard } from './ProductCarouselCard';
7+
8+
const product = {
9+
_type: 'model.dotcomrendering.pageElements.ProductBlockElement',
10+
elementId: 'b1f6e8e2-3f3a-4f0c-8d1e-5f3e3e3e3e3e',
11+
primaryHeadingHtml: 'Best Kettle overall',
12+
secondaryHeadingHtml: 'Bosch Sky Kettle',
13+
brandName: 'Bosch',
14+
productName: 'Sky Kettle',
15+
image: productImage,
16+
displayType: 'InlineWithProductCard',
17+
lowestPrice: '£39.99',
18+
customAttributes: [
19+
{ name: 'What we love', value: 'It pours well and looks great' },
20+
{
21+
name: "What we don't love",
22+
value: 'The handle feels a bit cheap compared to the rest of it',
23+
},
24+
],
25+
productCtas: [
26+
{
27+
url: 'https://www.johnlewis.com/bosch-twk7203gb-sky-variable-temperature-kettle-1-7l-black/p3228625',
28+
text: '',
29+
retailer: 'John Lewis',
30+
price: '£45.99',
31+
},
32+
{
33+
url: 'https://www.amazon.co.uk/Bosch-TWK7203GB-Sky-Variable-Temperature/dp/B07Z8VQ2V6',
34+
text: '',
35+
retailer: 'Amazon',
36+
price: '£39.99',
37+
},
38+
],
39+
starRating: 'none-selected',
40+
content: [
41+
{
42+
displayCredit: true,
43+
_type: 'model.dotcomrendering.pageElements.ImageBlockElement',
44+
role: 'inline',
45+
media: {
46+
allImages: [
47+
{
48+
index: 0,
49+
fields: {
50+
height: '3213',
51+
width: '3213',
52+
},
53+
mediaType: 'Image',
54+
mimeType: 'image/jpeg',
55+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/3213.jpg',
56+
},
57+
{
58+
index: 1,
59+
fields: {
60+
isMaster: 'true',
61+
height: '3213',
62+
width: '3213',
63+
},
64+
mediaType: 'Image',
65+
mimeType: 'image/jpeg',
66+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
67+
},
68+
{
69+
index: 2,
70+
fields: {
71+
height: '2000',
72+
width: '2000',
73+
},
74+
mediaType: 'Image',
75+
mimeType: 'image/jpeg',
76+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/2000.jpg',
77+
},
78+
{
79+
index: 3,
80+
fields: {
81+
height: '1000',
82+
width: '1000',
83+
},
84+
mediaType: 'Image',
85+
mimeType: 'image/jpeg',
86+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/1000.jpg',
87+
},
88+
{
89+
index: 4,
90+
fields: {
91+
height: '500',
92+
width: '500',
93+
},
94+
mediaType: 'Image',
95+
mimeType: 'image/jpeg',
96+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/500.jpg',
97+
},
98+
{
99+
index: 5,
100+
fields: {
101+
height: '140',
102+
width: '140',
103+
},
104+
mediaType: 'Image',
105+
mimeType: 'image/jpeg',
106+
url: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/140.jpg',
107+
},
108+
],
109+
},
110+
elementId: '76686aa1-2e47-4616-b4ed-a88d0afe07ed',
111+
imageSources: [
112+
{
113+
weighting: 'inline',
114+
srcSet: [
115+
{
116+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
117+
width: 620,
118+
},
119+
{
120+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
121+
width: 1240,
122+
},
123+
{
124+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
125+
width: 605,
126+
},
127+
{
128+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
129+
width: 1210,
130+
},
131+
{
132+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
133+
width: 445,
134+
},
135+
{
136+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
137+
width: 890,
138+
},
139+
],
140+
},
141+
{
142+
weighting: 'thumbnail',
143+
srcSet: [
144+
{
145+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
146+
width: 140,
147+
},
148+
{
149+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
150+
width: 280,
151+
},
152+
{
153+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
154+
width: 120,
155+
},
156+
{
157+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
158+
width: 240,
159+
},
160+
],
161+
},
162+
{
163+
weighting: 'supporting',
164+
srcSet: [
165+
{
166+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
167+
width: 380,
168+
},
169+
{
170+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
171+
width: 760,
172+
},
173+
{
174+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
175+
width: 300,
176+
},
177+
{
178+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
179+
width: 600,
180+
},
181+
{
182+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
183+
width: 620,
184+
},
185+
{
186+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
187+
width: 1240,
188+
},
189+
{
190+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
191+
width: 605,
192+
},
193+
{
194+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
195+
width: 1210,
196+
},
197+
{
198+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
199+
width: 445,
200+
},
201+
{
202+
src: 'https://media.guimcode.co.uk/bacede2d976c26d6a224ede074d5634a3f1d304f/0_0_3213_3213/master/3213.jpg',
203+
width: 890,
204+
},
205+
],
206+
},
207+
],
208+
data: {
209+
alt: 'Testing Bosch Sky Kettle',
210+
credit: 'Photograph: Rachel Ogden/The Guardian',
211+
},
212+
},
213+
{
214+
_type: 'model.dotcomrendering.pageElements.LinkBlockElement',
215+
url: 'https://www.johnlewis.com/bosch-twk7203gb-sky-variable-temperature-kettle-1-7l-black/p3228625',
216+
label: '£79.99 at John Lewis',
217+
linkType: 'ProductButton',
218+
},
219+
{
220+
_type: 'model.dotcomrendering.pageElements.LinkBlockElement',
221+
url: 'https://www.amazon.co.uk/Bosch-TWK7203GB-Sky-Variable-Temperature/dp/B07Z8VQ2V6',
222+
label: '£79.99 at Amazon',
223+
linkType: 'ProductButton',
224+
},
225+
{
226+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
227+
html: '<p>Offering variable temperatures and a double-walled stainless-steel housing, the 3kW Sky is a brilliant blend of robust form and function. It boasts a low minimum boil (300ml), a keep-warm setting and touch controls.</p>',
228+
elementId: '4a27eb68-6a03-4e82-a7d0-e4f1ef3ccb6f',
229+
},
230+
{
231+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
232+
html: '<p><strong>Why we love it<br></strong>I found it difficult to select a best kettle from so many that performed well, but the Bosch Sky clinched it because it’s such a good all-rounder that will suit most people. It pours well, has a button that’s within easy reach of the handle so it’s simple to open the lid without touching it, and it’s insulated so the exterior doesn’t become too hot to touch. From a design perspective, it has a more industrial feel than many others – no frippery here – but not too modern that it wouldn’t fit into most kitchens. Its display is thoughtfully designed, easy to keep clean and lights up as it heats.</p>',
233+
elementId: 'f48f03d4-bece-4763-874b-4027a311643e',
234+
},
235+
{
236+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
237+
html: '<p>The exterior doesn’t get too hot (up to 40C), and while it wasn’t the fastest to boil in testing, it was only seconds behind the Dualit below. It clicked off at boiling point, and the water was still a toasty 78C 30 minutes later. At the hour point, it was 66C, and two hours 52C, meaning you’ll spend less time and energy reboiling.</p>',
238+
elementId: 'df571922-33b1-416a-8b3d-ee756b638cc1',
239+
},
240+
{
241+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
242+
html: '<p><strong>It’s a shame that … </strong> its premium look ends at the handle, which seems cheap and plasticky next to the sleek aesthetic of the rest of it.</p>',
243+
elementId: 'd98fc724-8908-46e2-acc6-4739ad4d5719',
244+
},
245+
],
246+
} satisfies ProductBlockElement;
247+
248+
const meta = {
249+
component: ProductCarouselCard,
250+
title: 'Components/ProductCarouselCard',
251+
args: {
252+
product,
253+
format: {
254+
design: ArticleDesign.Standard,
255+
display: ArticleDisplay.Standard,
256+
theme: Pillar.Lifestyle,
257+
},
258+
},
259+
render: (args) => (
260+
<div
261+
css={css`
262+
width: 280px;
263+
`}
264+
>
265+
<ProductCarouselCard {...args} />
266+
</div>
267+
),
268+
} satisfies Meta<typeof ProductCarouselCard>;
269+
270+
export default meta;
271+
272+
type Story = StoryObj<typeof meta>;
273+
274+
export const Default = {} satisfies Story;
275+
276+
export const WithLongHeadingProductNameAndCTA = {
277+
args: {
278+
product: {
279+
...product,
280+
primaryHeadingHtml: 'Super long product category review name',
281+
productName:
282+
'Sky Kettle with a super duper long name that goes on and on',
283+
productCtas: [
284+
{
285+
url: 'https://www.johnlewis.com/bosch-twk7203gb-sky-variable-temperature-kettle-1-7l-black/p3228625',
286+
text: '',
287+
retailer: 'John Lewis with a very long name',
288+
price: '£45.99',
289+
},
290+
],
291+
},
292+
},
293+
} satisfies Story;

0 commit comments

Comments
 (0)