@wordpress/edit-site 4.6.0 → 4.9.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 (205) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +185 -0
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -0
  4. package/build/components/add-new-template/new-template.js +92 -32
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +139 -0
  7. package/build/components/add-new-template/utils.js.map +1 -0
  8. package/build/components/block-editor/block-inspector-button.js.map +1 -1
  9. package/build/components/block-editor/index.js.map +1 -1
  10. package/build/components/code-editor/code-editor-text-area.js +11 -9
  11. package/build/components/code-editor/code-editor-text-area.js.map +1 -1
  12. package/build/components/edit-template-part-menu-button/index.js.map +1 -1
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/global-styles/context-menu.js +6 -3
  15. package/build/components/global-styles/context-menu.js.map +1 -1
  16. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  17. package/build/components/global-styles/gradients-palette-panel.js +3 -7
  18. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  19. package/build/components/global-styles/hooks.js +1 -1
  20. package/build/components/global-styles/hooks.js.map +1 -1
  21. package/build/components/global-styles/palette.js +2 -1
  22. package/build/components/global-styles/palette.js.map +1 -1
  23. package/build/components/global-styles/preview.js +13 -2
  24. package/build/components/global-styles/preview.js.map +1 -1
  25. package/build/components/global-styles/screen-block-list.js +4 -1
  26. package/build/components/global-styles/screen-block-list.js.map +1 -1
  27. package/build/components/global-styles/screen-button-color.js +80 -0
  28. package/build/components/global-styles/screen-button-color.js.map +1 -0
  29. package/build/components/global-styles/screen-colors.js +47 -7
  30. package/build/components/global-styles/screen-colors.js.map +1 -1
  31. package/build/components/global-styles/screen-root.js +4 -2
  32. package/build/components/global-styles/screen-root.js.map +1 -1
  33. package/build/components/global-styles/screen-style-variations.js +9 -1
  34. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  35. package/build/components/global-styles/screen-typography-element.js +4 -0
  36. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  37. package/build/components/global-styles/screen-typography.js +9 -1
  38. package/build/components/global-styles/screen-typography.js.map +1 -1
  39. package/build/components/global-styles/ui.js +11 -0
  40. package/build/components/global-styles/ui.js.map +1 -1
  41. package/build/components/global-styles/use-global-styles-output.js +40 -9
  42. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  43. package/build/components/global-styles/utils.js +3 -1
  44. package/build/components/global-styles/utils.js.map +1 -1
  45. package/build/components/header/index.js +28 -10
  46. package/build/components/header/index.js.map +1 -1
  47. package/build/components/header/mode-switcher/index.js.map +1 -1
  48. package/build/components/header/more-menu/copy-content-menu-item.js +1 -1
  49. package/build/components/header/more-menu/copy-content-menu-item.js.map +1 -1
  50. package/build/components/header/more-menu/site-export.js +4 -1
  51. package/build/components/header/more-menu/site-export.js.map +1 -1
  52. package/build/components/header/undo-redo/redo.js +13 -4
  53. package/build/components/header/undo-redo/redo.js.map +1 -1
  54. package/build/components/header/undo-redo/undo.js +13 -4
  55. package/build/components/header/undo-redo/undo.js.map +1 -1
  56. package/build/components/keyboard-shortcut-help-modal/config.js +17 -0
  57. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  58. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  59. package/build/components/list/actions/index.js.map +1 -1
  60. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  61. package/build/components/list/added-by.js.map +1 -1
  62. package/build/components/navigation-sidebar/index.js.map +1 -1
  63. package/build/components/save-button/index.js.map +1 -1
  64. package/build/components/sidebar/index.js.map +1 -1
  65. package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
  66. package/build/components/sidebar/template-card/index.js +19 -7
  67. package/build/components/sidebar/template-card/index.js.map +1 -1
  68. package/build/components/sidebar/template-card/template-actions.js +64 -0
  69. package/build/components/sidebar/template-card/template-actions.js.map +1 -0
  70. package/build/components/sidebar/template-card/template-areas.js.map +1 -1
  71. package/build/components/template-details/template-areas.js.map +1 -1
  72. package/build/components/template-part-converter/index.js.map +1 -1
  73. package/build/components/url-query-controller/index.js.map +1 -1
  74. package/build/store/actions.js.map +1 -1
  75. package/build/store/selectors.js.map +1 -1
  76. package/build-module/components/add-new-template/add-custom-template-modal.js +170 -0
  77. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -0
  78. package/build-module/components/add-new-template/new-template.js +92 -35
  79. package/build-module/components/add-new-template/new-template.js.map +1 -1
  80. package/build-module/components/add-new-template/utils.js +119 -0
  81. package/build-module/components/add-new-template/utils.js.map +1 -0
  82. package/build-module/components/block-editor/block-inspector-button.js.map +1 -1
  83. package/build-module/components/block-editor/index.js.map +1 -1
  84. package/build-module/components/code-editor/code-editor-text-area.js +12 -10
  85. package/build-module/components/code-editor/code-editor-text-area.js.map +1 -1
  86. package/build-module/components/edit-template-part-menu-button/index.js.map +1 -1
  87. package/build-module/components/editor/index.js.map +1 -1
  88. package/build-module/components/global-styles/context-menu.js +6 -3
  89. package/build-module/components/global-styles/context-menu.js.map +1 -1
  90. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  91. package/build-module/components/global-styles/gradients-palette-panel.js +3 -5
  92. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  93. package/build-module/components/global-styles/hooks.js +1 -1
  94. package/build-module/components/global-styles/hooks.js.map +1 -1
  95. package/build-module/components/global-styles/palette.js +2 -1
  96. package/build-module/components/global-styles/palette.js.map +1 -1
  97. package/build-module/components/global-styles/preview.js +14 -3
  98. package/build-module/components/global-styles/preview.js.map +1 -1
  99. package/build-module/components/global-styles/screen-block-list.js +4 -1
  100. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  101. package/build-module/components/global-styles/screen-button-color.js +67 -0
  102. package/build-module/components/global-styles/screen-button-color.js.map +1 -0
  103. package/build-module/components/global-styles/screen-colors.js +48 -8
  104. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  105. package/build-module/components/global-styles/screen-root.js +4 -2
  106. package/build-module/components/global-styles/screen-root.js.map +1 -1
  107. package/build-module/components/global-styles/screen-style-variations.js +9 -1
  108. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  109. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  110. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  111. package/build-module/components/global-styles/screen-typography.js +10 -2
  112. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  113. package/build-module/components/global-styles/ui.js +10 -0
  114. package/build-module/components/global-styles/ui.js.map +1 -1
  115. package/build-module/components/global-styles/use-global-styles-output.js +39 -9
  116. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  117. package/build-module/components/global-styles/utils.js +3 -1
  118. package/build-module/components/global-styles/utils.js.map +1 -1
  119. package/build-module/components/header/index.js +29 -11
  120. package/build-module/components/header/index.js.map +1 -1
  121. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  122. package/build-module/components/header/more-menu/copy-content-menu-item.js +1 -1
  123. package/build-module/components/header/more-menu/copy-content-menu-item.js.map +1 -1
  124. package/build-module/components/header/more-menu/site-export.js +4 -1
  125. package/build-module/components/header/more-menu/site-export.js.map +1 -1
  126. package/build-module/components/header/undo-redo/redo.js +9 -3
  127. package/build-module/components/header/undo-redo/redo.js.map +1 -1
  128. package/build-module/components/header/undo-redo/undo.js +9 -3
  129. package/build-module/components/header/undo-redo/undo.js.map +1 -1
  130. package/build-module/components/keyboard-shortcut-help-modal/config.js +17 -0
  131. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  132. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  133. package/build-module/components/list/actions/index.js.map +1 -1
  134. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  135. package/build-module/components/list/added-by.js.map +1 -1
  136. package/build-module/components/navigation-sidebar/index.js.map +1 -1
  137. package/build-module/components/save-button/index.js.map +1 -1
  138. package/build-module/components/sidebar/index.js.map +1 -1
  139. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -1
  140. package/build-module/components/sidebar/template-card/index.js +18 -7
  141. package/build-module/components/sidebar/template-card/index.js.map +1 -1
  142. package/build-module/components/sidebar/template-card/template-actions.js +49 -0
  143. package/build-module/components/sidebar/template-card/template-actions.js.map +1 -0
  144. package/build-module/components/sidebar/template-card/template-areas.js.map +1 -1
  145. package/build-module/components/template-details/template-areas.js.map +1 -1
  146. package/build-module/components/template-part-converter/index.js.map +1 -1
  147. package/build-module/components/url-query-controller/index.js.map +1 -1
  148. package/build-module/store/actions.js.map +1 -1
  149. package/build-module/store/selectors.js.map +1 -1
  150. package/build-style/style-rtl.css +170 -23
  151. package/build-style/style.css +170 -23
  152. package/package.json +30 -30
  153. package/src/components/add-new-template/add-custom-template-modal.js +231 -0
  154. package/src/components/add-new-template/new-template.js +135 -59
  155. package/src/components/add-new-template/style.scss +116 -0
  156. package/src/components/add-new-template/utils.js +125 -0
  157. package/src/components/block-editor/block-inspector-button.js +2 -3
  158. package/src/components/block-editor/index.js +4 -9
  159. package/src/components/code-editor/code-editor-text-area.js +12 -7
  160. package/src/components/edit-template-part-menu-button/index.js +2 -3
  161. package/src/components/editor/index.js +4 -5
  162. package/src/components/global-styles/context-menu.js +3 -0
  163. package/src/components/global-styles/global-styles-provider.js +4 -8
  164. package/src/components/global-styles/gradients-palette-panel.js +2 -5
  165. package/src/components/global-styles/hooks.js +5 -3
  166. package/src/components/global-styles/palette.js +4 -1
  167. package/src/components/global-styles/preview.js +17 -2
  168. package/src/components/global-styles/screen-block-list.js +14 -5
  169. package/src/components/global-styles/screen-button-color.js +102 -0
  170. package/src/components/global-styles/screen-colors.js +49 -4
  171. package/src/components/global-styles/screen-root.js +12 -5
  172. package/src/components/global-styles/screen-style-variations.js +10 -4
  173. package/src/components/global-styles/screen-typography-element.js +4 -0
  174. package/src/components/global-styles/screen-typography.js +17 -2
  175. package/src/components/global-styles/style.scss +10 -0
  176. package/src/components/global-styles/test/use-global-styles-output.js +82 -16
  177. package/src/components/global-styles/ui.js +13 -0
  178. package/src/components/global-styles/use-global-styles-output.js +43 -4
  179. package/src/components/global-styles/utils.js +3 -0
  180. package/src/components/header/index.js +38 -13
  181. package/src/components/header/mode-switcher/index.js +4 -4
  182. package/src/components/header/more-menu/copy-content-menu-item.js +3 -4
  183. package/src/components/header/more-menu/site-export.js +5 -3
  184. package/src/components/header/style.scss +53 -5
  185. package/src/components/header/undo-redo/redo.js +6 -1
  186. package/src/components/header/undo-redo/undo.js +6 -1
  187. package/src/components/keyboard-shortcut-help-modal/config.js +12 -0
  188. package/src/components/keyboard-shortcuts/index.js +6 -10
  189. package/src/components/list/actions/index.js +2 -3
  190. package/src/components/list/actions/rename-menu-item.js +4 -6
  191. package/src/components/list/added-by.js +4 -3
  192. package/src/components/navigation-sidebar/index.js +2 -4
  193. package/src/components/save-button/index.js +2 -4
  194. package/src/components/sidebar/index.js +6 -6
  195. package/src/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +6 -9
  196. package/src/components/sidebar/navigation-menu-sidebar/style.scss +0 -1
  197. package/src/components/sidebar/template-card/index.js +17 -9
  198. package/src/components/sidebar/template-card/style.scss +49 -35
  199. package/src/components/sidebar/template-card/template-actions.js +43 -0
  200. package/src/components/sidebar/template-card/template-areas.js +6 -6
  201. package/src/components/template-details/template-areas.js +6 -6
  202. package/src/components/template-part-converter/index.js +2 -3
  203. package/src/components/url-query-controller/index.js +2 -3
  204. package/src/store/actions.js +257 -233
  205. package/src/store/selectors.js +9 -10
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { noop } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -20,6 +15,8 @@ import { __ } from '@wordpress/i18n';
20
15
  import { useSetting } from './hooks';
