@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.
- package/CHANGELOG.md +9 -8
- package/app/components/dynamic-image/index.jsx +91 -16
- package/app/components/dynamic-image/index.test.js +214 -30
- package/app/components/image/index.jsx +5 -13
- package/app/components/image/index.test.js +6 -3
- package/app/components/island/README.md +15 -10
- package/app/components/island/index.jsx +12 -5
- package/app/components/island/index.test.js +35 -0
- package/app/components/passwordless-login/index.jsx +4 -5
- package/app/components/passwordless-login/index.test.js +2 -4
- package/app/components/product-tile/index.jsx +1 -1
- package/app/components/product-view-modal/bundle.jsx +12 -2
- package/app/components/social-login/index.jsx +1 -0
- package/app/components/standard-login/index.jsx +4 -1
- package/app/constants.js +3 -0
- package/app/hooks/use-auth-modal.js +68 -67
- package/app/hooks/use-auth-modal.test.js +93 -23
- package/app/hooks/use-datacloud.js +169 -192
- package/app/hooks/use-datacloud.test.js +273 -17
- package/app/pages/cart/index.jsx +2 -1
- package/app/pages/cart/partials/cart-secondary-button-group.jsx +8 -10
- package/app/pages/cart/partials/cart-secondary-button-group.test.js +2 -3
- package/app/pages/checkout/partials/contact-info.jsx +9 -8
- package/app/pages/checkout/partials/contact-info.test.js +41 -4
- package/app/pages/checkout/partials/login-state.jsx +3 -3
- package/app/pages/home/index.test.js +2 -1
- package/app/pages/login/index.jsx +37 -37
- package/app/pages/login/index.test.js +42 -0
- package/app/pages/product-detail/index.jsx +64 -73
- package/app/pages/product-list/index.jsx +19 -9
- package/app/pages/product-list/index.test.js +153 -19
- package/app/utils/image.js +29 -0
- package/app/utils/image.test.js +141 -1
- package/app/utils/responsive-image.js +197 -115
- package/app/utils/responsive-image.test.js +483 -133
- package/config/default.js +2 -2
- package/config/mocks/default.js +2 -2
- package/package.json +7 -7
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
-
|
|
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
|
|
21
|
-
const uniqueArray = [...new Set(pxWidths)]
|
|
22
|
-
const widths = uniqueArray.sort()
|
|
20
|
+
const urlWithWidth = (width) => getSrc(disImageURL.withOptionalParams, width)
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
// Breakpoints (1em = 16px)
|
|
30
|
+
// sm: "30em",
|
|
31
|
+
// md: "48em",
|
|
32
|
+
// lg: "62em",
|
|
33
|
+
// xl: "80em",
|
|
34
|
+
// "2xl": "96em",
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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('
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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('
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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('
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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: '
|
|
59
|
-
tenantId: '
|
|
58
|
+
appSourceId: '7ae070a6-f4ec-4def-a383-d9cacc3f20a1',
|
|
59
|
+
tenantId: 'g82wgnrvm-ywk9dggrrw8mtggy.pc-rnd'
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
externals: [],
|
package/config/mocks/default.js
CHANGED
|
@@ -97,8 +97,8 @@ module.exports = {
|
|
|
97
97
|
isProduction: false
|
|
98
98
|
},
|
|
99
99
|
dataCloudAPI: {
|
|
100
|
-
appSourceId: '
|
|
101
|
-
tenantId: '
|
|
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
|