@wordpress/edit-site 5.6.0 → 5.8.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 +4 -0
- package/build/components/add-new-template/new-template-part.js +3 -11
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +7 -7
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/add-new-template/utils.js +1 -1
- package/build/components/add-new-template/utils.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +7 -10
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +6 -4
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +35 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/context-menu.js +8 -11
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +11 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +53 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +45 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/global-styles-provider.js +7 -4
- package/build/components/global-styles/global-styles-provider.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -58
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview.js +4 -5
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +17 -12
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +22 -211
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-css.js +1 -1
- package/build/components/global-styles/screen-css.js.map +1 -1
- package/build/components/global-styles/screen-effects.js +15 -7
- package/build/components/global-styles/screen-effects.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +2 -2
- package/build/components/global-styles/screen-filters.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +8 -118
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography-element.js +4 -0
- package/build/components/global-styles/screen-typography-element.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +5 -0
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +149 -0
- package/build/components/global-styles/style-variations-container.js.map +1 -0
- package/build/components/global-styles/ui.js +51 -37
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles-renderer/index.js +1 -2
- package/build/components/global-styles-renderer/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +1 -1
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -137
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +8 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +4 -0
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +6 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build/components/sidebar/index.js +4 -0
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen/index.js +8 -6
- package/build/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +58 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build/components/sidebar-navigation-screen-main/index.js +5 -0
- package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +114 -9
- package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build/components/site-hub/index.js +4 -3
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/start-template-options/index.js +44 -9
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/components/style-book/index.js +6 -7
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/welcome-guide/styles.js +1 -1
- package/build/components/welcome-guide/styles.js.map +1 -1
- package/build/hooks/commands/index.js +19 -0
- package/build/hooks/commands/index.js.map +1 -0
- package/build/hooks/commands/use-navigation-commands.js +117 -0
- package/build/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build/hooks/commands/use-wp-admin-commands.js +94 -0
- package/build/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/template-part-edit.js +2 -1
- package/build/hooks/template-part-edit.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +2 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +3 -9
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +7 -7
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/add-new-template/utils.js +1 -1
- package/build-module/components/add-new-template/utils.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +8 -11
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +6 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +34 -1
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +8 -8
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +11 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +43 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +35 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/global-styles-provider.js +8 -5
- package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -52
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview.js +4 -5
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +16 -11
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +23 -208
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-css.js +1 -1
- package/build-module/components/global-styles/screen-css.js.map +1 -1
- package/build-module/components/global-styles/screen-effects.js +13 -4
- package/build-module/components/global-styles/screen-effects.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +2 -2
- package/build-module/components/global-styles/screen-filters.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +11 -114
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography-element.js +4 -0
- package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +5 -0
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +130 -0
- package/build-module/components/global-styles/style-variations-container.js.map +1 -0
- package/build-module/components/global-styles/ui.js +49 -33
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles-renderer/index.js +1 -2
- package/build-module/components/global-styles-renderer/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -135
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +6 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -0
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +6 -2
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -0
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen/index.js +9 -7
- package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-main/index.js +6 -1
- package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +113 -11
- package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
- package/build-module/components/site-hub/index.js +3 -3
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +45 -10
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/components/style-book/index.js +7 -8
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/welcome-guide/styles.js +1 -1
- package/build-module/components/welcome-guide/styles.js.map +1 -1
- package/build-module/hooks/commands/index.js +10 -0
- package/build-module/hooks/commands/index.js.map +1 -0
- package/build-module/hooks/commands/use-navigation-commands.js +101 -0
- package/build-module/hooks/commands/use-navigation-commands.js.map +1 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js +79 -0
- package/build-module/hooks/commands/use-wp-admin-commands.js.map +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/template-part-edit.js +2 -1
- package/build-module/hooks/template-part-edit.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +2 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +24 -63
- package/build-style/style.css +24 -63
- package/package.json +33 -31
- package/src/components/add-new-template/new-template-part.js +1 -6
- package/src/components/add-new-template/new-template.js +3 -6
- package/src/components/add-new-template/utils.js +1 -1
- package/src/components/block-editor/editor-canvas.js +13 -23
- package/src/components/editor/index.js +11 -3
- package/src/components/global-styles/border-panel.js +32 -1
- package/src/components/global-styles/context-menu.js +8 -8
- package/src/components/global-styles/dimensions-panel.js +11 -0
- package/src/components/global-styles/effects-panel.js +40 -0
- package/src/components/global-styles/filters-panel.js +33 -0
- package/src/components/global-styles/global-styles-provider.js +4 -4
- package/src/components/global-styles/hooks.js +1 -78
- package/src/components/global-styles/preview.js +2 -2
- package/src/components/global-styles/screen-block-list.js +11 -7
- package/src/components/global-styles/screen-colors.js +25 -229
- package/src/components/global-styles/screen-css.js +1 -1
- package/src/components/global-styles/screen-effects.js +12 -5
- package/src/components/global-styles/screen-filters.js +2 -2
- package/src/components/global-styles/screen-style-variations.js +10 -129
- package/src/components/global-styles/screen-typography-element.js +4 -0
- package/src/components/global-styles/screen-typography.js +6 -0
- package/src/components/global-styles/stories/index.js +425 -0
- package/src/components/global-styles/style-variations-container.js +136 -0
- package/src/components/global-styles/style.scss +4 -57
- package/src/components/global-styles/ui.js +50 -33
- package/src/components/global-styles-renderer/index.js +1 -2
- package/src/components/header-edit-mode/more-menu/index.js +1 -1
- package/src/components/keyboard-shortcuts/index.js +1 -155
- package/src/components/layout/index.js +4 -0
- package/src/components/preferences-modal/index.js +7 -0
- package/src/components/secondary-sidebar/list-view-sidebar.js +4 -3
- package/src/components/sidebar/index.js +4 -0
- package/src/components/sidebar-navigation-screen/index.js +10 -5
- package/src/components/sidebar-navigation-screen/style.scss +20 -5
- package/src/components/sidebar-navigation-screen-global-styles/index.js +41 -0
- package/src/components/sidebar-navigation-screen-main/index.js +9 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +134 -9
- package/src/components/site-hub/index.js +3 -3
- package/src/components/start-template-options/index.js +40 -8
- package/src/components/start-template-options/style.scss +7 -14
- package/src/components/style-book/index.js +10 -16
- package/src/components/style-book/style.scss +1 -1
- package/src/components/welcome-guide/styles.js +1 -1
- package/src/hooks/commands/index.js +10 -0
- package/src/hooks/commands/use-navigation-commands.js +103 -0
- package/src/hooks/commands/use-wp-admin-commands.js +77 -0
- package/src/hooks/push-changes-to-global-styles/index.js +1 -0
- package/src/hooks/template-part-edit.js +1 -0
- package/src/index.js +1 -0
- package/src/store/selectors.js +2 -1
- package/build/components/global-styles/color-utils.js +0 -17
- package/build/components/global-styles/color-utils.js.map +0 -1
- package/build/components/global-styles/duotone-panel.js +0 -78
- package/build/components/global-styles/duotone-panel.js.map +0 -1
- package/build/components/global-styles/filter-utils.js +0 -17
- package/build/components/global-styles/filter-utils.js.map +0 -1
- package/build/components/global-styles/screen-background-color.js +0 -114
- package/build/components/global-styles/screen-background-color.js.map +0 -1
- package/build/components/global-styles/screen-button-color.js +0 -88
- package/build/components/global-styles/screen-button-color.js.map +0 -1
- package/build/components/global-styles/screen-heading-color.js +0 -165
- package/build/components/global-styles/screen-heading-color.js.map +0 -1
- package/build/components/global-styles/screen-link-color.js +0 -105
- package/build/components/global-styles/screen-link-color.js.map +0 -1
- package/build/components/global-styles/screen-text-color.js +0 -71
- package/build/components/global-styles/screen-text-color.js.map +0 -1
- package/build/components/global-styles/shadow-panel.js +0 -197
- package/build/components/global-styles/shadow-panel.js.map +0 -1
- package/build-module/components/global-styles/color-utils.js +0 -9
- package/build-module/components/global-styles/color-utils.js.map +0 -1
- package/build-module/components/global-styles/duotone-panel.js +0 -67
- package/build-module/components/global-styles/duotone-panel.js.map +0 -1
- package/build-module/components/global-styles/filter-utils.js +0 -9
- package/build-module/components/global-styles/filter-utils.js.map +0 -1
- package/build-module/components/global-styles/screen-background-color.js +0 -97
- package/build-module/components/global-styles/screen-background-color.js.map +0 -1
- package/build-module/components/global-styles/screen-button-color.js +0 -73
- package/build-module/components/global-styles/screen-button-color.js.map +0 -1
- package/build-module/components/global-styles/screen-heading-color.js +0 -149
- package/build-module/components/global-styles/screen-heading-color.js.map +0 -1
- package/build-module/components/global-styles/screen-link-color.js +0 -89
- package/build-module/components/global-styles/screen-link-color.js.map +0 -1
- package/build-module/components/global-styles/screen-text-color.js +0 -56
- package/build-module/components/global-styles/screen-text-color.js.map +0 -1
- package/build-module/components/global-styles/shadow-panel.js +0 -178
- package/build-module/components/global-styles/shadow-panel.js.map +0 -1
- package/src/components/global-styles/color-utils.js +0 -14
- package/src/components/global-styles/duotone-panel.js +0 -82
- package/src/components/global-styles/filter-utils.js +0 -9
- package/src/components/global-styles/screen-background-color.js +0 -132
- package/src/components/global-styles/screen-button-color.js +0 -104
- package/src/components/global-styles/screen-heading-color.js +0 -206
- package/src/components/global-styles/screen-link-color.js +0 -124
- package/src/components/global-styles/screen-text-color.js +0 -62
- package/src/components/global-styles/shadow-panel.js +0 -178
|
@@ -7,8 +7,6 @@ import a11yPlugin from 'colord/plugins/a11y';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { _x } from '@wordpress/i18n';
|
|
11
|
-
import { useMemo } from '@wordpress/element';
|
|
12
10
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
13
11
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
14
12
|
|
|
@@ -18,86 +16,11 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
|
18
16
|
import { unlock } from '../../private-apis';
|
|
19
17
|
import { useSelect } from '@wordpress/data';
|
|
20
18
|
|
|
21
|
-
const { useGlobalSetting
|
|
22
|
-
unlock( blockEditorPrivateApis );
|
|
19
|
+
const { useGlobalSetting } = unlock( blockEditorPrivateApis );
|
|
23
20
|
|
|
24
21
|
// Enable colord's a11y plugin.
|
|
25
22
|
extend( [ a11yPlugin ] );
|
|
26
23
|
|
|
27
|
-
export function useColorsPerOrigin( name ) {
|
|
28
|
-
const [ customColors ] = useGlobalSetting( 'color.palette.custom', name );
|
|
29
|
-
const [ themeColors ] = useGlobalSetting( 'color.palette.theme', name );
|
|
30
|
-
const [ defaultColors ] = useGlobalSetting( 'color.palette.default', name );
|
|
31
|
-
const [ shouldDisplayDefaultColors ] = useGlobalSetting(
|
|
32
|
-
'color.defaultPalette'
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return useColorsPerOriginFromSettings( {
|
|
36
|
-
color: {
|
|
37
|
-
palette: {
|
|
38
|
-
custom: customColors,
|
|
39
|
-
theme: themeColors,
|
|
40
|
-
default: defaultColors,
|
|
41
|
-
},
|
|
42
|
-
defaultPalette: shouldDisplayDefaultColors,
|
|
43
|
-
},
|
|
44
|
-
} );
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function useGradientsPerOrigin( name ) {
|
|
48
|
-
const [ customGradients ] = useGlobalSetting(
|
|
49
|
-
'color.gradients.custom',
|
|
50
|
-
name
|
|
51
|
-
);
|
|
52
|
-
const [ themeGradients ] = useGlobalSetting(
|
|
53
|
-
'color.gradients.theme',
|
|
54
|
-
name
|
|
55
|
-
);
|
|
56
|
-
const [ defaultGradients ] = useGlobalSetting(
|
|
57
|
-
'color.gradients.default',
|
|
58
|
-
name
|
|
59
|
-
);
|
|
60
|
-
const [ shouldDisplayDefaultGradients ] = useGlobalSetting(
|
|
61
|
-
'color.defaultGradients'
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
return useMemo( () => {
|
|
65
|
-
const result = [];
|
|
66
|
-
if ( themeGradients && themeGradients.length ) {
|
|
67
|
-
result.push( {
|
|
68
|
-
name: _x(
|
|
69
|
-
'Theme',
|
|
70
|
-
'Indicates this palette comes from the theme.'
|
|
71
|
-
),
|
|
72
|
-
gradients: themeGradients,
|
|
73
|
-
} );
|
|
74
|
-
}
|
|
75
|
-
if (
|
|
76
|
-
shouldDisplayDefaultGradients &&
|
|
77
|
-
defaultGradients &&
|
|
78
|
-
defaultGradients.length
|
|
79
|
-
) {
|
|
80
|
-
result.push( {
|
|
81
|
-
name: _x(
|
|
82
|
-
'Default',
|
|
83
|
-
'Indicates this palette comes from WordPress.'
|
|
84
|
-
),
|
|
85
|
-
gradients: defaultGradients,
|
|
86
|
-
} );
|
|
87
|
-
}
|
|
88
|
-
if ( customGradients && customGradients.length ) {
|
|
89
|
-
result.push( {
|
|
90
|
-
name: _x(
|
|
91
|
-
'Custom',
|
|
92
|
-
'Indicates this palette is created by the user.'
|
|
93
|
-
),
|
|
94
|
-
gradients: customGradients,
|
|
95
|
-
} );
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
}, [ customGradients, themeGradients, defaultGradients ] );
|
|
99
|
-
}
|
|
100
|
-
|
|
101
24
|
export function useColorRandomizer( name ) {
|
|
102
25
|
const [ themeColors, setThemeColors ] = useGlobalSetting(
|
|
103
26
|
'color.palette.theme',
|
|
@@ -117,7 +117,6 @@ const StylesPreview = ( { label, isFocused, withHoverView } ) => {
|
|
|
117
117
|
{ isReady && (
|
|
118
118
|
<Iframe
|
|
119
119
|
className="edit-site-global-styles-preview__iframe"
|
|
120
|
-
head={ <EditorStyles styles={ editorStyles } /> }
|
|
121
120
|
style={ {
|
|
122
121
|
height: normalizedHeight * ratio,
|
|
123
122
|
} }
|
|
@@ -125,12 +124,13 @@ const StylesPreview = ( { label, isFocused, withHoverView } ) => {
|
|
|
125
124
|
onMouseLeave={ () => setIsHovered( false ) }
|
|
126
125
|
tabIndex={ -1 }
|
|
127
126
|
>
|
|
127
|
+
<EditorStyles styles={ editorStyles } />
|
|
128
128
|
<motion.div
|
|
129
129
|
style={ {
|
|
130
130
|
height: normalizedHeight * ratio,
|
|
131
131
|
width: '100%',
|
|
132
132
|
background: gradientValue ?? backgroundColor,
|
|
133
|
-
cursor: 'pointer',
|
|
133
|
+
cursor: withHoverView ? 'pointer' : undefined,
|
|
134
134
|
} }
|
|
135
135
|
initial="start"
|
|
136
136
|
animate={
|
|
@@ -20,7 +20,6 @@ import { speak } from '@wordpress/a11y';
|
|
|
20
20
|
/**
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
|
-
import { useHasColorPanel } from './color-utils';
|
|
24
23
|
import { useHasVariationsPanel } from './variations-panel';
|
|
25
24
|
import ScreenHeader from './header';
|
|
26
25
|
import { NavigationButtonAsItem } from './navigation-button';
|
|
@@ -32,6 +31,7 @@ const {
|
|
|
32
31
|
useHasBorderPanel,
|
|
33
32
|
useGlobalSetting,
|
|
34
33
|
useSettingsForBlockElement,
|
|
34
|
+
useHasColorPanel,
|
|
35
35
|
} = unlock( blockEditorPrivateApis );
|
|
36
36
|
|
|
37
37
|
function useSortedBlockTypes() {
|
|
@@ -57,21 +57,25 @@ function useSortedBlockTypes() {
|
|
|
57
57
|
return [ ...coreItems, ...nonCoreItems ];
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
function
|
|
61
|
-
const [ rawSettings ] = useGlobalSetting( '',
|
|
62
|
-
const settings = useSettingsForBlockElement( rawSettings,
|
|
60
|
+
export function useBlockHasGlobalStyles( blockName ) {
|
|
61
|
+
const [ rawSettings ] = useGlobalSetting( '', blockName );
|
|
62
|
+
const settings = useSettingsForBlockElement( rawSettings, blockName );
|
|
63
63
|
const hasTypographyPanel = useHasTypographyPanel( settings );
|
|
64
|
-
const hasColorPanel = useHasColorPanel(
|
|
64
|
+
const hasColorPanel = useHasColorPanel( settings );
|
|
65
65
|
const hasBorderPanel = useHasBorderPanel( settings );
|
|
66
66
|
const hasDimensionsPanel = useHasDimensionsPanel( settings );
|
|
67
67
|
const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
|
|
68
|
-
const hasVariationsPanel = useHasVariationsPanel(
|
|
69
|
-
const
|
|
68
|
+
const hasVariationsPanel = useHasVariationsPanel( blockName );
|
|
69
|
+
const hasGlobalStyles =
|
|
70
70
|
hasTypographyPanel ||
|
|
71
71
|
hasColorPanel ||
|
|
72
72
|
hasLayoutPanel ||
|
|
73
73
|
hasVariationsPanel;
|
|
74
|
+
return hasGlobalStyles;
|
|
75
|
+
}
|
|
74
76
|
|
|
77
|
+
function BlockMenuItem( { block } ) {
|
|
78
|
+
const hasBlockMenuItem = useBlockHasGlobalStyles( block.name );
|
|
75
79
|
if ( ! hasBlockMenuItem ) {
|
|
76
80
|
return null;
|
|
77
81
|
}
|
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
6
|
-
__experimentalItemGroup as ItemGroup,
|
|
7
|
-
__experimentalHStack as HStack,
|
|
8
|
-
__experimentalVStack as VStack,
|
|
9
|
-
__experimentalZStack as ZStack,
|
|
10
|
-
FlexItem,
|
|
11
|
-
ColorIndicator,
|
|
12
|
-
} from '@wordpress/components';
|
|
5
|
+
import { __experimentalVStack as VStack } from '@wordpress/components';
|
|
13
6
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
14
7
|
|
|
15
8
|
/**
|
|
@@ -17,205 +10,32 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
|
17
10
|
*/
|
|
18
11
|
import ScreenHeader from './header';
|
|
19
12
|
import Palette from './palette';
|
|
20
|
-
import { NavigationButtonAsItem } from './navigation-button';
|
|
21
|
-
import { useSupportedStyles } from './hooks';
|
|
22
|
-
import Subtitle from './subtitle';
|
|
23
|
-
import ColorIndicatorWrapper from './color-indicator-wrapper';
|
|
24
13
|
import BlockPreviewPanel from './block-preview-panel';
|
|
25
14
|
import { getVariationClassName } from './utils';
|
|
26
15
|
import { unlock } from '../../private-apis';
|
|
27
16
|
|
|
28
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
useGlobalStyle,
|
|
19
|
+
useGlobalSetting,
|
|
20
|
+
useSettingsForBlockElement,
|
|
21
|
+
ColorPanel: StylesColorPanel,
|
|
22
|
+
} = unlock( blockEditorPrivateApis );
|
|
29
23
|
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
const urlPrefix = variation ? `/variations/${ variation }` : '';
|
|
33
|
-
const supports = useSupportedStyles( name );
|
|
34
|
-
const hasSupport =
|
|
35
|
-
supports.includes( 'backgroundColor' ) ||
|
|
36
|
-
supports.includes( 'background' );
|
|
37
|
-
const [ backgroundColor ] = useGlobalStyle(
|
|
38
|
-
prefix + 'color.background',
|
|
39
|
-
name
|
|
40
|
-
);
|
|
41
|
-
const [ gradientValue ] = useGlobalStyle( prefix + 'color.gradient', name );
|
|
42
|
-
|
|
43
|
-
if ( ! hasSupport ) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<NavigationButtonAsItem
|
|
49
|
-
path={ parentMenu + urlPrefix + '/colors/background' }
|
|
50
|
-
aria-label={ __( 'Colors background styles' ) }
|
|
51
|
-
>
|
|
52
|
-
<HStack justify="flex-start">
|
|
53
|
-
<ColorIndicatorWrapper expanded={ false }>
|
|
54
|
-
<ColorIndicator
|
|
55
|
-
colorValue={ gradientValue ?? backgroundColor }
|
|
56
|
-
data-testid="background-color-indicator"
|
|
57
|
-
/>
|
|
58
|
-
</ColorIndicatorWrapper>
|
|
59
|
-
<FlexItem className="edit-site-global-styles__color-label">
|
|
60
|
-
{ __( 'Background' ) }
|
|
61
|
-
</FlexItem>
|
|
62
|
-
</HStack>
|
|
63
|
-
</NavigationButtonAsItem>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function TextColorItem( { name, parentMenu, variation = '' } ) {
|
|
68
|
-
const prefix = variation ? `variations.${ variation }.` : '';
|
|
69
|
-
const urlPrefix = variation ? `/variations/${ variation }` : '';
|
|
70
|
-
const supports = useSupportedStyles( name );
|
|
71
|
-
const hasSupport = supports.includes( 'color' );
|
|
72
|
-
const [ color ] = useGlobalStyle( prefix + 'color.text', name );
|
|
73
|
-
|
|
74
|
-
if ( ! hasSupport ) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<NavigationButtonAsItem
|
|
80
|
-
path={ parentMenu + urlPrefix + '/colors/text' }
|
|
81
|
-
aria-label={ __( 'Colors text styles' ) }
|
|
82
|
-
>
|
|
83
|
-
<HStack justify="flex-start">
|
|
84
|
-
<ColorIndicatorWrapper expanded={ false }>
|
|
85
|
-
<ColorIndicator
|
|
86
|
-
colorValue={ color }
|
|
87
|
-
data-testid="text-color-indicator"
|
|
88
|
-
/>
|
|
89
|
-
</ColorIndicatorWrapper>
|
|
90
|
-
<FlexItem className="edit-site-global-styles__color-label">
|
|
91
|
-
{ __( 'Text' ) }
|
|
92
|
-
</FlexItem>
|
|
93
|
-
</HStack>
|
|
94
|
-
</NavigationButtonAsItem>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function LinkColorItem( { name, parentMenu, variation = '' } ) {
|
|
99
|
-
const prefix = variation ? `variations.${ variation }.` : '';
|
|
100
|
-
const urlPrefix = variation ? `/variations/${ variation }` : '';
|
|
101
|
-
const supports = useSupportedStyles( name );
|
|
102
|
-
const hasSupport = supports.includes( 'linkColor' );
|
|
103
|
-
const [ color ] = useGlobalStyle(
|
|
104
|
-
prefix + 'elements.link.color.text',
|
|
105
|
-
name
|
|
106
|
-
);
|
|
107
|
-
const [ colorHover ] = useGlobalStyle(
|
|
108
|
-
prefix + 'elements.link.:hover.color.text',
|
|
109
|
-
name
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
if ( ! hasSupport ) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<NavigationButtonAsItem
|
|
118
|
-
path={ parentMenu + urlPrefix + '/colors/link' }
|
|
119
|
-
aria-label={ __( 'Colors link styles' ) }
|
|
120
|
-
>
|
|
121
|
-
<HStack justify="flex-start">
|
|
122
|
-
<ZStack isLayered={ false } offset={ -8 }>
|
|
123
|
-
<ColorIndicatorWrapper expanded={ false }>
|
|
124
|
-
<ColorIndicator colorValue={ color } />
|
|
125
|
-
</ColorIndicatorWrapper>
|
|
126
|
-
<ColorIndicatorWrapper expanded={ false }>
|
|
127
|
-
<ColorIndicator colorValue={ colorHover } />
|
|
128
|
-
</ColorIndicatorWrapper>
|
|
129
|
-
</ZStack>
|
|
130
|
-
<FlexItem className="edit-site-global-styles__color-label">
|
|
131
|
-
{ __( 'Links' ) }
|
|
132
|
-
</FlexItem>
|
|
133
|
-
</HStack>
|
|
134
|
-
</NavigationButtonAsItem>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function HeadingColorItem( { name, parentMenu, variation = '' } ) {
|
|
139
|
-
const prefix = variation ? `variations.${ variation }.` : '';
|
|
140
|
-
const urlPrefix = variation ? `/variations/${ variation }` : '';
|
|
141
|
-
const supports = useSupportedStyles( name );
|
|
142
|
-
const hasSupport = supports.includes( 'color' );
|
|
143
|
-
const [ color ] = useGlobalStyle(
|
|
144
|
-
prefix + 'elements.heading.color.text',
|
|
145
|
-
name
|
|
146
|
-
);
|
|
147
|
-
const [ bgColor ] = useGlobalStyle(
|
|
148
|
-
prefix + 'elements.heading.color.background',
|
|
149
|
-
name
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
if ( ! hasSupport ) {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<NavigationButtonAsItem
|
|
158
|
-
path={ parentMenu + urlPrefix + '/colors/heading' }
|
|
159
|
-
aria-label={ __( 'Colors heading styles' ) }
|
|
160
|
-
>
|
|
161
|
-
<HStack justify="flex-start">
|
|
162
|
-
<ZStack isLayered={ false } offset={ -8 }>
|
|
163
|
-
<ColorIndicatorWrapper expanded={ false }>
|
|
164
|
-
<ColorIndicator colorValue={ bgColor } />
|
|
165
|
-
</ColorIndicatorWrapper>
|
|
166
|
-
<ColorIndicatorWrapper expanded={ false }>
|
|
167
|
-
<ColorIndicator colorValue={ color } />
|
|
168
|
-
</ColorIndicatorWrapper>
|
|
169
|
-
</ZStack>
|
|
170
|
-
<FlexItem>{ __( 'Headings' ) }</FlexItem>
|
|
171
|
-
</HStack>
|
|
172
|
-
</NavigationButtonAsItem>
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function ButtonColorItem( { name, parentMenu, variation = '' } ) {
|
|
177
|
-
const prefix = variation ? `variations.${ variation }.` : '';
|
|
178
|
-
const urlPrefix = variation ? `/variations/${ variation }` : '';
|
|
179
|
-
const supports = useSupportedStyles( name );
|
|
180
|
-
const hasSupport = supports.includes( 'buttonColor' );
|
|
181
|
-
const [ color ] = useGlobalStyle(
|
|
182
|
-
prefix + 'elements.button.color.text',
|
|
183
|
-
name
|
|
184
|
-
);
|
|
185
|
-
const [ bgColor ] = useGlobalStyle(
|
|
186
|
-
prefix + 'elements.button.color.background',
|
|
187
|
-
name
|
|
188
|
-
);
|
|
24
|
+
function ScreenColors( { name, variation = '' } ) {
|
|
25
|
+
const variationClassName = getVariationClassName( variation );
|
|
189
26
|
|
|
190
|
-
|
|
191
|
-
|
|
27
|
+
let prefixParts = [];
|
|
28
|
+
if ( variation ) {
|
|
29
|
+
prefixParts = [ 'variations', variation ].concat( prefixParts );
|
|
192
30
|
}
|
|
31
|
+
const prefix = prefixParts.join( '.' );
|
|
193
32
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
<ColorIndicatorWrapper expanded={ false }>
|
|
201
|
-
<ColorIndicator colorValue={ bgColor } />
|
|
202
|
-
</ColorIndicatorWrapper>
|
|
203
|
-
<ColorIndicatorWrapper expanded={ false }>
|
|
204
|
-
<ColorIndicator colorValue={ color } />
|
|
205
|
-
</ColorIndicatorWrapper>
|
|
206
|
-
</ZStack>
|
|
207
|
-
<FlexItem className="edit-site-global-styles__color-label">
|
|
208
|
-
{ __( 'Buttons' ) }
|
|
209
|
-
</FlexItem>
|
|
210
|
-
</HStack>
|
|
211
|
-
</NavigationButtonAsItem>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function ScreenColors( { name, variation = '' } ) {
|
|
216
|
-
const parentMenu =
|
|
217
|
-
name === undefined ? '' : '/blocks/' + encodeURIComponent( name );
|
|
218
|
-
const variationClassName = getVariationClassName( variation );
|
|
33
|
+
const [ style ] = useGlobalStyle( prefix, name, 'user', false );
|
|
34
|
+
const [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {
|
|
35
|
+
shouldDecodeEncode: false,
|
|
36
|
+
} );
|
|
37
|
+
const [ rawSettings ] = useGlobalSetting( '', name );
|
|
38
|
+
const settings = useSettingsForBlockElement( rawSettings, name );
|
|
219
39
|
|
|
220
40
|
return (
|
|
221
41
|
<>
|
|
@@ -232,36 +52,12 @@ function ScreenColors( { name, variation = '' } ) {
|
|
|
232
52
|
<VStack spacing={ 10 }>
|
|
233
53
|
<Palette name={ name } />
|
|
234
54
|
|
|
235
|
-
<
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
variation={ variation }
|
|
242
|
-
/>
|
|
243
|
-
<TextColorItem
|
|
244
|
-
name={ name }
|
|
245
|
-
parentMenu={ parentMenu }
|
|
246
|
-
variation={ variation }
|
|
247
|
-
/>
|
|
248
|
-
<LinkColorItem
|
|
249
|
-
name={ name }
|
|
250
|
-
parentMenu={ parentMenu }
|
|
251
|
-
variation={ variation }
|
|
252
|
-
/>
|
|
253
|
-
<HeadingColorItem
|
|
254
|
-
name={ name }
|
|
255
|
-
parentMenu={ parentMenu }
|
|
256
|
-
variation={ variation }
|
|
257
|
-
/>
|
|
258
|
-
<ButtonColorItem
|
|
259
|
-
name={ name }
|
|
260
|
-
parentMenu={ parentMenu }
|
|
261
|
-
variation={ variation }
|
|
262
|
-
/>
|
|
263
|
-
</ItemGroup>
|
|
264
|
-
</VStack>
|
|
55
|
+
<StylesColorPanel
|
|
56
|
+
inheritedValue={ inheritedStyle }
|
|
57
|
+
value={ style }
|
|
58
|
+
onChange={ setStyle }
|
|
59
|
+
settings={ settings }
|
|
60
|
+
/>
|
|
265
61
|
</VStack>
|
|
266
62
|
</div>
|
|
267
63
|
</>
|
|
@@ -38,7 +38,7 @@ function ScreenCSS( { name } ) {
|
|
|
38
38
|
<>
|
|
39
39
|
{ description }
|
|
40
40
|
<ExternalLink
|
|
41
|
-
href="https://wordpress.org/
|
|
41
|
+
href="https://wordpress.org/documentation/article/css/"
|
|
42
42
|
className="edit-site-global-styles-screen-css-help-link"
|
|
43
43
|
>
|
|
44
44
|
{ __( 'Learn more about CSS' ) }
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -9,17 +10,23 @@ import { __ } from '@wordpress/i18n';
|
|
|
9
10
|
import ScreenHeader from './header';
|
|
10
11
|
import BlockPreviewPanel from './block-preview-panel';
|
|
11
12
|
import { getVariationClassName } from './utils';
|
|
12
|
-
import
|
|
13
|
+
import { unlock } from '../../private-apis';
|
|
14
|
+
import EffectsPanel from './effects-panel';
|
|
15
|
+
|
|
16
|
+
const { useGlobalSetting, useSettingsForBlockElement, useHasEffectsPanel } =
|
|
17
|
+
unlock( blockEditorPrivateApis );
|
|
13
18
|
|
|
14
19
|
function ScreenEffects( { name, variation = '' } ) {
|
|
20
|
+
const [ rawSettings ] = useGlobalSetting( '', name );
|
|
21
|
+
const settings = useSettingsForBlockElement( rawSettings, name );
|
|
15
22
|
const variationClassName = getVariationClassName( variation );
|
|
16
|
-
const
|
|
23
|
+
const hasEffectsPanel = useHasEffectsPanel( settings );
|
|
17
24
|
return (
|
|
18
25
|
<>
|
|
19
|
-
<ScreenHeader title={ __( '
|
|
26
|
+
<ScreenHeader title={ __( 'Effects' ) } />
|
|
20
27
|
<BlockPreviewPanel name={ name } variation={ variationClassName } />
|
|
21
|
-
{
|
|
22
|
-
<
|
|
28
|
+
{ hasEffectsPanel && (
|
|
29
|
+
<EffectsPanel name={ name } variation={ variation } />
|
|
23
30
|
) }
|
|
24
31
|
</>
|
|
25
32
|
);
|
|
@@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import FiltersPanel from './filters-panel';
|
|
10
10
|
import BlockPreviewPanel from './block-preview-panel';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -19,7 +19,7 @@ function ScreenFilters( { name } ) {
|
|
|
19
19
|
<>
|
|
20
20
|
<ScreenHeader title={ __( 'Filters' ) } />
|
|
21
21
|
<BlockPreviewPanel name={ name } />
|
|
22
|
-
<
|
|
22
|
+
<FiltersPanel name={ name } />
|
|
23
23
|
</>
|
|
24
24
|
);
|
|
25
25
|
}
|
|
@@ -1,143 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* WordPress dependencies
|
|
9
3
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
-
import {
|
|
13
|
-
useMemo,
|
|
14
|
-
useContext,
|
|
15
|
-
useState,
|
|
16
|
-
useEffect,
|
|
17
|
-
useRef,
|
|
18
|
-
} from '@wordpress/element';
|
|
19
|
-
import { ENTER } from '@wordpress/keycodes';
|
|
20
|
-
import {
|
|
21
|
-
__experimentalGrid as Grid,
|
|
22
|
-
Card,
|
|
23
|
-
CardBody,
|
|
24
|
-
} from '@wordpress/components';
|
|
4
|
+
import { Card, CardBody } from '@wordpress/components';
|
|
25
5
|
import { __ } from '@wordpress/i18n';
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from '@wordpress/block-editor';
|
|
6
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
import { useEffect, useRef } from '@wordpress/element';
|
|
8
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
30
9
|
|
|
31
10
|
/**
|
|
32
11
|
* Internal dependencies
|
|
33
12
|
*/
|
|
34
|
-
import { mergeBaseAndUserConfigs } from './global-styles-provider';
|
|
35
|
-
import StylesPreview from './preview';
|
|
36
13
|
import ScreenHeader from './header';
|
|
37
|
-
import
|
|
38
|
-
|
|
39
|
-
const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
|
|
40
|
-
|
|
41
|
-
function compareVariations( a, b ) {
|
|
42
|
-
return (
|
|
43
|
-
fastDeepEqual( a.styles, b.styles ) &&
|
|
44
|
-
fastDeepEqual( a.settings, b.settings )
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function Variation( { variation } ) {
|
|
49
|
-
const [ isFocused, setIsFocused ] = useState( false );
|
|
50
|
-
const { base, user, setUserConfig } = useContext( GlobalStylesContext );
|
|
51
|
-
const context = useMemo( () => {
|
|
52
|
-
return {
|
|
53
|
-
user: {
|
|
54
|
-
settings: variation.settings ?? {},
|
|
55
|
-
styles: variation.styles ?? {},
|
|
56
|
-
},
|
|
57
|
-
base,
|
|
58
|
-
merged: mergeBaseAndUserConfigs( base, variation ),
|
|
59
|
-
setUserConfig: () => {},
|
|
60
|
-
};
|
|
61
|
-
}, [ variation, base ] );
|
|
62
|
-
|
|
63
|
-
const selectVariation = () => {
|
|
64
|
-
setUserConfig( () => {
|
|
65
|
-
return {
|
|
66
|
-
settings: variation.settings,
|
|
67
|
-
styles: variation.styles,
|
|
68
|
-
};
|
|
69
|
-
} );
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const selectOnEnter = ( event ) => {
|
|
73
|
-
if ( event.keyCode === ENTER ) {
|
|
74
|
-
event.preventDefault();
|
|
75
|
-
selectVariation();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const isActive = useMemo( () => {
|
|
80
|
-
return compareVariations( user, variation );
|
|
81
|
-
}, [ user, variation ] );
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<GlobalStylesContext.Provider value={ context }>
|
|
85
|
-
<div
|
|
86
|
-
className={ classnames(
|
|
87
|
-
'edit-site-global-styles-variations_item',
|
|
88
|
-
{
|
|
89
|
-
'is-active': isActive,
|
|
90
|
-
}
|
|
91
|
-
) }
|
|
92
|
-
role="button"
|
|
93
|
-
onClick={ selectVariation }
|
|
94
|
-
onKeyDown={ selectOnEnter }
|
|
95
|
-
tabIndex="0"
|
|
96
|
-
aria-label={ variation?.title }
|
|
97
|
-
aria-current={ isActive }
|
|
98
|
-
onFocus={ () => setIsFocused( true ) }
|
|
99
|
-
onBlur={ () => setIsFocused( false ) }
|
|
100
|
-
>
|
|
101
|
-
<div className="edit-site-global-styles-variations_item-preview">
|
|
102
|
-
<StylesPreview
|
|
103
|
-
label={ variation?.title }
|
|
104
|
-
isFocused={ isFocused }
|
|
105
|
-
withHoverView
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
</GlobalStylesContext.Provider>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
14
|
+
import StyleVariationsContainer from './style-variations-container';
|
|
112
15
|
|
|
113
16
|
function ScreenStyleVariations() {
|
|
114
|
-
const {
|
|
17
|
+
const { mode } = useSelect( ( select ) => {
|
|
115
18
|
return {
|
|
116
|
-
variations:
|
|
117
|
-
select(
|
|
118
|
-
coreStore
|
|
119
|
-
).__experimentalGetCurrentThemeGlobalStylesVariations(),
|
|
120
|
-
|
|
121
19
|
mode: select( blockEditorStore ).__unstableGetEditorMode(),
|
|
122
20
|
};
|
|
123
21
|
}, [] );
|
|
124
22
|
|
|
125
|
-
const withEmptyVariation = useMemo( () => {
|
|
126
|
-
return [
|
|
127
|
-
{
|
|
128
|
-
title: __( 'Default' ),
|
|
129
|
-
settings: {},
|
|
130
|
-
styles: {},
|
|
131
|
-
},
|
|
132
|
-
...variations.map( ( variation ) => ( {
|
|
133
|
-
...variation,
|
|
134
|
-
settings: variation.settings ?? {},
|
|
135
|
-
styles: variation.styles ?? {},
|
|
136
|
-
} ) ),
|
|
137
|
-
];
|
|
138
|
-
}, [ variations ] );
|
|
139
|
-
|
|
140
|
-
const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
|
|
141
23
|
const shouldRevertInitialMode = useRef( null );
|
|
142
24
|
useEffect( () => {
|
|
143
25
|
// ignore changes to zoom-out mode as we explictily change to it on mount.
|
|
@@ -160,8 +42,11 @@ function ScreenStyleVariations() {
|
|
|
160
42
|
}
|
|
161
43
|
};
|
|
162
44
|
}
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
163
46
|
}, [] );
|
|
164
47
|
|
|
48
|
+
const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
|
|
49
|
+
|
|
165
50
|
return (
|
|
166
51
|
<>
|
|
167
52
|
<ScreenHeader
|
|
@@ -178,11 +63,7 @@ function ScreenStyleVariations() {
|
|
|
178
63
|
className="edit-site-global-styles-screen-style-variations"
|
|
179
64
|
>
|
|
180
65
|
<CardBody>
|
|
181
|
-
<
|
|
182
|
-
{ withEmptyVariation?.map( ( variation, index ) => (
|
|
183
|
-
<Variation key={ index } variation={ variation } />
|
|
184
|
-
) ) }
|
|
185
|
-
</Grid>
|
|
66
|
+
<StyleVariationsContainer />
|
|
186
67
|
</CardBody>
|
|
187
68
|
</Card>
|
|
188
69
|
</>
|