@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.
Files changed (217) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template.js +1 -20
  3. package/build/components/add-new-template/new-template.js.map +1 -1
  4. package/build/components/app/index.js.map +1 -1
  5. package/build/components/block-editor/editor-canvas.js +1 -0
  6. package/build/components/block-editor/editor-canvas.js.map +1 -1
  7. package/build/components/editor/index.js +3 -1
  8. package/build/components/editor/index.js.map +1 -1
  9. package/build/components/global-styles/border-panel.js +5 -5
  10. package/build/components/global-styles/border-panel.js.map +1 -1
  11. package/build/components/global-styles/color-palette-panel.js +5 -2
  12. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  13. package/build/components/global-styles/color-utils.js +1 -1
  14. package/build/components/global-styles/color-utils.js.map +1 -1
  15. package/build/components/global-styles/context-menu.js +22 -6
  16. package/build/components/global-styles/context-menu.js.map +1 -1
  17. package/build/components/global-styles/custom-css.js +1 -1
  18. package/build/components/global-styles/custom-css.js.map +1 -1
  19. package/build/components/global-styles/dimensions-panel.js +41 -486
  20. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  21. package/build/components/global-styles/duotone-panel.js +78 -0
  22. package/build/components/global-styles/duotone-panel.js.map +1 -0
  23. package/build/components/global-styles/filter-utils.js +17 -0
  24. package/build/components/global-styles/filter-utils.js.map +1 -0
  25. package/build/components/global-styles/gradients-palette-panel.js +8 -3
  26. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  27. package/build/components/global-styles/header.js +3 -1
  28. package/build/components/global-styles/header.js.map +1 -1
  29. package/build/components/global-styles/hooks.js +14 -51
  30. package/build/components/global-styles/hooks.js.map +1 -1
  31. package/build/components/global-styles/palette.js +3 -1
  32. package/build/components/global-styles/palette.js.map +1 -1
  33. package/build/components/global-styles/preview.js +9 -5
  34. package/build/components/global-styles/preview.js.map +1 -1
  35. package/build/components/global-styles/screen-background-color.js +3 -2
  36. package/build/components/global-styles/screen-background-color.js.map +1 -1
  37. package/build/components/global-styles/screen-block-list.js +13 -6
  38. package/build/components/global-styles/screen-block-list.js.map +1 -1
  39. package/build/components/global-styles/screen-button-color.js +7 -5
  40. package/build/components/global-styles/screen-button-color.js.map +1 -1
  41. package/build/components/global-styles/screen-colors.js +8 -6
  42. package/build/components/global-styles/screen-colors.js.map +1 -1
  43. package/build/components/global-styles/screen-filters.js +46 -0
  44. package/build/components/global-styles/screen-filters.js.map +1 -0
  45. package/build/components/global-styles/screen-heading-color.js +8 -6
  46. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  47. package/build/components/global-styles/screen-layout.js +13 -5
  48. package/build/components/global-styles/screen-layout.js.map +1 -1
  49. package/build/components/global-styles/screen-link-color.js +3 -2
  50. package/build/components/global-styles/screen-link-color.js.map +1 -1
  51. package/build/components/global-styles/screen-text-color.js +3 -2
  52. package/build/components/global-styles/screen-text-color.js.map +1 -1
  53. package/build/components/global-styles/screen-typography.js +3 -1
  54. package/build/components/global-styles/screen-typography.js.map +1 -1
  55. package/build/components/global-styles/shadow-panel.js +2 -3
  56. package/build/components/global-styles/shadow-panel.js.map +1 -1
  57. package/build/components/global-styles/subtitle.js +3 -2
  58. package/build/components/global-styles/subtitle.js.map +1 -1
  59. package/build/components/global-styles/typography-panel.js +23 -303
  60. package/build/components/global-styles/typography-panel.js.map +1 -1
  61. package/build/components/global-styles/ui.js +6 -0
  62. package/build/components/global-styles/ui.js.map +1 -1
  63. package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
  64. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  65. package/build/components/keyboard-shortcuts/index.js +67 -0
  66. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  67. package/build/components/navigation-inspector/index.js +0 -29
  68. package/build/components/navigation-inspector/index.js.map +1 -1
  69. package/build/components/navigation-inspector/navigation-menu.js +22 -5
  70. package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
  71. package/build/components/sidebar-edit-mode/index.js +1 -1
  72. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  73. package/build/components/sidebar-edit-mode/template-card/index.js +9 -2
  74. package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  75. package/build/components/sidebar-edit-mode/template-card/last-revision.js +84 -0
  76. package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
  77. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
  78. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  79. package/build/components/start-template-options/index.js +175 -0
  80. package/build/components/start-template-options/index.js.map +1 -0
  81. package/build/hooks/push-changes-to-global-styles/index.js +5 -4
  82. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  83. package/build/store/actions.js +2 -2
  84. package/build/store/actions.js.map +1 -1
  85. package/build-module/components/add-new-template/new-template.js +1 -18
  86. package/build-module/components/add-new-template/new-template.js.map +1 -1
  87. package/build-module/components/app/index.js.map +1 -1
  88. package/build-module/components/block-editor/editor-canvas.js +1 -0
  89. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  90. package/build-module/components/editor/index.js +2 -1
  91. package/build-module/components/editor/index.js.map +1 -1
  92. package/build-module/components/global-styles/border-panel.js +6 -6
  93. package/build-module/components/global-styles/border-panel.js.map +1 -1
  94. package/build-module/components/global-styles/color-palette-panel.js +5 -2
  95. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  96. package/build-module/components/global-styles/color-utils.js +2 -2
  97. package/build-module/components/global-styles/color-utils.js.map +1 -1
  98. package/build-module/components/global-styles/context-menu.js +20 -6
  99. package/build-module/components/global-styles/context-menu.js.map +1 -1
  100. package/build-module/components/global-styles/custom-css.js +1 -1
  101. package/build-module/components/global-styles/custom-css.js.map +1 -1
  102. package/build-module/components/global-styles/dimensions-panel.js +43 -479
  103. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  104. package/build-module/components/global-styles/duotone-panel.js +67 -0
  105. package/build-module/components/global-styles/duotone-panel.js.map +1 -0
  106. package/build-module/components/global-styles/filter-utils.js +9 -0
  107. package/build-module/components/global-styles/filter-utils.js.map +1 -0
  108. package/build-module/components/global-styles/gradients-palette-panel.js +8 -3
  109. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  110. package/build-module/components/global-styles/header.js +3 -1
  111. package/build-module/components/global-styles/header.js.map +1 -1
  112. package/build-module/components/global-styles/hooks.js +12 -49
  113. package/build-module/components/global-styles/hooks.js.map +1 -1
  114. package/build-module/components/global-styles/palette.js +3 -1
  115. package/build-module/components/global-styles/palette.js.map +1 -1
  116. package/build-module/components/global-styles/preview.js +10 -6
  117. package/build-module/components/global-styles/preview.js.map +1 -1
  118. package/build-module/components/global-styles/screen-background-color.js +4 -3
  119. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  120. package/build-module/components/global-styles/screen-block-list.js +12 -5
  121. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  122. package/build-module/components/global-styles/screen-button-color.js +8 -6
  123. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  124. package/build-module/components/global-styles/screen-colors.js +9 -7
  125. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  126. package/build-module/components/global-styles/screen-filters.js +33 -0
  127. package/build-module/components/global-styles/screen-filters.js.map +1 -0
  128. package/build-module/components/global-styles/screen-heading-color.js +9 -7
  129. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  130. package/build-module/components/global-styles/screen-layout.js +11 -2
  131. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  132. package/build-module/components/global-styles/screen-link-color.js +4 -3
  133. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  134. package/build-module/components/global-styles/screen-text-color.js +4 -3
  135. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  136. package/build-module/components/global-styles/screen-typography.js +3 -1
  137. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  138. package/build-module/components/global-styles/shadow-panel.js +3 -4
  139. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  140. package/build-module/components/global-styles/subtitle.js +3 -2
  141. package/build-module/components/global-styles/subtitle.js.map +1 -1
  142. package/build-module/components/global-styles/typography-panel.js +24 -300
  143. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  144. package/build-module/components/global-styles/ui.js +5 -0
  145. package/build-module/components/global-styles/ui.js.map +1 -1
  146. package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
  147. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  148. package/build-module/components/keyboard-shortcuts/index.js +65 -0
  149. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  150. package/build-module/components/navigation-inspector/index.js +0 -27
  151. package/build-module/components/navigation-inspector/index.js.map +1 -1
  152. package/build-module/components/navigation-inspector/navigation-menu.js +25 -8
  153. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
  154. package/build-module/components/sidebar-edit-mode/index.js +1 -1
  155. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  156. package/build-module/components/sidebar-edit-mode/template-card/index.js +9 -4
  157. package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  158. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js +70 -0
  159. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
  160. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
  161. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  162. package/build-module/components/start-template-options/index.js +156 -0
  163. package/build-module/components/start-template-options/index.js.map +1 -0
  164. package/build-module/hooks/push-changes-to-global-styles/index.js +6 -5
  165. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  166. package/build-module/store/actions.js +2 -2
  167. package/build-module/store/actions.js.map +1 -1
  168. package/build-style/style-rtl.css +73 -4
  169. package/build-style/style.css +73 -4
  170. package/package.json +31 -31
  171. package/src/components/add-new-template/new-template.js +1 -16
  172. package/src/components/app/index.js +0 -1
  173. package/src/components/block-editor/editor-canvas.js +1 -0
  174. package/src/components/editor/index.js +2 -0
  175. package/src/components/global-styles/border-panel.js +6 -6
  176. package/src/components/global-styles/color-palette-panel.js +3 -0
  177. package/src/components/global-styles/color-utils.js +2 -3
  178. package/src/components/global-styles/context-menu.js +25 -4
  179. package/src/components/global-styles/custom-css.js +1 -1
  180. package/src/components/global-styles/dimensions-panel.js +43 -573
  181. package/src/components/global-styles/duotone-panel.js +82 -0
  182. package/src/components/global-styles/filter-utils.js +9 -0
  183. package/src/components/global-styles/gradients-palette-panel.js +4 -1
  184. package/src/components/global-styles/header.js +7 -1
  185. package/src/components/global-styles/hooks.js +17 -90
  186. package/src/components/global-styles/palette.js +1 -1
  187. package/src/components/global-styles/preview.js +155 -140
  188. package/src/components/global-styles/screen-background-color.js +3 -2
  189. package/src/components/global-styles/screen-block-list.js +16 -5
  190. package/src/components/global-styles/screen-button-color.js +8 -6
  191. package/src/components/global-styles/screen-colors.js +7 -7
  192. package/src/components/global-styles/screen-filters.js +27 -0
  193. package/src/components/global-styles/screen-heading-color.js +9 -7
  194. package/src/components/global-styles/screen-layout.js +9 -2
  195. package/src/components/global-styles/screen-link-color.js +3 -2
  196. package/src/components/global-styles/screen-text-color.js +3 -2
  197. package/src/components/global-styles/screen-typography.js +1 -1
  198. package/src/components/global-styles/shadow-panel.js +6 -3
  199. package/src/components/global-styles/style.scss +5 -0
  200. package/src/components/global-styles/subtitle.js +5 -2
  201. package/src/components/global-styles/typography-panel.js +29 -395
  202. package/src/components/global-styles/ui.js +5 -0
  203. package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
  204. package/src/components/keyboard-shortcuts/index.js +70 -0
  205. package/src/components/navigation-inspector/index.js +0 -32
  206. package/src/components/navigation-inspector/navigation-menu.js +24 -6
  207. package/src/components/sidebar-edit-mode/index.js +1 -1
  208. package/src/components/sidebar-edit-mode/template-card/index.js +24 -14
  209. package/src/components/sidebar-edit-mode/template-card/last-revision.js +75 -0
  210. package/src/components/sidebar-edit-mode/template-card/style.scss +4 -0
  211. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +7 -1
  212. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +0 -4
  213. package/src/components/start-template-options/index.js +171 -0
  214. package/src/components/start-template-options/style.scss +76 -0
  215. package/src/hooks/push-changes-to-global-styles/index.js +26 -21
  216. package/src/store/actions.js +2 -2
  217. 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;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { useSupportedStyles } from './hooks';
