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