@salesforce/retail-react-app 7.0.0-preview.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +9 -8
  2. package/app/components/dynamic-image/index.jsx +91 -16
  3. package/app/components/dynamic-image/index.test.js +214 -30
  4. package/app/components/image/index.jsx +5 -13
  5. package/app/components/image/index.test.js +6 -3
  6. package/app/components/island/README.md +15 -10
  7. package/app/components/island/index.jsx +12 -5
  8. package/app/components/island/index.test.js +35 -0
  9. package/app/components/passwordless-login/index.jsx +4 -5
  10. package/app/components/passwordless-login/index.test.js +2 -4
  11. package/app/components/product-tile/index.jsx +1 -1
  12. package/app/components/product-view-modal/bundle.jsx +12 -2
  13. package/app/components/social-login/index.jsx +1 -0
  14. package/app/components/standard-login/index.jsx +4 -1
  15. package/app/constants.js +3 -0
  16. package/app/hooks/use-auth-modal.js +68 -67
  17. package/app/hooks/use-auth-modal.test.js +93 -23
  18. package/app/hooks/use-datacloud.js +169 -192
  19. package/app/hooks/use-datacloud.test.js +273 -17
  20. package/app/pages/cart/index.jsx +2 -1
  21. package/app/pages/cart/partials/cart-secondary-button-group.jsx +8 -10
  22. package/app/pages/cart/partials/cart-secondary-button-group.test.js +2 -3
  23. package/app/pages/checkout/partials/contact-info.jsx +9 -8
  24. package/app/pages/checkout/partials/contact-info.test.js +41 -4
  25. package/app/pages/checkout/partials/login-state.jsx +3 -3
  26. package/app/pages/home/index.test.js +2 -1
  27. package/app/pages/login/index.jsx +37 -37
  28. package/app/pages/login/index.test.js +42 -0
  29. package/app/pages/product-detail/index.jsx +64 -73
  30. package/app/pages/product-list/index.jsx +19 -9
  31. package/app/pages/product-list/index.test.js +153 -19
  32. package/app/utils/image.js +29 -0
  33. package/app/utils/image.test.js +141 -1
  34. package/app/utils/responsive-image.js +197 -115
  35. package/app/utils/responsive-image.test.js +483 -133
  36. package/config/default.js +2 -2
  37. package/config/mocks/default.js +2 -2
  38. package/package.json +7 -7
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import {
9
- getResponsiveImageAttributes,
9
+ getResponsivePictureAttributes,
10
10
  getSrc
11
11
  } from '@salesforce/retail-react-app/app/utils/responsive-image'
12
12
 
@@ -17,154 +17,504 @@ const disImageURL = {
17
17
  'https://edge.disstg.commercecloud.salesforce.com/dw/image/v2/ZZRF_001/on/demandware.static/-/Sites-apparel-m-catalog/default/dw1e4fcb17/images/large/PG.10212867.JJ3XYXX.PZ.jpg'
18
18
  }
19
19
 