5
+
6
+ export function useHasFilterPanel( name ) {
7
+ const supports = useSupportedStyles( name );
8
+ return supports.includes( 'filter' );
9
+ }
@@ -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 level={ 5 }>{ title }</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
+ }
@@ -65,7 +65,7 @@ function Palette( { name } ) {
65
65
 
66
66
  return (
67
67
  <VStack spacing={ 3 }>
68
- <Subtitle>{ __( 'Palette' ) }</Subtitle>
68
+ <Subtitle level={ 3 }>{ __( 'Palette' ) }</Subtitle>
69
69
  <ItemGroup isBordered isSeparated>
70
70
  <NavigationButtonAsItem
71
71
  path={ screenPath }
@@ -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
- <Iframe
113
- className="edit-site-global-styles-preview__iframe"
114
- head={ <EditorStyles styles={ editorStyles } /> }
115
- style={ {
116
- height: normalizedHeight * ratio,
117
- visibility: ! width ? 'hidden' : 'visible',
118
- } }
119
- onMouseEnter={ () => setIsHovered( true ) }
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: '100%',
142
- overflow: 'hidden',
122
+ height: normalizedHeight * ratio,
143
123
  } }
124
+ onMouseEnter={ () => setIsHovered( true ) }
125
+ onMouseLeave={ () => setIsHovered( false ) }
126
+ tabIndex={ -1 }
144
127
  >
