@wordpress/edit-site 6.0.3 → 6.0.4
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/build/components/add-new-page/index.js +7 -1
- package/build/components/add-new-page/index.js.map +1 -1
- package/build/components/add-new-pattern/index.js +30 -16
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/page-pages/index.js +38 -6
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/index.js +8 -2
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-templates/index.js +10 -3
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +4 -4
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +20 -88
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/components/add-new-page/index.js +8 -2
- package/build-module/components/add-new-page/index.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +30 -16
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/page-pages/index.js +38 -6
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +8 -2
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +10 -3
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +5 -5
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +19 -86
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-style/style-rtl.css +13 -12
- package/build-style/style.css +13 -12
- package/package.json +17 -17
- package/src/components/add-new-page/index.js +14 -1
- package/src/components/add-new-pattern/index.js +37 -23
- package/src/components/block-editor/style.scss +0 -11
- package/src/components/page-pages/index.js +45 -11
- package/src/components/page-patterns/index.js +8 -2
- package/src/components/page-templates/index.js +9 -2
- package/src/components/sidebar-dataviews/default-views.js +13 -5
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +1 -875
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +29 -117
- package/src/style.scss +13 -0
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { renderHook } from '@testing-library/react';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
9
|
-
import
|
|
4
|
+
import {
|
|
10
5
|
filterObjectByProperty,
|
|
11
6
|
removePropertyFromObject,
|
|
12
7
|
} from '../use-theme-style-variations-by-property';
|
|
@@ -95,875 +90,6 @@ describe( 'filterObjectByProperty', () => {
|
|
|
95
90
|
);
|
|
96
91
|
} );
|
|
97
92
|
|
|
98
|
-
describe( 'useThemeStyleVariationsByProperty', () => {
|
|
99
|
-
const mockVariations = [
|
|
100
|
-
{
|
|
101
|
-
title: 'Title 1',
|
|
102
|
-
description: 'Description 1',
|
|
103
|
-
settings: {
|
|
104
|
-
color: {
|
|
105
|
-
duotone: [
|
|
106
|
-
{
|
|
107
|
-
name: 'Dark grayscale',
|
|
108
|
-
colors: [ '#000000', '#7f7f7f' ],
|
|
109
|
-
slug: 'dark-grayscale',
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: 'Grayscale',
|
|
113
|
-
colors: [ '#000000', '#ffffff' ],
|
|
114
|
-
slug: 'grayscale',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: 'Purple and yellow',
|
|
118
|
-
colors: [ '#8c00b7', '#fcff41' ],
|
|
119
|
-
slug: 'purple-yellow',
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
gradients: [
|
|
123
|
-
{
|
|
124
|
-
name: 'Vivid cyan blue to vivid purple',
|
|
125
|
-
gradient:
|
|
126
|
-
'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
|
|
127
|
-
slug: 'vivid-cyan-blue-to-vivid-purple',
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: 'Light green cyan to vivid green cyan',
|
|
131
|
-
gradient:
|
|
132
|
-
'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
|
|
133
|
-
slug: 'light-green-cyan-to-vivid-green-cyan',
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: 'Luminous vivid amber to luminous vivid orange',
|
|
137
|
-
gradient:
|
|
138
|
-
'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
|
|
139
|
-
slug: 'luminous-vivid-amber-to-luminous-vivid-orange',
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
palette: [
|
|
143
|
-
{
|
|
144
|
-
name: 'Vivid red',
|
|
145
|
-
slug: 'vivid-red',
|
|
146
|
-
color: '#cf2e2e',
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: 'Luminous vivid orange',
|
|
150
|
-
slug: 'luminous-vivid-orange',
|
|
151
|
-
color: '#ff6900',
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: 'Luminous vivid amber',
|
|
155
|
-
slug: 'luminous-vivid-amber',
|
|
156
|
-
color: '#fcb900',
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
},
|
|
160
|
-
typography: {
|
|
161
|
-
fluid: true,
|
|
162
|
-
fontFamilies: {
|
|
163
|
-
theme: [
|
|
164
|
-
{
|
|
165
|
-
name: 'Inter san-serif',
|
|
166
|
-
fontFamily: 'Inter san-serif',
|
|
167
|
-
slug: 'inter-san-serif',
|
|
168
|
-
fontFace: [
|
|
169
|
-
{
|
|
170
|
-
src: 'inter-san-serif.woff2',
|
|
171
|
-
fontWeight: '400',
|
|
172
|
-
fontStyle: 'italic',
|
|
173
|
-
fontFamily: 'Inter san-serif',
|
|
174
|
-
},
|
|
175
|
-
],
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
fontSizes: [
|
|
180
|
-
{
|
|
181
|
-
name: 'Small',
|
|
182
|
-
slug: 'small',
|
|
183
|
-
size: '13px',
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: 'Medium',
|
|
187
|
-
slug: 'medium',
|
|
188
|
-
size: '20px',
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: 'Large',
|
|
192
|
-
slug: 'large',
|
|
193
|
-
size: '36px',
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
},
|
|
197
|
-
layout: {
|
|
198
|
-
wideSize: '1200px',
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
styles: {
|
|
202
|
-
typography: {
|
|
203
|
-
letterSpacing: '3px',
|
|
204
|
-
},
|
|
205
|
-
color: {
|
|
206
|
-
backgroundColor: 'red',
|
|
207
|
-
color: 'orange',
|
|
208
|
-
},
|
|
209
|
-
elements: {
|
|
210
|
-
cite: {
|
|
211
|
-
color: {
|
|
212
|
-
text: 'white',
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
blocks: {
|
|
217
|
-
'core/quote': {
|
|
218
|
-
color: {
|
|
219
|
-
text: 'black',
|
|
220
|
-
background: 'white',
|
|
221
|
-
},
|
|
222
|
-
typography: {
|
|
223
|
-
fontSize: '20px',
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
title: 'Title 2',
|
|
231
|
-
description: 'Description 2',
|
|
232
|
-
settings: {
|
|
233
|
-
color: {
|
|
234
|
-
duotone: [
|
|
235
|
-
{
|
|
236
|
-
name: 'Boom',
|
|
237
|
-
colors: [ '#000000', '#7f7f7f' ],
|
|
238
|
-
slug: 'boom',
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
name: 'Gray to white',
|
|
242
|
-
colors: [ '#000000', '#ffffff' ],
|
|
243
|
-
slug: 'gray-to-white',
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
name: 'Whatever to whatever',
|
|
247
|
-
colors: [ '#8c00b7', '#fcff41' ],
|
|
248
|
-
slug: 'whatever-to-whatever',
|
|
249
|
-
},
|
|
250
|
-
],
|
|
251
|
-
gradients: [
|
|
252
|
-
{
|
|
253
|
-
name: 'Jam in the office',
|
|
254
|
-
gradient:
|
|
255
|
-
'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
|
|
256
|
-
slug: 'jam-in-the-office',
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
name: 'Open source',
|
|
260
|
-
gradient:
|
|
261
|
-
'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
|
|
262
|
-
slug: 'open-source',
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
name: 'Here to there',
|
|
266
|
-
gradient:
|
|
267
|
-
'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
|
|
268
|
-
slug: 'here-to-there',
|
|
269
|
-
},
|
|
270
|
-
],
|
|
271
|
-
palette: [
|
|
272
|
-
{
|
|
273
|
-
name: 'Chunky Bacon',
|
|
274
|
-
slug: 'chunky-bacon',
|
|
275
|
-
color: '#cf2e2e',
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
name: 'Burrito',
|
|
279
|
-
slug: 'burrito',
|
|
280
|
-
color: '#ff6900',
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
name: 'Dinosaur',
|
|
284
|
-
slug: 'dinosaur',
|
|
285
|
-
color: '#fcb900',
|
|
286
|
-
},
|
|
287
|
-
],
|
|
288
|
-
},
|
|
289
|
-
typography: {
|
|
290
|
-
fontSizes: [
|
|
291
|
-
{
|
|
292
|
-
name: 'Smallish',
|
|
293
|
-
slug: 'smallish',
|
|
294
|
-
size: '15px',
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
name: 'Mediumish',
|
|
298
|
-
slug: 'mediumish',
|
|
299
|
-
size: '22px',
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
name: 'Largish',
|
|
303
|
-
slug: 'largish',
|
|
304
|
-
size: '44px',
|
|
305
|
-
},
|
|
306
|
-
],
|
|
307
|
-
},
|
|
308
|
-
layout: {
|
|
309
|
-
contentSize: '300px',
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
styles: {
|
|
313
|
-
typography: {
|
|
314
|
-
letterSpacing: '3px',
|
|
315
|
-
},
|
|
316
|
-
color: {
|
|
317
|
-
backgroundColor: 'red',
|
|
318
|
-
text: 'orange',
|
|
319
|
-
},
|
|
320
|
-
elements: {
|
|
321
|
-
link: {
|
|
322
|
-
typography: {
|
|
323
|
-
textDecoration: 'underline',
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
blocks: {
|
|
328
|
-
'core/paragraph': {
|
|
329
|
-
color: {
|
|
330
|
-
text: 'purple',
|
|
331
|
-
background: 'green',
|
|
332
|
-
},
|
|
333
|
-
typography: {
|
|
334
|
-
fontSize: '20px',
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
];
|
|
341
|
-
const mockBaseVariation = {
|
|
342
|
-
settings: {
|
|
343
|
-
typography: {
|
|
344
|
-
fontFamilies: {
|
|
345
|
-
custom: [
|
|
346
|
-
{
|
|
347
|
-
name: 'ADLaM Display',
|
|
348
|
-
fontFamily: 'ADLaM Display, system-ui',
|
|
349
|
-
slug: 'adlam-display',
|
|
350
|
-
fontFace: [
|
|
351
|
-
{
|
|
352
|
-
src: 'adlam.woff2',
|
|
353
|
-
fontWeight: '400',
|
|
354
|
-
fontStyle: 'normal',
|
|
355
|
-
fontFamily: 'ADLaM Display',
|
|
356
|
-
},
|
|
357
|
-
],
|
|
358
|
-
},
|
|
359
|
-
],
|
|
360
|
-
},
|
|
361
|
-
fontSizes: [
|
|
362
|
-
{
|
|
363
|
-
name: 'Base small',
|
|
364
|
-
slug: 'base-small',
|
|
365
|
-
size: '1px',
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
name: 'Base medium',
|
|
369
|
-
slug: 'base-medium',
|
|
370
|
-
size: '2px',
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
name: 'Base large',
|
|
374
|
-
slug: 'base-large',
|
|
375
|
-
size: '3px',
|
|
376
|
-
},
|
|
377
|
-
],
|
|
378
|
-
},
|
|
379
|
-
color: {
|
|
380
|
-
palette: {
|
|
381
|
-
custom: [
|
|
382
|
-
{
|
|
383
|
-
color: '#c42727',
|
|
384
|
-
name: 'Color 1',
|
|
385
|
-
slug: 'custom-color-1',
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
color: '#3b0f0f',
|
|
389
|
-
name: 'Color 2',
|
|
390
|
-
slug: 'custom-color-2',
|
|
391
|
-
},
|
|
392
|
-
],
|
|
393
|
-
},
|
|
394
|
-
},
|
|
395
|
-
layout: {
|
|
396
|
-
wideSize: '1137px',
|
|
397
|
-
contentSize: '400px',
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
styles: {
|
|
401
|
-
typography: {
|
|
402
|
-
fontSize: '12px',
|
|
403
|
-
lineHeight: '1.5',
|
|
404
|
-
},
|
|
405
|
-
color: {
|
|
406
|
-
backgroundColor: 'cheese',
|
|
407
|
-
color: 'lettuce',
|
|
408
|
-
},
|
|
409
|
-
blocks: {
|
|
410
|
-
'core/quote': {
|
|
411
|
-
color: {
|
|
412
|
-
text: 'hello',
|
|
413
|
-
background: 'dolly',
|
|
414
|
-
},
|
|
415
|
-
typography: {
|
|
416
|
-
fontSize: '111111px',
|
|
417
|
-
},
|
|
418
|
-
},
|
|
419
|
-
'core/group': {
|
|
420
|
-
typography: {
|
|
421
|
-
fontFamily: 'var:preset|font-family|system-sans-serif',
|
|
422
|
-
},
|
|
423
|
-
},
|
|
424
|
-
},
|
|
425
|
-
},
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
it( 'should return variations if property is falsy', () => {
|
|
429
|
-
const { result } = renderHook( () =>
|
|
430
|
-
useThemeStyleVariationsByProperty( {
|
|
431
|
-
variations: mockVariations,
|
|
432
|
-
property: '',
|
|
433
|
-
} )
|
|
434
|
-
);
|
|
435
|
-
|
|
436
|
-
expect( result.current ).toEqual( mockVariations );
|
|
437
|
-
} );
|
|
438
|
-
|
|
439
|
-
it( 'should return variations if variations is empty or falsy', () => {
|
|
440
|
-
const { result: emptyResult } = renderHook( () =>
|
|
441
|
-
useThemeStyleVariationsByProperty( {
|
|
442
|
-
variations: [],
|
|
443
|
-
property: 'layout',
|
|
444
|
-
} )
|
|
445
|
-
);
|
|
446
|
-
|
|
447
|
-
expect( emptyResult.current ).toEqual( [] );
|
|
448
|
-
|
|
449
|
-
const { result: falsyResult } = renderHook( () =>
|
|
450
|
-
useThemeStyleVariationsByProperty( {
|
|
451
|
-
variations: null,
|
|
452
|
-
property: 'layout',
|
|
453
|
-
} )
|
|
454
|
-
);
|
|
455
|
-
|
|
456
|
-
expect( falsyResult.current ).toEqual( null );
|
|
457
|
-
} );
|
|
458
|
-
|
|
459
|
-
it( 'should return new, unreferenced object', () => {
|
|
460
|
-
const variations = [
|
|
461
|
-
{
|
|
462
|
-
title: 'hey',
|
|
463
|
-
description: 'ho',
|
|
464
|
-
joe: {
|
|
465
|
-
where: {
|
|
466
|
-
you: 'going with that unit test in your hand',
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
},
|
|
470
|
-
];
|
|
471
|
-
const { result } = renderHook( () =>
|
|
472
|
-
useThemeStyleVariationsByProperty( {
|
|
473
|
-
variations,
|
|
474
|
-
property: 'where',
|
|
475
|
-
} )
|
|
476
|
-
);
|
|
477
|
-
|
|
478
|
-
expect( result.current ).toEqual( [
|
|
479
|
-
{
|
|
480
|
-
title: 'hey',
|
|
481
|
-
description: 'ho',
|
|
482
|
-
joe: {
|
|
483
|
-
where: {
|
|
484
|
-
you: 'going with that unit test in your hand',
|
|
485
|
-
},
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
] );
|
|
489
|
-
|
|
490
|
-
expect( result.current[ 0 ].joe.where ).not.toBe(
|
|
491
|
-
variations[ 0 ].joe.where
|
|
492
|
-
);
|
|
493
|
-
expect( result.current[ 0 ].joe ).not.toBe( variations[ 0 ].joe );
|
|
494
|
-
} );
|
|
495
|
-
|
|
496
|
-
it( "should return the variation's typography properties", () => {
|
|
497
|
-
const { result } = renderHook( () =>
|
|
498
|
-
useThemeStyleVariationsByProperty( {
|
|
499
|
-
variations: mockVariations,
|
|
500
|
-
property: 'typography',
|
|
501
|
-
} )
|
|
502
|
-
);
|
|
503
|
-
|
|
504
|
-
expect( result.current ).toEqual( [
|
|
505
|
-
{
|
|
506
|
-
title: 'Title 1',
|
|
507
|
-
description: 'Description 1',
|
|
508
|
-
settings: {
|
|
509
|
-
typography: {
|
|
510
|
-
fluid: true,
|
|
511
|
-
fontFamilies: {
|
|
512
|
-
theme: [
|
|
513
|
-
{
|
|
514
|
-
name: 'Inter san-serif',
|
|
515
|
-
fontFamily: 'Inter san-serif',
|
|
516
|
-
slug: 'inter-san-serif',
|
|
517
|
-
fontFace: [
|
|
518
|
-
{
|
|
519
|
-
src: 'inter-san-serif.woff2',
|
|
520
|
-
fontWeight: '400',
|
|
521
|
-
fontStyle: 'italic',
|
|
522
|
-
fontFamily: 'Inter san-serif',
|
|
523
|
-
},
|
|
524
|
-
],
|
|
525
|
-
},
|
|
526
|
-
],
|
|
527
|
-
},
|
|
528
|
-
fontSizes: [
|
|
529
|
-
{
|
|
530
|
-
name: 'Small',
|
|
531
|
-
slug: 'small',
|
|
532
|
-
size: '13px',
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
name: 'Medium',
|
|
536
|
-
slug: 'medium',
|
|
537
|
-
size: '20px',
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
name: 'Large',
|
|
541
|
-
slug: 'large',
|
|
542
|
-
size: '36px',
|
|
543
|
-
},
|
|
544
|
-
],
|
|
545
|
-
},
|
|
546
|
-
},
|
|
547
|
-
styles: {
|
|
548
|
-
typography: {
|
|
549
|
-
letterSpacing: '3px',
|
|
550
|
-
},
|
|
551
|
-
blocks: {
|
|
552
|
-
'core/quote': {
|
|
553
|
-
typography: {
|
|
554
|
-
fontSize: '20px',
|
|
555
|
-
},
|
|
556
|
-
},
|
|
557
|
-
},
|
|
558
|
-
},
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
title: 'Title 2',
|
|
562
|
-
description: 'Description 2',
|
|
563
|
-
settings: {
|
|
564
|
-
typography: {
|
|
565
|
-
fontSizes: [
|
|
566
|
-
{
|
|
567
|
-
name: 'Smallish',
|
|
568
|
-
slug: 'smallish',
|
|
569
|
-
size: '15px',
|
|
570
|
-
},
|
|
571
|
-
{
|
|
572
|
-
name: 'Mediumish',
|
|
573
|
-
slug: 'mediumish',
|
|
574
|
-
size: '22px',
|
|
575
|
-
},
|
|
576
|
-
{
|
|
577
|
-
name: 'Largish',
|
|
578
|
-
slug: 'largish',
|
|
579
|
-
size: '44px',
|
|
580
|
-
},
|
|
581
|
-
],
|
|
582
|
-
},
|
|
583
|
-
},
|
|
584
|
-
styles: {
|
|
585
|
-
typography: {
|
|
586
|
-
letterSpacing: '3px',
|
|
587
|
-
},
|
|
588
|
-
elements: {
|
|
589
|
-
link: {
|
|
590
|
-
typography: {
|
|
591
|
-
textDecoration: 'underline',
|
|
592
|
-
},
|
|
593
|
-
},
|
|
594
|
-
},
|
|
595
|
-
blocks: {
|
|
596
|
-
'core/paragraph': {
|
|
597
|
-
typography: {
|
|
598
|
-
fontSize: '20px',
|
|
599
|
-
},
|
|
600
|
-
},
|
|
601
|
-
},
|
|
602
|
-
},
|
|
603
|
-
},
|
|
604
|
-
] );
|
|
605
|
-
} );
|
|
606
|
-
|
|
607
|
-
it( "should return the variation's color properties", () => {
|
|
608
|
-
const { result } = renderHook( () =>
|
|
609
|
-
useThemeStyleVariationsByProperty( {
|
|
610
|
-
variations: mockVariations,
|
|
611
|
-
property: 'color',
|
|
612
|
-
} )
|
|
613
|
-
);
|
|
614
|
-
|
|
615
|
-
expect( result.current ).toEqual( [
|
|
616
|
-
{
|
|
617
|
-
title: 'Title 1',
|
|
618
|
-
description: 'Description 1',
|
|
619
|
-
settings: {
|
|
620
|
-
color: {
|
|
621
|
-
duotone: [
|
|
622
|
-
{
|
|
623
|
-
name: 'Dark grayscale',
|
|
624
|
-
colors: [ '#000000', '#7f7f7f' ],
|
|
625
|
-
slug: 'dark-grayscale',
|
|
626
|
-
},
|
|
627
|
-
{
|
|
628
|
-
name: 'Grayscale',
|
|
629
|
-
colors: [ '#000000', '#ffffff' ],
|
|
630
|
-
slug: 'grayscale',
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
name: 'Purple and yellow',
|
|
634
|
-
colors: [ '#8c00b7', '#fcff41' ],
|
|
635
|
-
slug: 'purple-yellow',
|
|
636
|
-
},
|
|
637
|
-
],
|
|
638
|
-
gradients: [
|
|
639
|
-
{
|
|
640
|
-
name: 'Vivid cyan blue to vivid purple',
|
|
641
|
-
gradient:
|
|
642
|
-
'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
|
|
643
|
-
slug: 'vivid-cyan-blue-to-vivid-purple',
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
name: 'Light green cyan to vivid green cyan',
|
|
647
|
-
gradient:
|
|
648
|
-
'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
|
|
649
|
-
slug: 'light-green-cyan-to-vivid-green-cyan',
|
|
650
|
-
},
|
|
651
|
-
{
|
|
652
|
-
name: 'Luminous vivid amber to luminous vivid orange',
|
|
653
|
-
gradient:
|
|
654
|
-
'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
|
|
655
|
-
slug: 'luminous-vivid-amber-to-luminous-vivid-orange',
|
|
656
|
-
},
|
|
657
|
-
],
|
|
658
|
-
palette: [
|
|
659
|
-
{
|
|
660
|
-
name: 'Vivid red',
|
|
661
|
-
slug: 'vivid-red',
|
|
662
|
-
color: '#cf2e2e',
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
name: 'Luminous vivid orange',
|
|
666
|
-
slug: 'luminous-vivid-orange',
|
|
667
|
-
color: '#ff6900',
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
name: 'Luminous vivid amber',
|
|
671
|
-
slug: 'luminous-vivid-amber',
|
|
672
|
-
color: '#fcb900',
|
|
673
|
-
},
|
|
674
|
-
],
|
|
675
|
-
},
|
|
676
|
-
},
|
|
677
|
-
styles: {
|
|
678
|
-
color: {
|
|
679
|
-
backgroundColor: 'red',
|
|
680
|
-
color: 'orange',
|
|
681
|
-
},
|
|
682
|
-
elements: {
|
|
683
|
-
cite: {
|
|
684
|
-
color: {
|
|
685
|
-
text: 'white',
|
|
686
|
-
},
|
|
687
|
-
},
|
|
688
|
-
},
|
|
689
|
-
blocks: {
|
|
690
|
-
'core/quote': {
|
|
691
|
-
color: {
|
|
692
|
-
text: 'black',
|
|
693
|
-
background: 'white',
|
|
694
|
-
},
|
|
695
|
-
},
|
|
696
|
-
},
|
|
697
|
-
},
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
title: 'Title 2',
|
|
701
|
-
description: 'Description 2',
|
|
702
|
-
settings: {
|
|
703
|
-
color: {
|
|
704
|
-
duotone: [
|
|
705
|
-
{
|
|
706
|
-
name: 'Boom',
|
|
707
|
-
colors: [ '#000000', '#7f7f7f' ],
|
|
708
|
-
slug: 'boom',
|
|
709
|
-
},
|
|
710
|
-
{
|
|
711
|
-
name: 'Gray to white',
|
|
712
|
-
colors: [ '#000000', '#ffffff' ],
|
|
713
|
-
slug: 'gray-to-white',
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
name: 'Whatever to whatever',
|
|
717
|
-
colors: [ '#8c00b7', '#fcff41' ],
|
|
718
|
-
slug: 'whatever-to-whatever',
|
|
719
|
-
},
|
|
720
|
-
],
|
|
721
|
-
gradients: [
|
|
722
|
-
{
|
|
723
|
-
name: 'Jam in the office',
|
|
724
|
-
gradient:
|
|
725
|
-
'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
|
|
726
|
-
slug: 'jam-in-the-office',
|
|
727
|
-
},
|
|
728
|
-
{
|
|
729
|
-
name: 'Open source',
|
|
730
|
-
gradient:
|
|
731
|
-
'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
|
|
732
|
-
slug: 'open-source',
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
name: 'Here to there',
|
|
736
|
-
gradient:
|
|
737
|
-
'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
|
|
738
|
-
slug: 'here-to-there',
|
|
739
|
-
},
|
|
740
|
-
],
|
|
741
|
-
palette: [
|
|
742
|
-
{
|
|
743
|
-
name: 'Chunky Bacon',
|
|
744
|
-
slug: 'chunky-bacon',
|
|
745
|
-
color: '#cf2e2e',
|
|
746
|
-
},
|
|
747
|
-
{
|
|
748
|
-
name: 'Burrito',
|
|
749
|
-
slug: 'burrito',
|
|
750
|
-
color: '#ff6900',
|
|
751
|
-
},
|
|
752
|
-
{
|
|
753
|
-
name: 'Dinosaur',
|
|
754
|
-
slug: 'dinosaur',
|
|
755
|
-
color: '#fcb900',
|
|
756
|
-
},
|
|
757
|
-
],
|
|
758
|
-
},
|
|
759
|
-
},
|
|
760
|
-
styles: {
|
|
761
|
-
color: {
|
|
762
|
-
backgroundColor: 'red',
|
|
763
|
-
text: 'orange',
|
|
764
|
-
},
|
|
765
|
-
blocks: {
|
|
766
|
-
'core/paragraph': {
|
|
767
|
-
color: {
|
|
768
|
-
text: 'purple',
|
|
769
|
-
background: 'green',
|
|
770
|
-
},
|
|
771
|
-
},
|
|
772
|
-
},
|
|
773
|
-
},
|
|
774
|
-
},
|
|
775
|
-
] );
|
|
776
|
-
} );
|
|
777
|
-
|
|
778
|
-
it( 'should merge the user styles and settings with the supplied variation, but only for the specified property', () => {
|
|
779
|
-
const { result } = renderHook( () =>
|
|
780
|
-
useThemeStyleVariationsByProperty( {
|
|
781
|
-
variations: [ mockVariations[ 0 ] ],
|
|
782
|
-
property: 'typography',
|
|
783
|
-
baseVariation: mockBaseVariation,
|
|
784
|
-
} )
|
|
785
|
-
);
|
|
786
|
-
|
|
787
|
-
expect( result.current ).toEqual( [
|
|
788
|
-
{
|
|
789
|
-
title: 'Title 1',
|
|
790
|
-
description: 'Description 1',
|
|
791
|
-
settings: {
|
|
792
|
-
typography: {
|
|
793
|
-
fluid: true,
|
|
794
|
-
fontFamilies: {
|
|
795
|
-
theme: [
|
|
796
|
-
{
|
|
797
|
-
name: 'Inter san-serif',
|
|
798
|
-
fontFamily: 'Inter san-serif',
|
|
799
|
-
slug: 'inter-san-serif',
|
|
800
|
-
fontFace: [
|
|
801
|
-
{
|
|
802
|
-
src: 'inter-san-serif.woff2',
|
|
803
|
-
fontWeight: '400',
|
|
804
|
-
fontStyle: 'italic',
|
|
805
|
-
fontFamily: 'Inter san-serif',
|
|
806
|
-
},
|
|
807
|
-
],
|
|
808
|
-
},
|
|
809
|
-
],
|
|
810
|
-
custom: [
|
|
811
|
-
{
|
|
812
|
-
name: 'ADLaM Display',
|
|
813
|
-
fontFamily: 'ADLaM Display, system-ui',
|
|
814
|
-
slug: 'adlam-display',
|
|
815
|
-
fontFace: [
|
|
816
|
-
{
|
|
817
|
-
src: 'adlam.woff2',
|
|
818
|
-
fontWeight: '400',
|
|
819
|
-
fontStyle: 'normal',
|
|
820
|
-
fontFamily: 'ADLaM Display',
|
|
821
|
-
},
|
|
822
|
-
],
|
|
823
|
-
},
|
|
824
|
-
],
|
|
825
|
-
},
|
|
826
|
-
fontSizes: [
|
|
827
|
-
{
|
|
828
|
-
name: 'Small',
|
|
829
|
-
slug: 'small',
|
|
830
|
-
size: '13px',
|
|
831
|
-
},
|
|
832
|
-
{
|
|
833
|
-
name: 'Medium',
|
|
834
|
-
slug: 'medium',
|
|
835
|
-
size: '20px',
|
|
836
|
-
},
|
|
837
|
-
{
|
|
838
|
-
name: 'Large',
|
|
839
|
-
slug: 'large',
|
|
840
|
-
size: '36px',
|
|
841
|
-
},
|
|
842
|
-
],
|
|
843
|
-
},
|
|
844
|
-
color: {
|
|
845
|
-
palette: {
|
|
846
|
-
custom: [
|
|
847
|
-
{
|
|
848
|
-
color: '#c42727',
|
|
849
|
-
name: 'Color 1',
|
|
850
|
-
slug: 'custom-color-1',
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
color: '#3b0f0f',
|
|
854
|
-
name: 'Color 2',
|
|
855
|
-
slug: 'custom-color-2',
|
|
856
|
-
},
|
|
857
|
-
],
|
|
858
|
-
},
|
|
859
|
-
},
|
|
860
|
-
layout: {
|
|
861
|
-
wideSize: '1137px',
|
|
862
|
-
contentSize: '400px',
|
|
863
|
-
},
|
|
864
|
-
},
|
|
865
|
-
styles: {
|
|
866
|
-
color: {
|
|
867
|
-
backgroundColor: 'cheese',
|
|
868
|
-
color: 'lettuce',
|
|
869
|
-
},
|
|
870
|
-
typography: {
|
|
871
|
-
fontSize: '12px',
|
|
872
|
-
letterSpacing: '3px',
|
|
873
|
-
lineHeight: '1.5',
|
|
874
|
-
},
|
|
875
|
-
blocks: {
|
|
876
|
-
'core/quote': {
|
|
877
|
-
color: {
|
|
878
|
-
text: 'hello',
|
|
879
|
-
background: 'dolly',
|
|
880
|
-
},
|
|
881
|
-
typography: {
|
|
882
|
-
fontSize: '20px',
|
|
883
|
-
},
|
|
884
|
-
},
|
|
885
|
-
'core/group': {
|
|
886
|
-
typography: {
|
|
887
|
-
fontFamily:
|
|
888
|
-
'var:preset|font-family|system-sans-serif',
|
|
889
|
-
},
|
|
890
|
-
},
|
|
891
|
-
},
|
|
892
|
-
},
|
|
893
|
-
},
|
|
894
|
-
] );
|
|
895
|
-
} );
|
|
896
|
-
|
|
897
|
-
it( 'should filter the output and return only variations that match filter', () => {
|
|
898
|
-
const { result } = renderHook( () =>
|
|
899
|
-
useThemeStyleVariationsByProperty( {
|
|
900
|
-
variations: mockVariations,
|
|
901
|
-
property: 'typography',
|
|
902
|
-
filter: ( variation ) =>
|
|
903
|
-
!! variation?.settings?.typography?.fontFamilies?.theme
|
|
904
|
-
?.length,
|
|
905
|
-
} )
|
|
906
|
-
);
|
|
907
|
-
expect( result.current ).toEqual( [
|
|
908
|
-
{
|
|
909
|
-
title: 'Title 1',
|
|
910
|
-
description: 'Description 1',
|
|
911
|
-
settings: {
|
|
912
|
-
typography: {
|
|
913
|
-
fluid: true,
|
|
914
|
-
fontFamilies: {
|
|
915
|
-
theme: [
|
|
916
|
-
{
|
|
917
|
-
name: 'Inter san-serif',
|
|
918
|
-
fontFamily: 'Inter san-serif',
|
|
919
|
-
slug: 'inter-san-serif',
|
|
920
|
-
fontFace: [
|
|
921
|
-
{
|
|
922
|
-
src: 'inter-san-serif.woff2',
|
|
923
|
-
fontWeight: '400',
|
|
924
|
-
fontStyle: 'italic',
|
|
925
|
-
fontFamily: 'Inter san-serif',
|
|
926
|
-
},
|
|
927
|
-
],
|
|
928
|
-
},
|
|
929
|
-
],
|
|
930
|
-
},
|
|
931
|
-
fontSizes: [
|
|
932
|
-
{
|
|
933
|
-
name: 'Small',
|
|
934
|
-
slug: 'small',
|
|
935
|
-
size: '13px',
|
|
936
|
-
},
|
|
937
|
-
{
|
|
938
|
-
name: 'Medium',
|
|
939
|
-
slug: 'medium',
|
|
940
|
-
size: '20px',
|
|
941
|
-
},
|
|
942
|
-
{
|
|
943
|
-
name: 'Large',
|
|
944
|
-
slug: 'large',
|
|
945
|
-
size: '36px',
|
|
946
|
-
},
|
|
947
|
-
],
|
|
948
|
-
},
|
|
949
|
-
},
|
|
950
|
-
styles: {
|
|
951
|
-
typography: {
|
|
952
|
-
letterSpacing: '3px',
|
|
953
|
-
},
|
|
954
|
-
blocks: {
|
|
955
|
-
'core/quote': {
|
|
956
|
-
typography: {
|
|
957
|
-
fontSize: '20px',
|
|
958
|
-
},
|
|
959
|
-
},
|
|
960
|
-
},
|
|
961
|
-
},
|
|
962
|
-
},
|
|
963
|
-
] );
|
|
964
|
-
} );
|
|
965
|
-
} );
|
|
966
|
-
|
|
967
93
|
describe( 'removePropertyFromObject', () => {
|
|
968
94
|
const mockBaseVariation = {
|
|
969
95
|
settings: {
|