@wordpress/edit-site 5.3.6 → 5.5.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.js +1 -20
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/app/index.js.map +1 -1
- package/build/components/block-editor/editor-canvas.js +1 -0
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +3 -1
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -5
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-palette-panel.js +5 -2
- package/build/components/global-styles/color-palette-panel.js.map +1 -1
- package/build/components/global-styles/color-utils.js +1 -1
- package/build/components/global-styles/color-utils.js.map +1 -1
- package/build/components/global-styles/context-menu.js +22 -6
- package/build/components/global-styles/context-menu.js.map +1 -1
- package/build/components/global-styles/custom-css.js +1 -1
- package/build/components/global-styles/custom-css.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +41 -486
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/duotone-panel.js +78 -0
- package/build/components/global-styles/duotone-panel.js.map +1 -0
- package/build/components/global-styles/filter-utils.js +17 -0
- package/build/components/global-styles/filter-utils.js.map +1 -0
- package/build/components/global-styles/gradients-palette-panel.js +8 -3
- package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build/components/global-styles/header.js +3 -1
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/hooks.js +14 -51
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/palette.js +3 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +9 -5
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-background-color.js +3 -2
- package/build/components/global-styles/screen-background-color.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +13 -6
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-button-color.js +7 -5
- package/build/components/global-styles/screen-button-color.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +8 -6
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-filters.js +46 -0
- package/build/components/global-styles/screen-filters.js.map +1 -0
- package/build/components/global-styles/screen-heading-color.js +8 -6
- package/build/components/global-styles/screen-heading-color.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +13 -5
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-link-color.js +3 -2
- package/build/components/global-styles/screen-link-color.js.map +1 -1
- package/build/components/global-styles/screen-text-color.js +3 -2
- package/build/components/global-styles/screen-text-color.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +3 -1
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/shadow-panel.js +2 -3
- package/build/components/global-styles/shadow-panel.js.map +1 -1
- package/build/components/global-styles/subtitle.js +3 -2
- package/build/components/global-styles/subtitle.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +23 -303
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/ui.js +6 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +67 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/navigation-inspector/index.js +0 -29
- package/build/components/navigation-inspector/index.js.map +1 -1
- package/build/components/navigation-inspector/navigation-menu.js +22 -5
- package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -1
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/index.js +9 -2
- package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-card/last-revision.js +84 -0
- package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
- package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build/components/start-template-options/index.js +175 -0
- package/build/components/start-template-options/index.js.map +1 -0
- package/build/hooks/push-changes-to-global-styles/index.js +5 -4
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/store/actions.js +2 -2
- package/build/store/actions.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +1 -18
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/app/index.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +1 -0
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +2 -1
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +6 -6
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-palette-panel.js +5 -2
- package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/color-utils.js +2 -2
- package/build-module/components/global-styles/color-utils.js.map +1 -1
- package/build-module/components/global-styles/context-menu.js +20 -6
- package/build-module/components/global-styles/context-menu.js.map +1 -1
- package/build-module/components/global-styles/custom-css.js +1 -1
- package/build-module/components/global-styles/custom-css.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +43 -479
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/duotone-panel.js +67 -0
- package/build-module/components/global-styles/duotone-panel.js.map +1 -0
- package/build-module/components/global-styles/filter-utils.js +9 -0
- package/build-module/components/global-styles/filter-utils.js.map +1 -0
- package/build-module/components/global-styles/gradients-palette-panel.js +8 -3
- package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +3 -1
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +12 -49
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/palette.js +3 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +10 -6
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-background-color.js +4 -3
- package/build-module/components/global-styles/screen-background-color.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +12 -5
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-button-color.js +8 -6
- package/build-module/components/global-styles/screen-button-color.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +9 -7
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-filters.js +33 -0
- package/build-module/components/global-styles/screen-filters.js.map +1 -0
- package/build-module/components/global-styles/screen-heading-color.js +9 -7
- package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +11 -2
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-link-color.js +4 -3
- package/build-module/components/global-styles/screen-link-color.js.map +1 -1
- package/build-module/components/global-styles/screen-text-color.js +4 -3
- package/build-module/components/global-styles/screen-text-color.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -1
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel.js +3 -4
- package/build-module/components/global-styles/shadow-panel.js.map +1 -1
- package/build-module/components/global-styles/subtitle.js +3 -2
- package/build-module/components/global-styles/subtitle.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +24 -300
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/ui.js +5 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +65 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/navigation-inspector/index.js +0 -27
- package/build-module/components/navigation-inspector/index.js.map +1 -1
- package/build-module/components/navigation-inspector/navigation-menu.js +25 -8
- package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +1 -1
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/index.js +9 -4
- package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-card/last-revision.js +70 -0
- package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +156 -0
- package/build-module/components/start-template-options/index.js.map +1 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js +6 -5
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/store/actions.js +2 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +73 -4
- package/build-style/style.css +73 -4
- package/package.json +31 -31
- package/src/components/add-new-template/new-template.js +1 -16
- package/src/components/app/index.js +0 -1
- package/src/components/block-editor/editor-canvas.js +1 -0
- package/src/components/editor/index.js +2 -0
- package/src/components/global-styles/border-panel.js +6 -6
- package/src/components/global-styles/color-palette-panel.js +3 -0
- package/src/components/global-styles/color-utils.js +2 -3
- package/src/components/global-styles/context-menu.js +25 -4
- package/src/components/global-styles/custom-css.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +43 -573
- package/src/components/global-styles/duotone-panel.js +82 -0
- package/src/components/global-styles/filter-utils.js +9 -0
- package/src/components/global-styles/gradients-palette-panel.js +4 -1
- package/src/components/global-styles/header.js +7 -1
- package/src/components/global-styles/hooks.js +17 -90
- package/src/components/global-styles/palette.js +1 -1
- package/src/components/global-styles/preview.js +155 -140
- package/src/components/global-styles/screen-background-color.js +3 -2
- package/src/components/global-styles/screen-block-list.js +16 -5
- package/src/components/global-styles/screen-button-color.js +8 -6
- package/src/components/global-styles/screen-colors.js +7 -7
- package/src/components/global-styles/screen-filters.js +27 -0
- package/src/components/global-styles/screen-heading-color.js +9 -7
- package/src/components/global-styles/screen-layout.js +9 -2
- package/src/components/global-styles/screen-link-color.js +3 -2
- package/src/components/global-styles/screen-text-color.js +3 -2
- package/src/components/global-styles/screen-typography.js +1 -1
- package/src/components/global-styles/shadow-panel.js +6 -3
- package/src/components/global-styles/style.scss +5 -0
- package/src/components/global-styles/subtitle.js +5 -2
- package/src/components/global-styles/typography-panel.js +29 -395
- package/src/components/global-styles/ui.js +5 -0
- package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
- package/src/components/keyboard-shortcuts/index.js +70 -0
- package/src/components/navigation-inspector/index.js +0 -32
- package/src/components/navigation-inspector/navigation-menu.js +24 -6
- package/src/components/sidebar-edit-mode/index.js +1 -1
- package/src/components/sidebar-edit-mode/template-card/index.js +24 -14
- package/src/components/sidebar-edit-mode/template-card/last-revision.js +75 -0
- package/src/components/sidebar-edit-mode/template-card/style.scss +4 -0
- package/src/components/sidebar-navigation-screen-navigation-menus/index.js +7 -1
- package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +0 -4
- package/src/components/start-template-options/index.js +171 -0
- package/src/components/start-template-options/style.scss +76 -0
- package/src/hooks/push-changes-to-global-styles/index.js +26 -21
- package/src/store/actions.js +2 -2
- package/src/style.scss +1 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
7
|
+
DuotonePicker,
|
|
8
|
+
} from '@wordpress/components';
|
|
9
|
+
import {
|
|
10
|
+
privateApis as blockEditorPrivateApis,
|
|
11
|
+
useSetting,
|
|
12
|
+
} from '@wordpress/block-editor';
|
|
13
|
+
import { useMemo } from '@wordpress/element';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { unlock } from '../../private-apis';
|
|
19
|
+
const { useGlobalStyle } = unlock( blockEditorPrivateApis );
|
|
20
|
+
|
|
21
|
+
const EMPTY_ARRAY = [];
|
|
22
|
+
|
|
23
|
+
function useMultiOriginPresets( { presetSetting, defaultSetting } ) {
|
|
24
|
+
const disableDefault = ! useSetting( defaultSetting );
|
|
25
|
+
const userPresets =
|
|
26
|
+
useSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;
|
|
27
|
+
const themePresets =
|
|
28
|
+
useSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;
|
|
29
|
+
const defaultPresets =
|
|
30
|
+
useSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;
|
|
31
|
+
return useMemo(
|
|
32
|
+
() => [
|
|
33
|
+
...userPresets,
|
|
34
|
+
...themePresets,
|
|
35
|
+
...( disableDefault ? EMPTY_ARRAY : defaultPresets ),
|
|
36
|
+
],
|
|
37
|
+
[ disableDefault, userPresets, themePresets, defaultPresets ]
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function DuotonePanel( { name } ) {
|
|
42
|
+
const [ themeDuotone, setThemeDuotone ] = useGlobalStyle(
|
|
43
|
+
'filter.duotone',
|
|
44
|
+
name
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const duotonePalette = useMultiOriginPresets( {
|
|
48
|
+
presetSetting: 'color.duotone',
|
|
49
|
+
defaultSetting: 'color.defaultDuotone',
|
|
50
|
+
} );
|
|
51
|
+
const colorPalette = useMultiOriginPresets( {
|
|
52
|
+
presetSetting: 'color.palette',
|
|
53
|
+
defaultSetting: 'color.defaultPalette',
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
if ( duotonePalette?.length === 0 ) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
<ToolsPanel label={ __( 'Duotone' ) }>
|
|
62
|
+
<span className="span-columns">
|
|
63
|
+
{ __(
|
|
64
|
+
'Create a two-tone color effect without losing your original image.'
|
|
65
|
+
) }
|
|
66
|
+
</span>
|
|
67
|
+
<div className="span-columns">
|
|
68
|
+
<DuotonePicker
|
|
69
|
+
colorPalette={ colorPalette }
|
|
70
|
+
duotonePalette={ duotonePalette }
|
|
71
|
+
disableCustomColors={ true }
|
|
72
|
+
disableCustomDuotone={ true }
|
|
73
|
+
value={ themeDuotone }
|
|
74
|
+
onChange={ setThemeDuotone }
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
</ToolsPanel>
|
|
78
|
+
</>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default DuotonePanel;
|
|
@@ -75,6 +75,7 @@ export default function GradientPalettePanel( { name } ) {
|
|
|
75
75
|
gradients={ themeGradients }
|
|
76
76
|
onChange={ setThemeGradients }
|
|
77
77
|
paletteLabel={ __( 'Theme' ) }
|
|
78
|
+
paletteLabelHeadingLevel={ 3 }
|
|
78
79
|
/>
|
|
79
80
|
) }
|
|
80
81
|
{ !! defaultGradients &&
|
|
@@ -86,12 +87,14 @@ export default function GradientPalettePanel( { name } ) {
|
|
|
86
87
|
gradients={ defaultGradients }
|
|
87
88
|
onChange={ setDefaultGradients }
|
|
88
89
|
paletteLabel={ __( 'Default' ) }
|
|
90
|
+
paletteLabelLevel={ 3 }
|
|
89
91
|
/>
|
|
90
92
|
) }
|
|
91
93
|
<PaletteEdit
|
|
92
94
|
gradients={ customGradients }
|
|
93
95
|
onChange={ setCustomGradients }
|
|
94
96
|
paletteLabel={ __( 'Custom' ) }
|
|
97
|
+
paletteLabelLevel={ 3 }
|
|
95
98
|
emptyMessage={ __(
|
|
96
99
|
'Custom gradients are empty! Add some gradients to create your own palette.'
|
|
97
100
|
) }
|
|
@@ -99,7 +102,7 @@ export default function GradientPalettePanel( { name } ) {
|
|
|
99
102
|
/>
|
|
100
103
|
{ !! duotonePalette && !! duotonePalette.length && (
|
|
101
104
|
<div>
|
|
102
|
-
<Subtitle>{ __( 'Duotone' ) }</Subtitle>
|
|
105
|
+
<Subtitle level={ 3 }>{ __( 'Duotone' ) }</Subtitle>
|
|
103
106
|
<Spacer margin={ 3 } />
|
|
104
107
|
<DuotonePicker
|
|
105
108
|
duotonePalette={ duotonePalette }
|
|
@@ -29,7 +29,13 @@ function ScreenHeader( { title, description } ) {
|
|
|
29
29
|
aria-label={ __( 'Navigate to the previous view' ) }
|
|
30
30
|
/>
|
|
31
31
|
<Spacer>
|
|
32
|
-
<Heading
|
|
32
|
+
<Heading
|
|
33
|
+
className="edit-site-global-styles-header"
|
|
34
|
+
level={ 2 }
|
|
35
|
+
size={ 13 }
|
|
36
|
+
>
|
|
37
|
+
{ title }
|
|
38
|
+
</Heading>
|
|
33
39
|
</Spacer>
|
|
34
40
|
</HStack>
|
|
35
41
|
</Spacer>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get } from 'lodash';
|
|
5
4
|
import { colord, extend } from 'colord';
|
|
6
5
|
import a11yPlugin from 'colord/plugins/a11y';
|
|
7
6
|
|
|
@@ -10,107 +9,20 @@ import a11yPlugin from 'colord/plugins/a11y';
|
|
|
10
9
|
*/
|
|
11
10
|
import { _x } from '@wordpress/i18n';
|
|
12
11
|
import { useMemo } from '@wordpress/element';
|
|
13
|
-
import {
|
|
14
|
-
getBlockType,
|
|
15
|
-
__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,
|
|
16
|
-
} from '@wordpress/blocks';
|
|
12
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
17
13
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
18
14
|
|
|
19
15
|
/**
|
|
20
16
|
* Internal dependencies
|
|
21
17
|
*/
|
|
22
18
|
import { unlock } from '../../private-apis';
|
|
19
|
+
import { useSelect } from '@wordpress/data';
|
|
23
20
|
|
|
24
21
|
const { useGlobalSetting } = unlock( blockEditorPrivateApis );
|
|
25
22
|
|
|
26
23
|
// Enable colord's a11y plugin.
|
|
27
24
|
extend( [ a11yPlugin ] );
|
|
28
25
|
|
|
29
|
-
const ROOT_BLOCK_SUPPORTS = [
|
|
30
|
-
'background',
|
|
31
|
-
'backgroundColor',
|
|
32
|
-
'color',
|
|
33
|
-
'linkColor',
|
|
34
|
-
'buttonColor',
|
|
35
|
-
'fontFamily',
|
|
36
|
-
'fontSize',
|
|
37
|
-
'fontStyle',
|
|
38
|
-
'fontWeight',
|
|
39
|
-
'lineHeight',
|
|
40
|
-
'textDecoration',
|
|
41
|
-
'padding',
|
|
42
|
-
'contentSize',
|
|
43
|
-
'wideSize',
|
|
44
|
-
'blockGap',
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
export function getSupportedGlobalStylesPanels( name ) {
|
|
48
|
-
if ( ! name ) {
|
|
49
|
-
return ROOT_BLOCK_SUPPORTS;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const blockType = getBlockType( name );
|
|
53
|
-
|
|
54
|
-
if ( ! blockType ) {
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const supportKeys = [];
|
|
59
|
-
|
|
60
|
-
// Check for blockGap support.
|
|
61
|
-
// Block spacing support doesn't map directly to a single style property, so needs to be handled separately.
|
|
62
|
-
// Also, only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied.
|
|
63
|
-
if (
|
|
64
|
-
blockType?.supports?.spacing?.blockGap &&
|
|
65
|
-
blockType?.supports?.spacing?.__experimentalSkipSerialization !==
|
|
66
|
-
true &&
|
|
67
|
-
! blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(
|
|
68
|
-
( spacingType ) => spacingType === 'blockGap'
|
|
69
|
-
)
|
|
70
|
-
) {
|
|
71
|
-
supportKeys.push( 'blockGap' );
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// check for shadow support
|
|
75
|
-
if ( blockType?.supports?.shadow ) {
|
|
76
|
-
supportKeys.push( 'shadow' );
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
Object.keys( STYLE_PROPERTY ).forEach( ( styleName ) => {
|
|
80
|
-
if ( ! STYLE_PROPERTY[ styleName ].support ) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Opting out means that, for certain support keys like background color,
|
|
85
|
-
// blocks have to explicitly set the support value false. If the key is
|
|
86
|
-
// unset, we still enable it.
|
|
87
|
-
if ( STYLE_PROPERTY[ styleName ].requiresOptOut ) {
|
|
88
|
-
if (
|
|
89
|
-
STYLE_PROPERTY[ styleName ].support[ 0 ] in
|
|
90
|
-
blockType.supports &&
|
|
91
|
-
get(
|
|
92
|
-
blockType.supports,
|
|
93
|
-
STYLE_PROPERTY[ styleName ].support
|
|
94
|
-
) !== false
|
|
95
|
-
) {
|
|
96
|
-
return supportKeys.push( styleName );
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
get(
|
|
102
|
-
blockType.supports,
|
|
103
|
-
STYLE_PROPERTY[ styleName ].support,
|
|
104
|
-
false
|
|
105
|
-
)
|
|
106
|
-
) {
|
|
107
|
-
return supportKeys.push( styleName );
|
|
108
|
-
}
|
|
109
|
-
} );
|
|
110
|
-
|
|
111
|
-
return supportKeys;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
26
|
export function useColorsPerOrigin( name ) {
|
|
115
27
|
const [ customColors ] = useGlobalSetting( 'color.palette.custom', name );
|
|
116
28
|
const [ themeColors ] = useGlobalSetting( 'color.palette.theme', name );
|
|
@@ -240,3 +152,18 @@ export function useColorRandomizer( name ) {
|
|
|
240
152
|
? [ randomizeColors ]
|
|
241
153
|
: [];
|
|
242
154
|
}
|
|
155
|
+
|
|
156
|
+
export function useSupportedStyles( name, element ) {
|
|
157
|
+
const { supportedPanels } = useSelect(
|
|
158
|
+
( select ) => {
|
|
159
|
+
return {
|
|
160
|
+
supportedPanels: unlock(
|
|
161
|
+
select( blocksStore )
|
|
162
|
+
).getSupportedStyles( name, element ),
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
[ name, element ]
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
return supportedPanels;
|
|
169
|
+
}
|
|
@@ -107,163 +107,178 @@ const StylesPreview = ( { label, isFocused, withHoverView } ) => {
|
|
|
107
107
|
|
|
108
108
|
return styles;
|
|
109
109
|
}, [ styles ] );
|
|
110
|
+
const isReady = !! width;
|
|
110
111
|
|
|
111
112
|
return (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
onMouseLeave={ () => setIsHovered( false ) }
|
|
121
|
-
tabIndex={ -1 }
|
|
122
|
-
>
|
|
123
|
-
{ containerResizeListener }
|
|
124
|
-
<motion.div
|
|
125
|
-
style={ {
|
|
126
|
-
height: normalizedHeight * ratio,
|
|
127
|
-
width: '100%',
|
|
128
|
-
background: gradientValue ?? backgroundColor,
|
|
129
|
-
cursor: 'pointer',
|
|
130
|
-
} }
|
|
131
|
-
initial="start"
|
|
132
|
-
animate={
|
|
133
|
-
( isHovered || isFocused ) && ! disableMotion && label
|
|
134
|
-
? 'hover'
|
|
135
|
-
: 'start'
|
|
136
|
-
}
|
|
137
|
-
>
|
|
138
|
-
<motion.div
|
|
139
|
-
variants={ firstFrame }
|
|
113
|
+
<>
|
|
114
|
+
<div style={ { position: 'relative' } }>
|
|
115
|
+
{ containerResizeListener }
|
|
116
|
+
</div>
|
|
117
|
+
{ isReady && (
|
|
118
|
+
<Iframe
|
|
119
|
+
className="edit-site-global-styles-preview__iframe"
|
|
120
|
+
head={ <EditorStyles styles={ editorStyles } /> }
|
|
140
121
|
style={ {
|
|
141
|
-
height:
|
|
142
|
-
overflow: 'hidden',
|
|
122
|
+
height: normalizedHeight * ratio,
|
|
143
123
|
} }
|
|
124
|
+
onMouseEnter={ () => setIsHovered( true ) }
|
|
125
|
+
onMouseLeave={ () => setIsHovered( false ) }
|
|
126
|
+
tabIndex={ -1 }
|
|
144
127
|
>
|
|
145
|
-
<
|
|
146
|
-
spacing={ 10 * ratio }
|
|
147
|
-
justify="center"
|
|
128
|
+
<motion.div
|
|
148
129
|
style={ {
|
|
149
|
-
height:
|
|
150
|
-
|
|
130
|
+
height: normalizedHeight * ratio,
|
|
131
|
+
width: '100%',
|
|
132
|
+
background: gradientValue ?? backgroundColor,
|
|
133
|
+
cursor: 'pointer',
|
|
151
134
|
} }
|
|
135
|
+
initial="start"
|
|
136
|
+
animate={
|
|
137
|
+
( isHovered || isFocused ) &&
|
|
138
|
+
! disableMotion &&
|
|
139
|
+
label
|
|
140
|
+
? 'hover'
|
|
141
|
+
: 'start'
|
|
142
|
+
}
|
|
152
143
|
>
|
|
153
144
|
<motion.div
|
|
145
|
+
variants={ firstFrame }
|
|
154
146
|
style={ {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
color: headingColor,
|
|
158
|
-
fontWeight: headingFontWeight,
|
|
147
|
+
height: '100%',
|
|
148
|
+
overflow: 'hidden',
|
|
159
149
|
} }
|
|
160
|
-
animate={ { scale: 1, opacity: 1 } }
|
|
161
|
-
initial={ { scale: 0.1, opacity: 0 } }
|
|
162
|
-
transition={ { delay: 0.3, type: 'tween' } }
|
|
163
150
|
>
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
normalizedColorSwatchSize *
|
|
174
|
-
ratio,
|
|
175
|
-
width:
|
|
176
|
-
normalizedColorSwatchSize *
|
|
177
|
-
ratio,
|
|
178
|
-
background: color,
|
|
179
|
-
borderRadius:
|
|
180
|
-
( normalizedColorSwatchSize *
|
|
181
|
-
ratio ) /
|
|
182
|
-
2,
|
|
183
|
-
} }
|
|
184
|
-
animate={ { scale: 1, opacity: 1 } }
|
|
185
|
-
initial={ { scale: 0.1, opacity: 0 } }
|
|
186
|
-
transition={ {
|
|
187
|
-
delay: index === 1 ? 0.2 : 0.1,
|
|
188
|
-
} }
|
|
189
|
-
/>
|
|
190
|
-
)
|
|
191
|
-
) }
|
|
192
|
-
</VStack>
|
|
193
|
-
</HStack>
|
|
194
|
-
</motion.div>
|
|
195
|
-
<motion.div
|
|
196
|
-
variants={ withHoverView && midFrame }
|
|
197
|
-
style={ {
|
|
198
|
-
height: '100%',
|
|
199
|
-
width: '100%',
|
|
200
|
-
position: 'absolute',
|
|
201
|
-
top: 0,
|
|
202
|
-
overflow: 'hidden',
|
|
203
|
-
filter: 'blur(60px)',
|
|
204
|
-
opacity: 0.1,
|
|
205
|
-
} }
|
|
206
|
-
>
|
|
207
|
-
<HStack
|
|
208
|
-
spacing={ 0 }
|
|
209
|
-
justify="flex-start"
|
|
210
|
-
style={ {
|
|
211
|
-
height: '100%',
|
|
212
|
-
overflow: 'hidden',
|
|
213
|
-
} }
|
|
214
|
-
>
|
|
215
|
-
{ paletteColors
|
|
216
|
-
.slice( 0, 4 )
|
|
217
|
-
.map( ( { color }, index ) => (
|
|
218
|
-
<div
|
|
219
|
-
key={ index }
|
|
151
|
+
<HStack
|
|
152
|
+
spacing={ 10 * ratio }
|
|
153
|
+
justify="center"
|
|
154
|
+
style={ {
|
|
155
|
+
height: '100%',
|
|
156
|
+
overflow: 'hidden',
|
|
157
|
+
} }
|
|
158
|
+
>
|
|
159
|
+
<motion.div
|
|
220
160
|
style={ {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
161
|
+
fontFamily: headingFontFamily,
|
|
162
|
+
fontSize: 65 * ratio,
|
|
163
|
+
color: headingColor,
|
|
164
|
+
fontWeight: headingFontWeight,
|
|
224
165
|
} }
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
166
|
+
animate={ { scale: 1, opacity: 1 } }
|
|
167
|
+
initial={ { scale: 0.1, opacity: 0 } }
|
|
168
|
+
transition={ { delay: 0.3, type: 'tween' } }
|
|
169
|
+
>
|
|
170
|
+
Aa
|
|
171
|
+
</motion.div>
|
|
172
|
+
<VStack spacing={ 4 * ratio }>
|
|
173
|
+
{ highlightedColors.map(
|
|
174
|
+
( { slug, color }, index ) => (
|
|
175
|
+
<motion.div
|
|
176
|
+
key={ slug }
|
|
177
|
+
style={ {
|
|
178
|
+
height:
|
|
179
|
+
normalizedColorSwatchSize *
|
|
180
|
+
ratio,
|
|
181
|
+
width:
|
|
182
|
+
normalizedColorSwatchSize *
|
|
183
|
+
ratio,
|
|
184
|
+
background: color,
|
|
185
|
+
borderRadius:
|
|
186
|
+
( normalizedColorSwatchSize *
|
|
187
|
+
ratio ) /
|
|
188
|
+
2,
|
|
189
|
+
} }
|
|
190
|
+
animate={ {
|
|
191
|
+
scale: 1,
|
|
192
|
+
opacity: 1,
|
|
193
|
+
} }
|
|
194
|
+
initial={ {
|
|
195
|
+
scale: 0.1,
|
|
196
|
+
opacity: 0,
|
|
197
|
+
} }
|
|
198
|
+
transition={ {
|
|
199
|
+
delay:
|
|
200
|
+
index === 1 ? 0.2 : 0.1,
|
|
201
|
+
} }
|
|
202
|
+
/>
|
|
203
|
+
)
|
|
204
|
+
) }
|
|
205
|
+
</VStack>
|
|
206
|
+
</HStack>
|
|
207
|
+
</motion.div>
|
|
208
|
+
<motion.div
|
|
209
|
+
variants={ withHoverView && midFrame }
|
|
210
|
+
style={ {
|
|
211
|
+
height: '100%',
|
|
212
|
+
width: '100%',
|
|
213
|
+
position: 'absolute',
|
|
214
|
+
top: 0,
|
|
215
|
+
overflow: 'hidden',
|
|
216
|
+
filter: 'blur(60px)',
|
|
217
|
+
opacity: 0.1,
|
|
218
|
+
} }
|
|
219
|
+
>
|
|
220
|
+
<HStack
|
|
221
|
+
spacing={ 0 }
|
|
222
|
+
justify="flex-start"
|
|
251
223
|
style={ {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
color: headingColor,
|
|
255
|
-
fontWeight: headingFontWeight,
|
|
256
|
-
lineHeight: '1em',
|
|
257
|
-
textAlign: 'center',
|
|
224
|
+
height: '100%',
|
|
225
|
+
overflow: 'hidden',
|
|
258
226
|
} }
|
|
259
227
|
>
|
|
260
|
-
{
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
228
|
+
{ paletteColors
|
|
229
|
+
.slice( 0, 4 )
|
|
230
|
+
.map( ( { color }, index ) => (
|
|
231
|
+
<div
|
|
232
|
+
key={ index }
|
|
233
|
+
style={ {
|
|
234
|
+
height: '100%',
|
|
235
|
+
background: color,
|
|
236
|
+
flexGrow: 1,
|
|
237
|
+
} }
|
|
238
|
+
/>
|
|
239
|
+
) ) }
|
|
240
|
+
</HStack>
|
|
241
|
+
</motion.div>
|
|
242
|
+
<motion.div
|
|
243
|
+
variants={ secondFrame }
|
|
244
|
+
style={ {
|
|
245
|
+
height: '100%',
|
|
246
|
+
width: '100%',
|
|
247
|
+
overflow: 'hidden',
|
|
248
|
+
position: 'absolute',
|
|
249
|
+
top: 0,
|
|
250
|
+
} }
|
|
251
|
+
>
|
|
252
|
+
<VStack
|
|
253
|
+
spacing={ 3 * ratio }
|
|
254
|
+
justify="center"
|
|
255
|
+
style={ {
|
|
256
|
+
height: '100%',
|
|
257
|
+
overflow: 'hidden',
|
|
258
|
+
padding: 10 * ratio,
|
|
259
|
+
boxSizing: 'border-box',
|
|
260
|
+
} }
|
|
261
|
+
>
|
|
262
|
+
{ label && (
|
|
263
|
+
<div
|
|
264
|
+
style={ {
|
|
265
|
+
fontSize: 40 * ratio,
|
|
266
|
+
fontFamily: headingFontFamily,
|
|
267
|
+
color: headingColor,
|
|
268
|
+
fontWeight: headingFontWeight,
|
|
269
|
+
lineHeight: '1em',
|
|
270
|
+
textAlign: 'center',
|
|
271
|
+
} }
|
|
272
|
+
>
|
|
273
|
+
{ label }
|
|
274
|
+
</div>
|
|
275
|
+
) }
|
|
276
|
+
</VStack>
|
|
277
|
+
</motion.div>
|
|
278
|
+
</motion.div>
|
|
279
|
+
</Iframe>
|
|
280
|
+
) }
|
|
281
|
+
</>
|
|
267
282
|
);
|
|
268
283
|
};
|
|
269
284
|
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
*/
|
|
18
18
|
import ScreenHeader from './header';
|
|
19
19
|
import {
|
|
20
|
-
|
|
20
|
+
useSupportedStyles,
|
|
21
21
|
useColorsPerOrigin,
|
|
22
22
|
useGradientsPerOrigin,
|
|
23
23
|
} from './hooks';
|
|
@@ -27,7 +27,7 @@ const { useGlobalSetting, useGlobalStyle } = unlock( blockEditorPrivateApis );
|
|
|
27
27
|
|
|
28
28
|
function ScreenBackgroundColor( { name, variation = '' } ) {
|
|
29
29
|
const prefix = variation ? `variations.${ variation }.` : '';
|
|
30
|
-
const supports =
|
|
30
|
+
const supports = useSupportedStyles( name );
|
|
31
31
|
const [ areCustomSolidsEnabled ] = useGlobalSetting( 'color.custom', name );
|
|
32
32
|
const [ areCustomGradientsEnabled ] = useGlobalSetting(
|
|
33
33
|
'color.customGradient',
|
|
@@ -122,6 +122,7 @@ function ScreenBackgroundColor( { name, variation = '' } ) {
|
|
|
122
122
|
showTitle={ false }
|
|
123
123
|
enableAlpha
|
|
124
124
|
__experimentalIsRenderedInSidebar
|
|
125
|
+
headingLevel={ 3 }
|
|
125
126
|
{ ...controlProps }
|
|
126
127
|
/>
|
|
127
128
|
</>
|
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { useSelect } from '@wordpress/data';
|
|
12
12
|
import { useState, useMemo, useEffect, useRef } from '@wordpress/element';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
BlockIcon,
|
|
15
|
+
privateApis as blockEditorPrivateApis,
|
|
16
|
+
} from '@wordpress/block-editor';
|
|
14
17
|
import { useDebounce } from '@wordpress/compose';
|
|
15
18
|
import { speak } from '@wordpress/a11y';
|
|
16
19
|
|
|
@@ -19,11 +22,17 @@ import { speak } from '@wordpress/a11y';
|
|
|
19
22
|
*/
|
|
20
23
|
import { useHasBorderPanel } from './border-panel';
|
|
21
24
|
import { useHasColorPanel } from './color-utils';
|
|
22
|
-
import { useHasDimensionsPanel } from './dimensions-panel';
|
|
23
|
-
import { useHasTypographyPanel } from './typography-panel';
|
|
24
25
|
import { useHasVariationsPanel } from './variations-panel';
|
|
25
26
|
import ScreenHeader from './header';
|
|
26
27
|
import { NavigationButtonAsItem } from './navigation-button';
|
|
28
|
+
import { unlock } from '../../private-apis';
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
useHasDimensionsPanel,
|
|
32
|
+
useHasTypographyPanel,
|
|
33
|
+
useGlobalSetting,
|
|
34
|
+
useSettingsForBlockElement,
|
|
35
|
+
} = unlock( blockEditorPrivateApis );
|
|
27
36
|
|
|
28
37
|
function useSortedBlockTypes() {
|
|
29
38
|
const blockItems = useSelect(
|
|
@@ -49,10 +58,12 @@ function useSortedBlockTypes() {
|
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
function BlockMenuItem( { block } ) {
|
|
52
|
-
const
|
|
61
|
+
const [ rawSettings ] = useGlobalSetting( '', block.name );
|
|
62
|
+
const settings = useSettingsForBlockElement( rawSettings, block.name );
|
|
63
|
+
const hasTypographyPanel = useHasTypographyPanel( settings );
|
|
53
64
|
const hasColorPanel = useHasColorPanel( block.name );
|
|
54
65
|
const hasBorderPanel = useHasBorderPanel( block.name );
|
|
55
|
-
const hasDimensionsPanel = useHasDimensionsPanel(
|
|
66
|
+
const hasDimensionsPanel = useHasDimensionsPanel( settings );
|
|
56
67
|
const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
|
|
57
68
|
const hasVariationsPanel = useHasVariationsPanel( block.name );
|
|
58
69
|
const hasBlockMenuItem =
|