21
16
  import Subtitle from './subtitle';
22
17
 
18
+ const noop = () => {};
19
+
23
20
  export default function GradientPalettePanel( { name } ) {
24
21
  const [ themeGradients, setThemeGradients ] = useSetting(
25
22
  'color.gradients.theme',
@@ -27,9 +27,10 @@ export const useGlobalStylesReset = () => {
27
27
  const canReset = !! config && ! isEqual( config, EMPTY_CONFIG );
28
28
  return [
29
29
  canReset,
30
- useCallback( () => setUserConfig( () => EMPTY_CONFIG ), [
31
- setUserConfig,
32
- ] ),
30
+ useCallback(
31
+ () => setUserConfig( () => EMPTY_CONFIG ),
32
+ [ setUserConfig ]
33
+ ),
33
34
  ];
34
35
  };
35
36
 
@@ -158,6 +159,7 @@ const ROOT_BLOCK_SUPPORTS = [
158
159
  'backgroundColor',
159
160
  'color',
160
161
  'linkColor',
162
+ 'buttonColor',
161
163
  'fontFamily',
162
164
  'fontSize',
163
165
  'fontStyle',
@@ -58,7 +58,10 @@ function Palette( { name } ) {
58
58
  <VStack spacing={ 3 }>
59
59
  <Subtitle>{ __( 'Palette' ) }</Subtitle>
60
60
  <ItemGroup isBordered isSeparated>
61
- <NavigationButtonAsItem path={ screenPath }>
61
+ <NavigationButtonAsItem
62
+ path={ screenPath }
63
+ aria-label={ __( 'Color palettes' ) }
64
+ >
62
65
  <HStack
63
66
  direction={
64
67
  colors.length === 0 ? 'row-reverse' : 'row'
@@ -11,7 +11,7 @@ import {
11
11
  __experimentalVStack as VStack,
12
12
  } from '@wordpress/components';
13
13
  import { useReducedMotion, useResizeObserver } from '@wordpress/compose';
14
- import { useState } from '@wordpress/element';
14
+ import { useState, useMemo } from '@wordpress/element';
15
15
 
16
16
  /**
17
17
  * Internal dependencies
@@ -79,10 +79,25 @@ const StylesPreview = ( { label, isFocused } ) => {
79
79
  )
80
80
  .slice( 0, 2 );
81
81
 
82
+ // Reset leaked styles from WP common.css.
83
+ const editorStyles = useMemo( () => {
84
+ if ( styles ) {
85
+ return [
86
+ ...styles,
87
+ {
88
+ css: 'body{min-width: 0;}',
89
+ isGlobalStyles: true,
90
+ },
91
+ ];
92
+ }
93
+
94
+ return styles;
95
+ }, [ styles ] );
96
+
82
97
  return (
83
98
  <Iframe
84
99
  className="edit-site-global-styles-preview__iframe"
85
- head={ <EditorStyles styles={ styles } /> }
100
+ head={ <EditorStyles styles={ editorStyles } /> }
86
101
  style={ {
87
102
  height: normalizedHeight * ratio,
88
103
  visibility: ! width ? 'hidden' : 'visible',
@@ -40,10 +40,10 @@ function useSortedBlockTypes() {
40
40
  type.push( block );
41
41
  return blocks;
42
42
  };
43
- const {
44
- core: coreItems,
45
- noncore: nonCoreItems,
46
- } = blockItems.reduce( groupByType, { core: [], noncore: [] } );
43
+ const { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(
44
+ groupByType,
45
+ { core: [], noncore: [] }
46
+ );
47
47
  return [ ...coreItems, ...nonCoreItems ];
48
48
  }
49
49
 
@@ -60,8 +60,17 @@ function BlockMenuItem( { block } ) {
60
60
  return null;
61
61
  }
62
62
 
63
+ const navigationButtonLabel = sprintf(
64
+ // translators: %s: is the name of a block e.g., 'Image' or 'Table'.
65
+ __( '%s block styles' ),
66
+ block.title
67
+ );
68
+
63
69
  return (
64
- <NavigationButtonAsItem path={ '/blocks/' + block.name }>
70
+ <NavigationButtonAsItem
71
+ path={ '/blocks/' + block.name }
72
+ aria-label={ navigationButtonLabel }
73
+ >
65
74
  <HStack justify="flex-start">
66
75
  <BlockIcon icon={ block.icon } />
67
76
  <FlexItem>{ block.title }</FlexItem>
@@ -0,0 +1,102 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { __experimentalColorGradientControl as ColorGradientControl } from '@wordpress/block-editor';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import ScreenHeader from './header';
11
+ import {
12
+ getSupportedGlobalStylesPanels,
13
+ useSetting,
14
+ useStyle,
15
+ useColorsPerOrigin,
16
+ } from './hooks';
17
+
18
+ function ScreenButtonColor( { name } ) {
19
+ const supports = getSupportedGlobalStylesPanels( name );
20
+ const [ solids ] = useSetting( 'color.palette', name );
21
+ const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );
22
+
23
+ const colorsPerOrigin = useColorsPerOrigin( name );
24
+
25
+ const [ isBackgroundEnabled ] = useSetting( 'color.background', name );
26
+
27
+ const hasButtonColor =
28
+ supports.includes( 'buttonColor' ) &&
29
+ isBackgroundEnabled &&
30
+ ( solids.length > 0 || areCustomSolidsEnabled );
31
+
32
+ const [ buttonTextColor, setButtonTextColor ] = useStyle(
33
+ 'elements.button.color.text',
34
+ name
35
+ );
36
+ const [ userButtonTextColor ] = useStyle(
37
+ 'elements.button.color.text',
38
+ name,
39
+ 'user'
40
+ );
41
+
42
+ const [ buttonBgColor, setButtonBgColor ] = useStyle(
43
+ 'elements.button.color.background',
44
+ name
45
+ );
46
+ const [ userButtonBgColor ] = useStyle(
47
+ 'elements.button.color.background',
48
+ name,
49
+ 'user'
50
+ );
51
+
52
+ if ( ! hasButtonColor ) {
53
+ return null;
54
+ }
55
+
56
+ return (
57
+ <>
58
+ <ScreenHeader
59
+ title={ __( 'Buttons' ) }
60
+ description={ __(
61
+ 'Set the default colors used for buttons across the site.'
62
+ ) }
63
+ />
64
+
65
+ <h4 className="edit-site-global-styles-section-title">
66
+ { __( 'Text color' ) }
67
+ </h4>
68
+
69
+ <ColorGradientControl
70
+ className="edit-site-screen-button-color__control"
71
+ colors={ colorsPerOrigin }
72
+ disableCustomColors={ ! areCustomSolidsEnabled }
73
+ __experimentalHasMultipleOrigins
74
+ showTitle={ false }
75
+ enableAlpha
76
+ __experimentalIsRenderedInSidebar
77
+ colorValue={ buttonTextColor }
78
+ onColorChange={ setButtonTextColor }
79
+ clearable={ buttonTextColor === userButtonTextColor }
80
+ />
81
+
82
+ <h4 className="edit-site-global-styles-section-title">
83
+ { __( 'Background color' ) }
84
+ </h4>
85
+
86
+ <ColorGradientControl
87
+ className="edit-site-screen-button-color__control"
88
+ colors={ colorsPerOrigin }
89
+ disableCustomColors={ ! areCustomSolidsEnabled }
90
+ __experimentalHasMultipleOrigins
91
+ showTitle={ false }
92
+ enableAlpha
93
+ __experimentalIsRenderedInSidebar
94
+ colorValue={ buttonBgColor }
95
+ onColorChange={ setButtonBgColor }
96
+ clearable={ buttonBgColor === userButtonBgColor }
97
+ />
98
+ </>
99
+ );
100
+ }
101
+
102
+ export default ScreenButtonColor;
@@ -6,6 +6,7 @@ import {
6
6
  __experimentalItemGroup as ItemGroup,
7
7
  __experimentalHStack as HStack,
8
8
  __experimentalVStack as VStack,
9
+ __experimentalZStack as ZStack,
9
10
  FlexItem,
10
11
  ColorIndicator,
11
12
  } from '@wordpress/components';
@@ -33,11 +34,15 @@ function BackgroundColorItem( { name, parentMenu } ) {
33
34
  }
34
35
 
35
36
  return (
36
- <NavigationButtonAsItem path={ parentMenu + '/colors/background' }>
37
+ <NavigationButtonAsItem
38
+ path={ parentMenu + '/colors/background' }
39
+ aria-label={ __( 'Colors background styles' ) }
40
+ >
37
41
  <HStack justify="flex-start">
38
42
  <ColorIndicatorWrapper expanded={ false }>
39
43
  <ColorIndicator
40
44
  colorValue={ gradientValue ?? backgroundColor }
45
+ data-testid="background-color-indicator"
41
46
  />
42
47
  </ColorIndicatorWrapper>
43
48
  <FlexItem>{ __( 'Background' ) }</FlexItem>
@@ -56,10 +61,16 @@ function TextColorItem( { name, parentMenu } ) {
56
61
  }
57
62
 
58
63
  return (
59
- <NavigationButtonAsItem path={ parentMenu + '/colors/text' }>
64
+ <NavigationButtonAsItem
65
+ path={ parentMenu + '/colors/text' }
66
+ aria-label={ __( 'Colors text styles' ) }
67
+ >
60
68
  <HStack justify="flex-start">
61
69
  <ColorIndicatorWrapper expanded={ false }>
62
- <ColorIndicator colorValue={ color } />
70
+ <ColorIndicator
71
+ colorValue={ color }
72
+ data-testid="text-color-indicator"
73
+ />
63
74
  </ColorIndicatorWrapper>
64
75
  <FlexItem>{ __( 'Text' ) }</FlexItem>
65
76
  </HStack>
@@ -77,7 +88,10 @@ function LinkColorItem( { name, parentMenu } ) {
77
88
  }
78
89
 
79
90
  return (
80
- <NavigationButtonAsItem path={ parentMenu + '/colors/link' }>
91
+ <NavigationButtonAsItem
92
+ path={ parentMenu + '/colors/link' }
93
+ aria-label={ __( 'Colors link styles' ) }
94
+ >
81
95
  <HStack justify="flex-start">
82
96
  <ColorIndicatorWrapper expanded={ false }>
83
97
  <ColorIndicator colorValue={ color } />
@@ -88,6 +102,33 @@ function LinkColorItem( { name, parentMenu } ) {
88
102
  );
89
103
  }
90
104
 
105
+ function ButtonColorItem( { name, parentMenu } ) {
106
+ const supports = getSupportedGlobalStylesPanels( name );
107
+ const hasSupport = supports.includes( 'buttonColor' );
108
+ const [ color ] = useStyle( 'elements.button.color.text', name );
109
+ const [ bgColor ] = useStyle( 'elements.button.color.background', name );
110
+
111
+ if ( ! hasSupport ) {
112
+ return null;
113
+ }
114
+
115
+ return (
116
+ <NavigationButtonAsItem path={ parentMenu + '/colors/button' }>
117
+ <HStack justify="flex-start">
118
+ <ZStack isLayered={ false } offset={ -8 }>
119
+ <ColorIndicatorWrapper expanded={ false }>
120
+ <ColorIndicator colorValue={ bgColor } />
121
+ </ColorIndicatorWrapper>
122
+ <ColorIndicatorWrapper expanded={ false }>
123
+ <ColorIndicator colorValue={ color } />
124
+ </ColorIndicatorWrapper>
125
+ </ZStack>
126
+ <FlexItem>{ __( 'Buttons' ) }</FlexItem>
127
+ </HStack>
128
+ </NavigationButtonAsItem>
129
+ );
130
+ }
131
+
91
132
  function ScreenColors( { name } ) {
92
133
  const parentMenu = name === undefined ? '' : '/blocks/' + name;
93
134
 
@@ -119,6 +160,10 @@ function ScreenColors( { name } ) {
119
160
  name={ name }
120
161
  parentMenu={ parentMenu }
121
162
  />
163
+ <ButtonColorItem
164
+ name={ name }
165
+ parentMenu={ parentMenu }
166
+ />
122
167
  </ItemGroup>
123
168
  </VStack>
124
169
  </VStack>
@@ -28,9 +28,10 @@ import StylesPreview from './preview';
28
28
  function ScreenRoot() {
29
29
  const { variations } = useSelect( ( select ) => {
30
30
  return {
31
- variations: select(
32
- coreStore
33
- ).__experimentalGetCurrentThemeGlobalStylesVariations(),
31
+ variations:
32
+ select(
33
+ coreStore
34
+ ).__experimentalGetCurrentThemeGlobalStylesVariations(),
34
35
  };
35
36
  }, [] );
36
37
 
@@ -45,7 +46,10 @@ function ScreenRoot() {
45
46
  </Card>
46
47
  { !! variations?.length && (
47
48
  <ItemGroup>
48
- <NavigationButtonAsItem path="/variations">
49
+ <NavigationButtonAsItem
50
+ path="/variations"
51
+ aria-label={ __( 'Browse styles' ) }
52
+ >
49
53
  <HStack justify="space-between">
50
54
  <FlexItem>
51
55
  { __( 'Browse styles' ) }
@@ -81,7 +85,10 @@ function ScreenRoot() {
81
85
  ) }
82
86
  </Spacer>
83
87
  <ItemGroup>
84
- <NavigationButtonAsItem path="/blocks">
88
+ <NavigationButtonAsItem
89
+ path="/blocks"
90
+ aria-label={ __( 'Blocks styles' ) }
91
+ >
85
92
  <HStack justify="space-between">
86
93
  <FlexItem>{ __( 'Blocks' ) }</FlexItem>
87
94
  <IconWithCurrentColor
@@ -79,6 +79,7 @@ function Variation( { variation } ) {
79
79
  onKeyDown={ selectOnEnter }
80
80
  tabIndex="0"
81
81
  aria-label={ variation?.title }
82
+ aria-current={ isActive }
82
83
  onFocus={ () => setIsFocused( true ) }
83
84
  onBlur={ () => setIsFocused( false ) }
84
85
  >
@@ -96,9 +97,10 @@ function Variation( { variation } ) {
96
97
  function ScreenStyleVariations() {
97
98
  const { variations } = useSelect( ( select ) => {
98
99
  return {
99
- variations: select(
100
- coreStore
101
- ).__experimentalGetCurrentThemeGlobalStylesVariations(),
100
+ variations:
101
+ select(
102
+ coreStore
103
+ ).__experimentalGetCurrentThemeGlobalStylesVariations(),
102
104
  };
103
105
  }, [] );
104
106
 
@@ -109,7 +111,11 @@ function ScreenStyleVariations() {
109
111
  settings: {},
110
112
  styles: {},
111
113
  },
112
- ...variations,
114
+ ...variations.map( ( variation ) => ( {
115
+ ...variation,
116
+ settings: variation.settings ?? {},
117
+ styles: variation.styles ?? {},
118
+ } ) ),
113
119
  ];
114
120
  }, [ variations ] );
115
121
 
@@ -18,6 +18,10 @@ const elements = {
18
18
  description: __( 'Manage the fonts and typography used on the links.' ),
19
19
  title: __( 'Links' ),
20
20
  },
21
+ button: {
22
+ description: __( 'Manage the fonts and typography used on buttons.' ),
23
+ title: __( 'Buttons' ),
24
+ },
21
25
  };
22
26
 
23
27
  function ScreenTypographyElement( { name, element } ) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __ } from '@wordpress/i18n';
4
+ import { __, sprintf } from '@wordpress/i18n';
5
5
  import {
6
6
  __experimentalItemGroup as ItemGroup,
7
7
  __experimentalVStack as VStack,
@@ -43,8 +43,17 @@ function Item( { name, parentMenu, element, label } ) {
43
43
  return null;
44
44
  }
45
45
 
46
+ const navigationButtonLabel = sprintf(
47
+ // translators: %s: is a subset of Typography, e.g., 'text' or 'links'.
48
+ __( 'Typography %s styles' ),
49
+ label
50
+ );
51
+
46
52
  return (
47
- <NavigationButtonAsItem path={ parentMenu + '/typography/' + element }>
53
+ <NavigationButtonAsItem
54
+ path={ parentMenu + '/typography/' + element }
55
+ aria-label={ navigationButtonLabel }
56
+ >
48
57
  <HStack justify="flex-start">
49
58
  <FlexItem
50
59
  className="edit-site-global-styles-screen-typography__indicator"
@@ -95,6 +104,12 @@ function ScreenTypography( { name } ) {
95
104
  element="link"
96
105
  label={ __( 'Links' ) }
97
106
  />
107
+ <Item
108
+ name={ name }
109
+ parentMenu={ parentMenu }
110
+ element="button"
111
+ label={ __( 'Buttons' ) }
112
+ />
98
113
  </ItemGroup>
99
114
  </VStack>
100
115
  </div>
@@ -57,6 +57,15 @@
57
57
  font-size: 11px !important;
58
58
  }
59
59
 
60
+ .edit-site-global-styles-section-title {
61
+ color: $gray-800;
62
+ font-weight: 600;
63
+ line-height: 1.2;
64
+ padding: $grid-unit-20;
65
+ padding-bottom: 0;
66
+ margin: 0;
67
+ }
68
+
60
69
  .edit-site-screen-color-palette-toggle.edit-site-screen-color-palette-toggle {
61
70
  margin-right: $grid-unit-20;
62
71
  margin-left: $grid-unit-20;
@@ -68,6 +77,7 @@
68
77
 
69
78
  .edit-site-screen-text-color__control,
70
79
  .edit-site-screen-link-color__control,
80
+ .edit-site-screen-button-color__control,
71
81
  .edit-site-screen-background-color__control {
72
82
  padding: $grid-unit-20;
73
83
  }
@@ -40,6 +40,20 @@ describe( 'global styles renderer', () => {
40
40
  fontSize: '23px',
41
41
  },
42
42
  },
43
+ link: {
44
+ ':hover': {
45
+ color: {
46
+ background: 'green',
47
+ text: 'yellow',
48
+ },
49
+ },
50
+ ':focus': {
51
+ color: {
52
+ background: 'green',
53
+ text: 'yellow',
54
+ },
55
+ },
56
+ },
43
57
  },
44
58
  },
45
59
  },
@@ -49,6 +63,18 @@ describe( 'global styles renderer', () => {
49
63
  background: 'yellow',
50
64
  text: 'yellow',
51
65
  },
66
+ ':hover': {
67
+ color: {
68
+ background: 'hotpink',
69
+ text: 'black',
70
+ },
71
+ },
72
+ ':focus': {
73
+ color: {
74
+ background: 'hotpink',
75
+ text: 'black',
76
+ },
77
+ },
52
78
  },
53
79
  },
54
80
  },
@@ -58,6 +84,7 @@ describe( 'global styles renderer', () => {
58
84
  selector: '.my-heading1, .my-heading2',
59
85
  },
60
86
  };
87
+
61
88
  expect( getNodesWithStyles( tree, blockSelectors ) ).toEqual( [
62
89
  {
63
90
  styles: {
@@ -74,6 +101,18 @@ describe( 'global styles renderer', () => {
74
101
  background: 'yellow',
75
102
  text: 'yellow',
76
103
  },
104
+ ':hover': {
105
+ color: {
106
+ background: 'hotpink',
107
+ text: 'black',
108
+ },
109
+ },
110
+ ':focus': {
111
+ color: {
112
+ background: 'hotpink',
113
+ text: 'black',
114
+ },
115
+ },
77
116
  },
78
117
  selector: ELEMENTS.link,
79
118
  },
@@ -102,6 +141,23 @@ describe( 'global styles renderer', () => {
102
141
  },
103
142
  selector: '.my-heading1 h2, .my-heading2 h2',
104
143
  },
144
+ {
145
+ styles: {
146
+ ':hover': {
147
+ color: {
148
+ background: 'green',
149
+ text: 'yellow',
150
+ },
151
+ },
152
+ ':focus': {
153
+ color: {
154
+ background: 'green',
155
+ text: 'yellow',
156
+ },
157
+ },
158
+ },
159
+ selector: '.my-heading1 a, .my-heading2 a',
160
+ },
105
161
  ] );
106
162
  } );
107
163
  } );
@@ -318,6 +374,21 @@ describe( 'global styles renderer', () => {
318
374
  fontSize: '42px',
319
375
  },
320
376
  },
377
+ link: {
378
+ color: {
379
+ text: 'blue',
380
+ },
381
+ ':hover': {
382
+ color: {
383
+ text: 'orange',
384
+ },
385
+ },
386
+ ':focus': {
387
+ color: {
388
+ text: 'orange',
389
+ },
390
+ },
391
+ },
321
392
  },
322
393
  blocks: {
323
394
  'core/group': {
@@ -345,6 +416,16 @@ describe( 'global styles renderer', () => {
345
416
  color: {
346
417
  text: 'hotpink',
347
418
  },
419
+ ':hover': {
420
+ color: {
421
+ text: 'red',
422
+ },
423
+ },
424
+ ':focus': {
425
+ color: {
426
+ text: 'red',
427
+ },
428
+ },
348
429
  },
349
430
  },
350
431
  },
@@ -358,27 +439,12 @@ describe( 'global styles renderer', () => {
358
439
  },
359
440
  'core/heading': {
360
441
  selector: 'h1,h2,h3,h4,h5,h6',
361
- elements: {
362
- link:
363
- 'h1 ' +
364
- ELEMENTS.link +
365
- ',h2 ' +
366
- ELEMENTS.link +
367
- ',h3 ' +
368
- ELEMENTS.link +
369
- ',h4 ' +
370
- ELEMENTS.link +
371
- ',h5 ' +
372
- ELEMENTS.link +
373
- ',h6 ' +
374
- ELEMENTS.link,
375
- },
376
442
  },
377
443
  };
378
444
 
379
445
  expect( toStyles( tree, blockSelectors ) ).toEqual(
380
446
  'body {margin: 0;}' +
381
- 'body{background-color: red;margin: 10px;padding: 10px;}h1{font-size: 42px;}.wp-block-group{margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}h1,h2,h3,h4,h5,h6{color: orange;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: hotpink;}' +
447
+ 'body{background-color: red;margin: 10px;padding: 10px;}h1{font-size: 42px;}a{color: blue;}a:hover{color: orange;}a:focus{color: orange;}.wp-block-group{margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}h1,h2,h3,h4,h5,h6{color: orange;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: hotpink;}h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover{color: red;}h1 a:focus,h2 a:focus,h3 a:focus,h4 a:focus,h5 a:focus,h6 a:focus{color: red;}' +
382
448
  '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }' +
383
449
  '.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}'
384
450
  );
@@ -20,6 +20,7 @@ import ScreenColorPalette from './screen-color-palette';
20
20
  import ScreenBackgroundColor from './screen-background-color';
21
21
  import ScreenTextColor from './screen-text-color';
22
22
  import ScreenLinkColor from './screen-link-color';
23
+ import ScreenButtonColor from './screen-button-color';
23
24
  import ScreenLayout from './screen-layout';
24
25
  import ScreenStyleVariations from './screen-style-variations';
25
26
 
@@ -58,6 +59,12 @@ function ContextScreens( { name } ) {
58
59
  <ScreenTypographyElement name={ name } element="link" />
59
60
  </GlobalStylesNavigationScreen>
60
61
 
62
+ <GlobalStylesNavigationScreen
63
+ path={ parentMenu + '/typography/button' }
64
+ >
65
+ <ScreenTypographyElement name={ name } element="button" />
66
+ </GlobalStylesNavigationScreen>
67
+
61
68
  <GlobalStylesNavigationScreen path={ parentMenu + '/colors' }>
62
69
  <ScreenColors name={ name } />
63
70
  </GlobalStylesNavigationScreen>
@@ -82,6 +89,12 @@ function ContextScreens( { name } ) {
82
89
  <ScreenLinkColor name={ name } />
83
90
  </GlobalStylesNavigationScreen>
84
91
 
92
+ <GlobalStylesNavigationScreen
93
+ path={ parentMenu + '/colors/button' }
94
+ >
95
+ <ScreenButtonColor name={ name } />
96
+ </GlobalStylesNavigationScreen>
97
+
85
98
  <GlobalStylesNavigationScreen path={ parentMenu + '/layout' }>
86
99
  <ScreenLayout name={ name } />
87
100
  </GlobalStylesNavigationScreen>