20
- const buildSrcSet = (pxWidths) => {
21
- const uniqueArray = [...new Set(pxWidths)]
22
- const widths = uniqueArray.sort()
20
+ const urlWithWidth = (width) => getSrc(disImageURL.withOptionalParams, width)
23
21
 
24
- return widths
25
- .map((width) => {
26
- return `${urlWithWidth(width)} ${width}w, ${urlWithWidth(width * 2)} ${width * 2}w`
22
+ describe('getResponsivePictureAttributes()', () => {
23
+ test('vw widths', () => {
24
+ let props = getResponsivePictureAttributes({
25
+ src: disImageURL.withOptionalParams,
26
+ widths: ['50vw', '50vw', '20vw', '20vw', '25vw']
27
27
  })
28
- .join(', ')
29
- }
30
- const urlWithWidth = (width) => getSrc(disImageURL.withOptionalParams, width)
31
28
 
32
- test('vw widths', () => {
33
- let props = getResponsiveImageAttributes({
34
- src: disImageURL.withOptionalParams,
35
- widths: ['100vw', '100vw', '50vw']
36
- })
29
+ // Breakpoints (1em = 16px)
30
+ // sm: "30em",
31
+ // md: "48em",
32
+ // lg: "62em",
33
+ // xl: "80em",
34
+ // "2xl": "96em",
37
35
 
38
- // Breakpoints
39
- // sm: "30em",
40
- // md: "48em",
41
- // lg: "62em",
42
- // xl: "80em",
43
- // "2xl": "96em",
44
-
45
- // 100vw of sm => 30em => 30 * 16 = 480px
46
- // 100vw of md => 48em => 768px
47
- // 50vw of lg => 31em => 496px
48
- // 50vw of xl => 40em => 640
49
- // 50vw of 2xl => 48em => 768px
50
-
51
- expect(props).toStrictEqual({
52
- src: disImageURL.withoutOptionalParams,
53
- sizes: '(min-width: 48em) 50vw, (min-width: 30em) 100vw, 100vw',
54
- srcSet: buildSrcSet([480, 768, 496, 640, 768])
55
- })
36
+ // 50vw of sm => 15em => 240px
37
+ // 50vw of md => 24em => 384px
38
+ // 20vw of lg => 12.4em => 198px
39
+ // 20vw of xl => 16em => 256px
40
+ // 25vw of 2xl => 24em => 384px
56
41
 
57
- // This time as _object_
58
- props = getResponsiveImageAttributes({
59
- src: disImageURL.withOptionalParams,
60
- widths: {
61
- base: '100vw',
62
- sm: '100vw',
63
- md: '50vw'
64
- }
65
- })
66
- expect(props).toStrictEqual({
67
- src: disImageURL.withoutOptionalParams,
68
- sizes: '(min-width: 48em) 50vw, (min-width: 30em) 100vw, 100vw',
69
- srcSet: buildSrcSet([480, 768, 496, 640, 768])
70
- })
42
+ expect(props).toStrictEqual({
43
+ src: disImageURL.withoutOptionalParams,
44
+ sources: [
45
+ {
46
+ media: '(min-width: 80em)',
47
+ sizes: '25vw',
48
+ srcSet: [384, 768].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
49
+ },
50
+ {
51
+ media: '(min-width: 62em)',
52
+ sizes: '20vw',
53
+ srcSet: [256, 512].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
54
+ },
55
+ {
56
+ media: '(min-width: 48em)',
57
+ sizes: '20vw',
58
+ srcSet: [198, 396].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
59
+ },
60
+ {
61
+ media: '(min-width: 30em)',
62
+ sizes: '50vw',
63
+ srcSet: [384, 768].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
64
+ },
65
+ {
66
+ media: undefined,
67
+ sizes: '50vw',
68
+ srcSet: [240, 480].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
69
+ }
70
+ ],
71
+ links: [
72
+ {
73
+ media: '(max-width: 29.99em)',
74
+ sizes: '50vw',
75
+ srcSet: [240, 480].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
76
+ },
77
+ {
78
+ media: '(min-width: 30em) and (max-width: 47.99em)',
79
+ sizes: '50vw',
80
+ srcSet: [384, 768].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
81
+ },
82
+ {
83
+ media: '(min-width: 48em) and (max-width: 61.99em)',
84
+ sizes: '20vw',
85
+ srcSet: [198, 396].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
86
+ },
87
+ {
88
+ media: '(min-width: 62em) and (max-width: 79.99em)',
89
+ sizes: '20vw',
90
+ srcSet: [256, 512].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
91
+ },
92
+ {
93
+ media: '(min-width: 80em)',
94
+ sizes: '25vw',
95
+ srcSet: [384, 768].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
96
+ }
97
+ ]
98
+ })
71
99
 
72
- // Edge case: testing changing width at the very last breakpoint (2xl)
73
- props = getResponsiveImageAttributes({
74
- src: disImageURL.withOptionalParams,
75
- widths: {
76
- base: '100vw',
77
- '2xl': '50vw'
78
- }
79
- })
80
- // 100vw of sm => 30em => 30 * 16 = 480px
81
- // 100vw of md => 48em => 768px
82
- // 100vw of lg => 62em => 992px
83
- // 100vw of xl => 80em => 1280px
84
- // 100vw of 2xl => 96em => 1536px
85
- // 50vw of 2xl => 48em => 768px
86
- expect(props).toStrictEqual({
87
- src: disImageURL.withoutOptionalParams,
88
- sizes: '(min-width: 96em) 50vw, (min-width: 80em) 100vw, (min-width: 62em) 100vw, (min-width: 48em) 100vw, (min-width: 30em) 100vw, 100vw',
89
- srcSet: buildSrcSet([480, 768, 992, 1280, 1536, 768])
90
- })
91
- })
100
+ // This time as _object_
101
+ props = getResponsivePictureAttributes({
102
+ src: disImageURL.withOptionalParams,
103
+ widths: {
104
+ base: '100vw',
105
+ sm: '100vw',
106
+ md: '50vw'
107
+ }
108
+ })
109
+ expect(props).toStrictEqual({
110
+ src: disImageURL.withoutOptionalParams,
111
+ sources: [
112
+ {
113
+ media: '(min-width: 80em)',
114
+ sizes: '50vw',
115
+ srcSet: [768, 1536]
116
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
117
+ .join(', ')
118
+ },
119
+ {
120
+ media: '(min-width: 62em)',
121
+ sizes: '50vw',
122
+ srcSet: [640, 1280]
123
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
124
+ .join(', ')
125
+ },
126
+ {
127
+ media: '(min-width: 48em)',
128
+ sizes: '50vw',
129
+ srcSet: [496, 992].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
130
+ },
131
+ {
132
+ media: '(min-width: 30em)',
133
+ sizes: '100vw',
134
+ srcSet: [768, 1536]
135
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
136
+ .join(', ')
137
+ },
138
+ {
139
+ media: undefined,
140
+ sizes: '100vw',
141
+ srcSet: [480, 960].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
142
+ }
143
+ ],
144
+ links: [
145
+ {
146
+ media: '(max-width: 29.99em)',
147
+ sizes: '100vw',
148
+ srcSet: [480, 960].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
149
+ },
150
+ {
151
+ media: '(min-width: 30em) and (max-width: 47.99em)',
152
+ sizes: '100vw',
153
+ srcSet: [768, 1536]
154
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
155
+ .join(', ')
156
+ },
157
+ {
158
+ media: '(min-width: 48em) and (max-width: 61.99em)',
159
+ sizes: '50vw',
160
+ srcSet: [496, 992].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
161
+ },
162
+ {
163
+ media: '(min-width: 62em) and (max-width: 79.99em)',
164
+ sizes: '50vw',
165
+ srcSet: [640, 1280]
166
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
167
+ .join(', ')
168
+ },
169
+ {
170
+ media: '(min-width: 80em)',
171
+ sizes: '50vw',
172
+ srcSet: [768, 1536]
173
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
174
+ .join(', ')
175
+ }
176
+ ]
177
+ })
92
178
 
93
- test('px values', () => {
94
- // widths in array format
95
- let props = getResponsiveImageAttributes({
96
- src: disImageURL.withOptionalParams,
97
- widths: [100, 500, 1000]
98
- })
99
- expect(props).toStrictEqual({
100
- src: disImageURL.withoutOptionalParams,
101
- sizes: '(min-width: 48em) 1000px, (min-width: 30em) 500px, 100px',
102
- srcSet: buildSrcSet([100, 500, 1000])
103
- })
179
+ // Edge case: testing changing width at the very last breakpoint (2xl)
180
+ props = getResponsivePictureAttributes({
181
+ src: disImageURL.withOptionalParams,
182
+ widths: {
183
+ base: '100vw',
184
+ '2xl': '50vw'
185
+ }
186
+ })
104
187
 
105
- // widths in object format
106
- props = getResponsiveImageAttributes({
107
- src: disImageURL.withOptionalParams,
108
- widths: {
109
- base: 100,
110
- sm: 500,
111
- md: 1000
112
- }
113
- })
114
- expect(props).toStrictEqual({
115
- src: disImageURL.withoutOptionalParams,
116
- sizes: '(min-width: 48em) 1000px, (min-width: 30em) 500px, 100px',
117
- srcSet: buildSrcSet([100, 500, 1000])
188
+ // 100vw of sm => 30em => 480px
189
+ // 100vw of md => 48em => 768px
190
+ // 100vw of lg => 62em => 992px
191
+ // 100vw of xl => 80em => 1280px
192
+ // 100vw of 2xl => 96em => 1536px
193
+ // 50vw of 2xl => 48em => 768px
194
+ expect(props).toStrictEqual({
195
+ src: disImageURL.withoutOptionalParams,
196
+ sources: [
197
+ {
198
+ media: '(min-width: 96em)',
199
+ sizes: '50vw',
200
+ srcSet: [768, 1536]
201
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
202
+ .join(', ')
203
+ },
204
+ {
205
+ media: '(min-width: 80em)',
206
+ sizes: '100vw',
207
+ srcSet: [1536, 3072]
208
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
209
+ .join(', ')
210
+ },
211
+ {
212
+ media: '(min-width: 62em)',
213
+ sizes: '100vw',
214
+ srcSet: [1280, 2560]
215
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
216
+ .join(', ')
217
+ },
218
+ {
219
+ media: '(min-width: 48em)',
220
+ sizes: '100vw',
221
+ srcSet: [992, 1984]
222
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
223
+ .join(', ')
224
+ },
225
+ {
226
+ media: '(min-width: 30em)',
227
+ sizes: '100vw',
228
+ srcSet: [768, 1536]
229
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
230
+ .join(', ')
231
+ },
232
+ {
233
+ media: undefined,
234
+ sizes: '100vw',
235
+ srcSet: [480, 960].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
236
+ }
237
+ ],
238
+ links: [
239
+ {
240
+ media: '(max-width: 29.99em)',
241
+ sizes: '100vw',
242
+ srcSet: [480, 960].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
243
+ },
244
+ {
245
+ media: '(min-width: 30em) and (max-width: 47.99em)',
246
+ sizes: '100vw',
247
+ srcSet: [768, 1536]
248
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
249
+ .join(', ')
250
+ },
251
+ {
252
+ media: '(min-width: 48em) and (max-width: 61.99em)',
253
+ sizes: '100vw',
254
+ srcSet: [992, 1984]
255
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
256
+ .join(', ')
257
+ },
258
+ {
259
+ media: '(min-width: 62em) and (max-width: 79.99em)',
260
+ sizes: '100vw',
261
+ srcSet: [1280, 2560]
262
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
263
+ .join(', ')
264
+ },
265
+ {
266
+ media: '(min-width: 80em) and (max-width: 95.99em)',
267
+ sizes: '100vw',
268
+ srcSet: [1536, 3072]
269
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
270
+ .join(', ')
271
+ },
272
+ {
273
+ media: '(min-width: 96em)',
274
+ sizes: '50vw',
275
+ srcSet: [768, 1536]
276
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
277
+ .join(', ')
278
+ }
279
+ ]
280
+ })
118
281
  })
119
- })
120
282
 
121
- test('mixture of px and vw values', () => {
122
- let props = getResponsiveImageAttributes({
123
- src: disImageURL.withOptionalParams,
124
- widths: ['100vw', '720px', 500]
125
- })
126
- // 100vw of sm => 30em => 30 * 16 = 480px
283
+ test('px values', () => {
284
+ // widths in array format
285
+ let props = getResponsivePictureAttributes({
286
+ src: disImageURL.withOptionalParams,
287
+ widths: [100, 500, 1000]
288
+ })
289
+ expect(props).toStrictEqual({
290
+ src: disImageURL.withoutOptionalParams,
291
+ sources: [
292
+ {
293
+ media: '(min-width: 48em)',
294
+ sizes: '1000px',
295
+ srcSet: [1000, 2000]
296
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
297
+ .join(', ')
298
+ },
299
+ {
300
+ media: '(min-width: 30em)',
301
+ sizes: '500px',
302
+ srcSet: [500, 1000]
303
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
304
+ .join(', ')
305
+ },
306
+ {
307
+ media: undefined,
308
+ sizes: '100px',
309
+ srcSet: [100, 200].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
310
+ }
311
+ ],
312
+ links: [
313
+ {
314
+ media: '(max-width: 29.99em)',
315
+ sizes: '100px',
316
+ srcSet: [100, 200].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
317
+ },
318
+ {
319
+ media: '(min-width: 30em) and (max-width: 47.99em)',
320
+ sizes: '500px',
321
+ srcSet: [500, 1000]
322
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
323
+ .join(', ')
324
+ },
325
+ {
326
+ media: '(min-width: 48em)',
327
+ sizes: '1000px',
328
+ srcSet: [1000, 2000]
329
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
330
+ .join(', ')
331
+ }
332
+ ]
333
+ })
127
334
 
128
- expect(props).toStrictEqual({
129
- src: disImageURL.withoutOptionalParams,
130
- sizes: '(min-width: 48em) 500px, (min-width: 30em) 720px, 100vw',
131
- srcSet: buildSrcSet([480, 500, 720])
335
+ props = getResponsivePictureAttributes({
336
+ src: disImageURL.withOptionalParams,
337
+ widths: {
338
+ base: 100,
339
+ sm: 500,
340
+ md: 1000,
341
+ '2xl': 500
342
+ }
343
+ })
344
+ expect(props).toStrictEqual({
345
+ src: disImageURL.withoutOptionalParams,
346
+ sources: [
347
+ {
348
+ media: '(min-width: 96em)',
349
+ sizes: '500px',
350
+ srcSet: [500, 1000]
351
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
352
+ .join(', ')
353
+ },
354
+ {
355
+ media: '(min-width: 48em)',
356
+ sizes: '1000px',
357
+ srcSet: [1000, 2000]
358
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
359
+ .join(', ')
360
+ },
361
+ {
362
+ media: '(min-width: 30em)',
363
+ sizes: '500px',
364
+ srcSet: [500, 1000]
365
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
366
+ .join(', ')
367
+ },
368
+ {
369
+ media: undefined,
370
+ sizes: '100px',
371
+ srcSet: [100, 200].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
372
+ }
373
+ ],
374
+ links: [
375
+ {
376
+ media: '(max-width: 29.99em)',
377
+ sizes: '100px',
378
+ srcSet: [100, 200].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
379
+ },
380
+ {
381
+ media: '(min-width: 30em) and (max-width: 47.99em)',
382
+ sizes: '500px',
383
+ srcSet: [500, 1000]
384
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
385
+ .join(', ')
386
+ },
387
+ {
388
+ media: '(min-width: 48em) and (max-width: 95.99em)',
389
+ sizes: '1000px',
390
+ srcSet: [1000, 2000]
391
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
392
+ .join(', ')
393
+ },
394
+ {
395
+ media: '(min-width: 96em)',
396
+ sizes: '500px',
397
+ srcSet: [500, 1000]
398
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
399
+ .join(', ')
400
+ }
401
+ ]
402
+ })
132
403
  })
133
- })
134
404
 
135
- test('only src', () => {
136
- let props = getResponsiveImageAttributes({
137
- src: disImageURL.withoutOptionalParams
138
- })
139
- expect(props).toStrictEqual({
140
- src: disImageURL.withoutOptionalParams
141
- })
405
+ test('mixture of px and vw values', () => {
406
+ let props = getResponsivePictureAttributes({
407
+ src: disImageURL.withOptionalParams,
408
+ widths: ['100vw', '720px', 500]
409
+ })
142
410
 
143
- // This time _with_ the optional params
144
- props = getResponsiveImageAttributes({
145
- src: disImageURL.withOptionalParams
146
- })
147
- expect(props).toStrictEqual({
148
- src: disImageURL.withoutOptionalParams
411
+ expect(props).toStrictEqual({
412
+ src: disImageURL.withoutOptionalParams,
413
+ sources: [
414
+ {
415
+ media: '(min-width: 48em)',
416
+ sizes: '500px',
417
+ srcSet: [500, 1000]
418
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
419
+ .join(', ')
420
+ },
421
+ {
422
+ media: '(min-width: 30em)',
423
+ sizes: '720px',
424
+ srcSet: [720, 1440]
425
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
426
+ .join(', ')
427
+ },
428
+ {
429
+ media: undefined,
430
+ sizes: '100vw',
431
+ srcSet: [480, 960].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
432
+ }
433
+ ],
434
+ links: [
435
+ {
436
+ media: '(max-width: 29.99em)',
437
+ sizes: '100vw',
438
+ srcSet: [480, 960].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
439
+ },
440
+ {
441
+ media: '(min-width: 30em) and (max-width: 47.99em)',
442
+ sizes: '720px',
443
+ srcSet: [720, 1440]
444
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
445
+ .join(', ')
446
+ },
447
+ {
448
+ media: '(min-width: 48em)',
449
+ sizes: '500px',
450
+ srcSet: [500, 1000]
451
+ .map((width) => `${urlWithWidth(width)} ${width}w`)
452
+ .join(', ')
453
+ }
454
+ ]
455
+ })
149
456
  })
150
- })
151
457
 
152
- test('passing in theme breakpoints', () => {
153
- const props = getResponsiveImageAttributes({
154
- src: disImageURL.withOptionalParams,
155
- widths: ['100vw', 360],
156
- breakpoints: {
157
- base: '0px',
158
- sm: '320px',
159
- md: '768px',
160
- lg: '960px',
161
- xl: '1200px',
162
- '2xl': '1536px'
163
- }
458
+ test('only src', () => {
459
+ let props = getResponsivePictureAttributes({
460
+ src: disImageURL.withoutOptionalParams
461
+ })
462
+ expect(props).toStrictEqual({
463
+ sources: [],
464
+ links: [],
465
+ src: disImageURL.withoutOptionalParams
466
+ })
467
+
468
+ // This time _with_ the optional params
469
+ props = getResponsivePictureAttributes({
470
+ src: disImageURL.withOptionalParams
471
+ })
472
+ expect(props).toStrictEqual({
473
+ sources: [],
474
+ links: [],
475
+ src: disImageURL.withoutOptionalParams
476
+ })
164
477
  })
165
- expect(props).toStrictEqual({
166
- src: disImageURL.withoutOptionalParams,
167
- sizes: '(min-width: 320px) 360px, 100vw',
168
- srcSet: buildSrcSet([320, 360])
478
+
479
+ test('passing in theme breakpoints', () => {
480
+ const props = getResponsivePictureAttributes({
481
+ src: disImageURL.withOptionalParams,
482
+ widths: ['100vw', 360],
483
+ breakpoints: {
484
+ base: '0px',
485
+ sm: '320px',
486
+ md: '768px',
487
+ lg: '960px',
488
+ xl: '1200px',
489
+ '2xl': '1536px'
490
+ }
491
+ })
492
+ expect(props).toStrictEqual({
493
+ src: disImageURL.withoutOptionalParams,
494
+ sources: [
495
+ {
496
+ media: '(min-width: 320px)',
497
+ sizes: '360px',
498
+ srcSet: [360, 720].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
499
+ },
500
+ {
501
+ media: undefined,
502
+ sizes: '100vw',
503
+ srcSet: [320, 640].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
504
+ }
505
+ ],
506
+ links: [
507
+ {
508
+ media: '(max-width: 319px)',
509
+ sizes: '100vw',
510
+ srcSet: [320, 640].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
511
+ },
512
+ {
513
+ media: '(min-width: 320px)',
514
+ sizes: '360px',
515
+ srcSet: [360, 720].map((width) => `${urlWithWidth(width)} ${width}w`).join(', ')
516
+ }
517
+ ]
518
+ })
169
519
  })
170
520
  })
package/config/default.js CHANGED
@@ -55,8 +55,8 @@ module.exports = {
55
55
  isProduction: false
56
56
  },
57
57
  dataCloudAPI: {
58
- appSourceId: 'f22ae831-ac03-4bf6-afc1-3a0b19f1ea8e',
59
- tenantId: 'mmydmztgh04dczjzmnsw0zd0g8.pc-rnd'
58
+ appSourceId: '7ae070a6-f4ec-4def-a383-d9cacc3f20a1',
59
+ tenantId: 'g82wgnrvm-ywk9dggrrw8mtggy.pc-rnd'
60
60
  }
61
61
  },
62
62
  externals: [],
@@ -97,8 +97,8 @@ module.exports = {
97
97
  isProduction: false
98
98
  },
99
99
  dataCloudAPI: {
100
- appSourceId: 'f22ae831-ac03-4bf6-afc1-3a0b19f1ea8e',
101
- tenantId: 'mmydmztgh04dczjzmnsw0zd0g8.pc-rnd'
100
+ appSourceId: '7ae070a6-f4ec-4def-a383-d9cacc3f20a1',
101
+ tenantId: 'g82wgnrvm-ywk9dggrrw8mtggy.pc-rnd'
102
102
  }
103
103
  },
104
104
  // This list contains server-side only libraries that you don't want to be compiled by webpack