145
- <HStack
146
- spacing={ 10 * ratio }
147
- justify="center"
128
+ <motion.div
148
129
  style={ {
149
- height: '100%',
150
- overflow: 'hidden',
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
- fontFamily: headingFontFamily,
156
- fontSize: 65 * ratio,
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
- Aa
165
- </motion.div>
166
- <VStack spacing={ 4 * ratio }>
167
- { highlightedColors.map(
168
- ( { slug, color }, index ) => (
169
- <motion.div
170
- key={ slug }
171
- style={ {
172
- height:
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
- height: '100%',
222
- background: color,
223
- flexGrow: 1,
161
+ fontFamily: headingFontFamily,
162
+ fontSize: 65 * ratio,
163
+ color: headingColor,
164
+ fontWeight: headingFontWeight,
224
165
  } }
225
- />
226
- ) ) }
227
- </HStack>
228
- </motion.div>
229
- <motion.div
230
- variants={ secondFrame }
231
- style={ {
232
- height: '100%',
233
- width: '100%',
234
- overflow: 'hidden',
235
- position: 'absolute',
236
- top: 0,
237
- } }
238
- >
239
- <VStack
240
- spacing={ 3 * ratio }
241
- justify="center"
242
- style={ {
243
- height: '100%',
244
- overflow: 'hidden',
245
- padding: 10 * ratio,
246
- boxSizing: 'border-box',
247
- } }
248
- >
249
- { label && (
250
- <div
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
- fontSize: 40 * ratio,
253
- fontFamily: headingFontFamily,
254
- color: headingColor,
255
- fontWeight: headingFontWeight,
256
- lineHeight: '1em',
257
- textAlign: 'center',
224
+ height: '100%',
225
+ overflow: 'hidden',
258
226
  } }
259
227
  >
260
- { label }
261
- </div>
262
- ) }
263
- </VStack>
264
- </motion.div>
265
- </motion.div>
266
- </Iframe>
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
- getSupportedGlobalStylesPanels,
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 = getSupportedGlobalStylesPanels( name );
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 { BlockIcon } from '@wordpress/block-editor';
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 hasTypographyPanel = useHasTypographyPanel( block.name );
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( block.name );
66
+ const hasDimensionsPanel = useHasDimensionsPanel( settings );
56
67
  const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
57
68
  const hasVariationsPanel = useHasVariationsPanel( block.name );
58
69
  const hasBlockMenuItem =