@wordpress/edit-site 5.7.0 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/editor/index.js +6 -4
  3. package/build/components/editor/index.js.map +1 -1
  4. package/build/components/global-styles/border-panel.js +35 -1
  5. package/build/components/global-styles/border-panel.js.map +1 -1
  6. package/build/components/global-styles/context-menu.js +6 -8
  7. package/build/components/global-styles/context-menu.js.map +1 -1
  8. package/build/components/global-styles/dimensions-panel.js +11 -1
  9. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  10. package/build/components/global-styles/effects-panel.js +53 -0
  11. package/build/components/global-styles/effects-panel.js.map +1 -0
  12. package/build/components/global-styles/filters-panel.js +45 -0
  13. package/build/components/global-styles/filters-panel.js.map +1 -0
  14. package/build/components/global-styles/global-styles-provider.js +7 -4
  15. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  16. package/build/components/global-styles/preview.js +1 -1
  17. package/build/components/global-styles/preview.js.map +1 -1
  18. package/build/components/global-styles/screen-block-list.js +14 -8
  19. package/build/components/global-styles/screen-block-list.js.map +1 -1
  20. package/build/components/global-styles/screen-css.js +1 -1
  21. package/build/components/global-styles/screen-css.js.map +1 -1
  22. package/build/components/global-styles/screen-effects.js +15 -7
  23. package/build/components/global-styles/screen-effects.js.map +1 -1
  24. package/build/components/global-styles/screen-filters.js +2 -2
  25. package/build/components/global-styles/screen-filters.js.map +1 -1
  26. package/build/components/global-styles/screen-style-variations.js +8 -118
  27. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  28. package/build/components/global-styles/style-variations-container.js +149 -0
  29. package/build/components/global-styles/style-variations-container.js.map +1 -0
  30. package/build/components/global-styles/ui.js +46 -2
  31. package/build/components/global-styles/ui.js.map +1 -1
  32. package/build/components/header-edit-mode/more-menu/index.js +1 -1
  33. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  34. package/build/components/keyboard-shortcuts/index.js +0 -137
  35. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  36. package/build/components/layout/index.js +8 -1
  37. package/build/components/layout/index.js.map +1 -1
  38. package/build/components/preferences-modal/index.js +4 -0
  39. package/build/components/preferences-modal/index.js.map +1 -1
  40. package/build/components/sidebar/index.js +4 -0
  41. package/build/components/sidebar/index.js.map +1 -1
  42. package/build/components/sidebar-navigation-screen/index.js +8 -6
  43. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  44. package/build/components/sidebar-navigation-screen-global-styles/index.js +58 -0
  45. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
  46. package/build/components/sidebar-navigation-screen-main/index.js +5 -0
  47. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  48. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +114 -9
  49. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  50. package/build/components/site-hub/index.js +4 -3
  51. package/build/components/site-hub/index.js.map +1 -1
  52. package/build/components/welcome-guide/styles.js +1 -1
  53. package/build/components/welcome-guide/styles.js.map +1 -1
  54. package/build/hooks/commands/index.js +19 -0
  55. package/build/hooks/commands/index.js.map +1 -0
  56. package/build/hooks/commands/use-navigation-commands.js +117 -0
  57. package/build/hooks/commands/use-navigation-commands.js.map +1 -0
  58. package/build/hooks/commands/use-wp-admin-commands.js +94 -0
  59. package/build/hooks/commands/use-wp-admin-commands.js.map +1 -0
  60. package/build/hooks/template-part-edit.js +2 -1
  61. package/build/hooks/template-part-edit.js.map +1 -1
  62. package/build/index.js +2 -1
  63. package/build/index.js.map +1 -1
  64. package/build/store/selectors.js +2 -1
  65. package/build/store/selectors.js.map +1 -1
  66. package/build-module/components/editor/index.js +6 -4
  67. package/build-module/components/editor/index.js.map +1 -1
  68. package/build-module/components/global-styles/border-panel.js +34 -1
  69. package/build-module/components/global-styles/border-panel.js.map +1 -1
  70. package/build-module/components/global-styles/context-menu.js +6 -6
  71. package/build-module/components/global-styles/context-menu.js.map +1 -1
  72. package/build-module/components/global-styles/dimensions-panel.js +11 -1
  73. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  74. package/build-module/components/global-styles/effects-panel.js +43 -0
  75. package/build-module/components/global-styles/effects-panel.js.map +1 -0
  76. package/build-module/components/global-styles/filters-panel.js +35 -0
  77. package/build-module/components/global-styles/filters-panel.js.map +1 -0
  78. package/build-module/components/global-styles/global-styles-provider.js +8 -5
  79. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  80. package/build-module/components/global-styles/preview.js +1 -1
  81. package/build-module/components/global-styles/preview.js.map +1 -1
  82. package/build-module/components/global-styles/screen-block-list.js +13 -8
  83. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  84. package/build-module/components/global-styles/screen-css.js +1 -1
  85. package/build-module/components/global-styles/screen-css.js.map +1 -1
  86. package/build-module/components/global-styles/screen-effects.js +13 -4
  87. package/build-module/components/global-styles/screen-effects.js.map +1 -1
  88. package/build-module/components/global-styles/screen-filters.js +2 -2
  89. package/build-module/components/global-styles/screen-filters.js.map +1 -1
  90. package/build-module/components/global-styles/screen-style-variations.js +11 -114
  91. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  92. package/build-module/components/global-styles/style-variations-container.js +130 -0
  93. package/build-module/components/global-styles/style-variations-container.js.map +1 -0
  94. package/build-module/components/global-styles/ui.js +44 -3
  95. package/build-module/components/global-styles/ui.js.map +1 -1
  96. package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
  97. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  98. package/build-module/components/keyboard-shortcuts/index.js +1 -135
  99. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  100. package/build-module/components/layout/index.js +6 -1
  101. package/build-module/components/layout/index.js.map +1 -1
  102. package/build-module/components/preferences-modal/index.js +4 -0
  103. package/build-module/components/preferences-modal/index.js.map +1 -1
  104. package/build-module/components/sidebar/index.js +3 -0
  105. package/build-module/components/sidebar/index.js.map +1 -1
  106. package/build-module/components/sidebar-navigation-screen/index.js +9 -7
  107. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  108. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +41 -0
  109. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
  110. package/build-module/components/sidebar-navigation-screen-main/index.js +6 -1
  111. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  112. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +113 -11
  113. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  114. package/build-module/components/site-hub/index.js +3 -3
  115. package/build-module/components/site-hub/index.js.map +1 -1
  116. package/build-module/components/welcome-guide/styles.js +1 -1
  117. package/build-module/components/welcome-guide/styles.js.map +1 -1
  118. package/build-module/hooks/commands/index.js +10 -0
  119. package/build-module/hooks/commands/index.js.map +1 -0
  120. package/build-module/hooks/commands/use-navigation-commands.js +101 -0
  121. package/build-module/hooks/commands/use-navigation-commands.js.map +1 -0
  122. package/build-module/hooks/commands/use-wp-admin-commands.js +79 -0
  123. package/build-module/hooks/commands/use-wp-admin-commands.js.map +1 -0
  124. package/build-module/hooks/template-part-edit.js +2 -1
  125. package/build-module/hooks/template-part-edit.js.map +1 -1
  126. package/build-module/index.js +2 -1
  127. package/build-module/index.js.map +1 -1
  128. package/build-module/store/selectors.js +2 -1
  129. package/build-module/store/selectors.js.map +1 -1
  130. package/build-style/style-rtl.css +20 -46
  131. package/build-style/style.css +20 -46
  132. package/package.json +33 -31
  133. package/src/components/editor/index.js +11 -3
  134. package/src/components/global-styles/border-panel.js +32 -1
  135. package/src/components/global-styles/context-menu.js +6 -6
  136. package/src/components/global-styles/dimensions-panel.js +11 -0
  137. package/src/components/global-styles/effects-panel.js +40 -0
  138. package/src/components/global-styles/filters-panel.js +33 -0
  139. package/src/components/global-styles/global-styles-provider.js +4 -4
  140. package/src/components/global-styles/preview.js +1 -1
  141. package/src/components/global-styles/screen-block-list.js +9 -5
  142. package/src/components/global-styles/screen-css.js +1 -1
  143. package/src/components/global-styles/screen-effects.js +12 -5
  144. package/src/components/global-styles/screen-filters.js +2 -2
  145. package/src/components/global-styles/screen-style-variations.js +10 -129
  146. package/src/components/global-styles/style-variations-container.js +136 -0
  147. package/src/components/global-styles/style.scss +0 -39
  148. package/src/components/global-styles/ui.js +44 -2
  149. package/src/components/header-edit-mode/more-menu/index.js +1 -1
  150. package/src/components/keyboard-shortcuts/index.js +1 -155
  151. package/src/components/layout/index.js +4 -0
  152. package/src/components/preferences-modal/index.js +7 -0
  153. package/src/components/sidebar/index.js +4 -0
  154. package/src/components/sidebar-navigation-screen/index.js +10 -5
  155. package/src/components/sidebar-navigation-screen/style.scss +20 -5
  156. package/src/components/sidebar-navigation-screen-global-styles/index.js +41 -0
  157. package/src/components/sidebar-navigation-screen-main/index.js +9 -1
  158. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +134 -9
  159. package/src/components/site-hub/index.js +3 -3
  160. package/src/components/start-template-options/style.scss +7 -14
  161. package/src/components/welcome-guide/styles.js +1 -1
  162. package/src/hooks/commands/index.js +10 -0
  163. package/src/hooks/commands/use-navigation-commands.js +103 -0
  164. package/src/hooks/commands/use-wp-admin-commands.js +77 -0
  165. package/src/hooks/template-part-edit.js +1 -0
  166. package/src/index.js +1 -0
  167. package/src/store/selectors.js +2 -1
  168. package/build/components/global-styles/duotone-panel.js +0 -78
  169. package/build/components/global-styles/duotone-panel.js.map +0 -1
  170. package/build/components/global-styles/filter-utils.js +0 -17
  171. package/build/components/global-styles/filter-utils.js.map +0 -1
  172. package/build/components/global-styles/shadow-panel.js +0 -197
  173. package/build/components/global-styles/shadow-panel.js.map +0 -1
  174. package/build-module/components/global-styles/duotone-panel.js +0 -67
  175. package/build-module/components/global-styles/duotone-panel.js.map +0 -1
  176. package/build-module/components/global-styles/filter-utils.js +0 -9
  177. package/build-module/components/global-styles/filter-utils.js.map +0 -1
  178. package/build-module/components/global-styles/shadow-panel.js +0 -178
  179. package/build-module/components/global-styles/shadow-panel.js.map +0 -1
  180. package/src/components/global-styles/duotone-panel.js +0 -82
  181. package/src/components/global-styles/filter-utils.js +0 -9
  182. package/src/components/global-styles/shadow-panel.js +0 -178
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
5
+ import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/components';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -29,11 +30,41 @@ export default function BorderPanel( { name, variation = '' } ) {
29
30
  const [ rawSettings ] = useGlobalSetting( '', name );
30
31
  const settings = useSettingsForBlockElement( rawSettings, name );
31
32
 
33
+ const onChange = ( newStyle ) => {
34
+ // As Global Styles can't conditionally generate styles based on if
35
+ // other style properties have been set, we need to force split
36
+ // border definitions for user set global border styles. Border
37
+ // radius is derived from the same property i.e. `border.radius` if
38
+ // it is a string that is used. The longhand border radii styles are
39
+ // only generated if that property is an object.
40
+ //
41
+ // For borders (color, style, and width) those are all properties on
42
+ // the `border` style property. This means if the theme.json defined
43
+ // split borders and the user condenses them into a flat border or
44
+ // vice-versa we'd get both sets of styles which would conflict.
45
+ const { border } = newStyle;
46
+ const updatedBorder = ! hasSplitBorders( border )
47
+ ? {
48
+ top: border,
49
+ right: border,
50
+ bottom: border,
51
+ left: border,
52
+ }
53
+ : {
54
+ color: null,
55
+ style: null,
56
+ width: null,
57
+ ...border,
58
+ };
59
+
60
+ setStyle( { ...newStyle, border: updatedBorder } );
61
+ };
62
+
32
63
  return (
33
64
  <StylesBorderPanel
34
65
  inheritedValue={ inheritedStyle }
35
66
  value={ style }
36
- onChange={ setStyle }
67
+ onChange={ onChange }
37
68
  settings={ settings }
38
69
  />
39
70
  );
@@ -27,12 +27,10 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
27
27
  /**
28
28
  * Internal dependencies
29
29
  */
30
- import { useHasFilterPanel } from './filter-utils';
31
30
  import { useHasVariationsPanel } from './variations-panel';
32
31
  import { NavigationButtonAsItem } from './navigation-button';
33
32
  import { IconWithCurrentColor } from './icon-with-current-color';
34
33
  import { ScreenVariations } from './screen-variations';
35
- import { useHasShadowControl } from './shadow-panel';
36
34
  import { unlock } from '../../private-apis';
37
35
 
38
36
  const {
@@ -40,6 +38,8 @@ const {
40
38
  useHasTypographyPanel,
41
39
  useHasBorderPanel,
42
40
  useHasColorPanel,
41
+ useHasEffectsPanel,
42
+ useHasFiltersPanel,
43
43
  useGlobalSetting,
44
44
  useSettingsForBlockElement,
45
45
  } = unlock( blockEditorPrivateApis );
@@ -50,8 +50,8 @@ function ContextMenu( { name, parentMenu = '' } ) {
50
50
  const hasTypographyPanel = useHasTypographyPanel( settings );
51
51
  const hasColorPanel = useHasColorPanel( settings );
52
52
  const hasBorderPanel = useHasBorderPanel( settings );
53
- const hasEffectsPanel = useHasShadowControl( name );
54
- const hasFilterPanel = useHasFilterPanel( name );
53
+ const hasEffectsPanel = useHasEffectsPanel( settings );
54
+ const hasFilterPanel = useHasFiltersPanel( settings );
55
55
  const hasDimensionsPanel = useHasDimensionsPanel( settings );
56
56
  const hasLayoutPanel = hasDimensionsPanel;
57
57
  const hasVariationsPanel = useHasVariationsPanel( name, parentMenu );
@@ -109,9 +109,9 @@ function ContextMenu( { name, parentMenu = '' } ) {
109
109
  <NavigationButtonAsItem
110
110
  icon={ shadow }
111
111
  path={ parentMenu + '/effects' }
112
- aria-label={ __( 'Shadow' ) }
112
+ aria-label={ __( 'Effects' ) }
113
113
  >
114
- { __( 'Shadow' ) }
114
+ { __( 'Effects' ) }
115
115
  </NavigationButtonAsItem>
116
116
  ) }
117
117
  { hasFilterPanel && (
@@ -16,6 +16,16 @@ const {
16
16
  DimensionsPanel: StylesDimensionsPanel,
17
17
  } = unlock( blockEditorPrivateApis );
18
18
 
19
+ const DEFAULT_CONTROLS = {
20
+ contentSize: true,
21
+ wideSize: true,
22
+ padding: true,
23
+ margin: true,
24
+ blockGap: true,
25
+ minHeight: true,
26
+ childLayout: false,
27
+ };
28
+
19
29
  export default function DimensionsPanel( { name, variation = '' } ) {
20
30
  let prefixParts = [];
21
31
  if ( variation ) {
@@ -66,6 +76,7 @@ export default function DimensionsPanel( { name, variation = '' } ) {
66
76
  onChange={ onChange }
67
77
  settings={ settings }
68
78
  includeLayoutControls
79
+ defaultControls={ DEFAULT_CONTROLS }
69
80
  />
70
81
  );
71
82
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { unlock } from '../../private-apis';
10
+
11
+ const {
12
+ useGlobalSetting,
13
+ useGlobalStyle,
14
+ EffectsPanel: StylesEffectsPanel,
15
+ useSettingsForBlockElement,
16
+ } = unlock( blockEditorPrivateApis );
17
+
18
+ export default function EffectsPanel( { name, variation = '' } ) {
19
+ let prefixParts = [];
20
+ if ( variation ) {
21
+ prefixParts = [ 'variations', variation ].concat( prefixParts );
22
+ }
23
+ const prefix = prefixParts.join( '.' );
24
+
25
+ const [ style ] = useGlobalStyle( prefix, name, 'user', false );
26
+ const [ inheritedStyle, setStyle ] = useGlobalStyle( prefix, name, 'all', {
27
+ shouldDecodeEncode: false,
28
+ } );
29
+ const [ rawSettings ] = useGlobalSetting( '', name );
30
+ const settings = useSettingsForBlockElement( rawSettings, name );
31
+
32
+ return (
33
+ <StylesEffectsPanel
34
+ inheritedValue={ inheritedStyle }
35
+ value={ style }
36
+ onChange={ setStyle }
37
+ settings={ settings }
38
+ />
39
+ );
40
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { unlock } from '../../private-apis';
10
+ const {
11
+ useGlobalStyle,
12
+ useGlobalSetting,
13
+ useSettingsForBlockElement,
14
+ FiltersPanel: StylesFiltersPanel,
15
+ } = unlock( blockEditorPrivateApis );
16
+
17
+ export default function FiltersPanel( { name } ) {
18
+ const [ style ] = useGlobalStyle( '', name, 'user', false );
19
+ const [ inheritedStyle, setStyle ] = useGlobalStyle( '', name, 'all', {
20
+ shouldDecodeEncode: false,
21
+ } );
22
+ const [ rawSettings ] = useGlobalSetting( '', name );
23
+ const settings = useSettingsForBlockElement( rawSettings, name );
24
+
25
+ return (
26
+ <StylesFiltersPanel
27
+ inheritedValue={ inheritedStyle }
28
+ value={ style }
29
+ onChange={ setStyle }
30
+ settings={ settings }
31
+ />
32
+ );
33
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { mergeWith, isEmpty, mapValues } from 'lodash';
4
+ import { mergeWith, isEmpty } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -41,9 +41,9 @@ const cleanEmptyObject = ( object ) => {
41
41
  return object;
42
42
  }
43
43
  const cleanedNestedObjects = Object.fromEntries(
44
- Object.entries( mapValues( object, cleanEmptyObject ) ).filter(
45
- ( [ , value ] ) => Boolean( value )
46
- )
44
+ Object.entries( object )
45
+ .map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )
46
+ .filter( ( [ , value ] ) => Boolean( value ) )
47
47
  );
48
48
  return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
49
49
  };
@@ -130,7 +130,7 @@ const StylesPreview = ( { label, isFocused, withHoverView } ) => {
130
130
  height: normalizedHeight * ratio,
131
131
  width: '100%',
132
132
  background: gradientValue ?? backgroundColor,
133
- cursor: 'pointer',
133
+ cursor: withHoverView ? 'pointer' : undefined,
134
134
  } }
135
135
  initial="start"
136
136
  animate={
@@ -57,21 +57,25 @@ function useSortedBlockTypes() {
57
57
  return [ ...coreItems, ...nonCoreItems ];
58
58
  }
59
59
 
60
- function BlockMenuItem( { block } ) {
61
- const [ rawSettings ] = useGlobalSetting( '', block.name );
62
- const settings = useSettingsForBlockElement( rawSettings, block.name );
60
+ export function useBlockHasGlobalStyles( blockName ) {
61
+ const [ rawSettings ] = useGlobalSetting( '', blockName );
62
+ const settings = useSettingsForBlockElement( rawSettings, blockName );
63
63
  const hasTypographyPanel = useHasTypographyPanel( settings );
64
64
  const hasColorPanel = useHasColorPanel( settings );
65
65
  const hasBorderPanel = useHasBorderPanel( settings );
66
66
  const hasDimensionsPanel = useHasDimensionsPanel( settings );
67
67
  const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
68
- const hasVariationsPanel = useHasVariationsPanel( block.name );
69
- const hasBlockMenuItem =
68
+ const hasVariationsPanel = useHasVariationsPanel( blockName );
69
+ const hasGlobalStyles =
70
70
  hasTypographyPanel ||
71
71
  hasColorPanel ||
72
72
  hasLayoutPanel ||
73
73
  hasVariationsPanel;
74
+ return hasGlobalStyles;
75
+ }
74
76
 
77
+ function BlockMenuItem( { block } ) {
78
+ const hasBlockMenuItem = useBlockHasGlobalStyles( block.name );
75
79
  if ( ! hasBlockMenuItem ) {
76
80
  return null;
77
81
  }
@@ -38,7 +38,7 @@ function ScreenCSS( { name } ) {
38
38
  <>
39
39
  { description }
40
40
  <ExternalLink
41
- href="https://wordpress.org/support/article/css/"
41
+ href="https://wordpress.org/documentation/article/css/"
42
42
  className="edit-site-global-styles-screen-css-help-link"
43
43
  >
44
44
  { __( 'Learn more about CSS' ) }
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
5
6
 
6
7
  /**
7
8
  * Internal dependencies
@@ -9,17 +10,23 @@ import { __ } from '@wordpress/i18n';
9
10
  import ScreenHeader from './header';
10
11
  import BlockPreviewPanel from './block-preview-panel';
11
12
  import { getVariationClassName } from './utils';
12
- import ShadowPanel, { useHasShadowControl } from './shadow-panel';
13
+ import { unlock } from '../../private-apis';
14
+ import EffectsPanel from './effects-panel';
15
+
16
+ const { useGlobalSetting, useSettingsForBlockElement, useHasEffectsPanel } =
17
+ unlock( blockEditorPrivateApis );
13
18
 
14
19
  function ScreenEffects( { name, variation = '' } ) {
20
+ const [ rawSettings ] = useGlobalSetting( '', name );
21
+ const settings = useSettingsForBlockElement( rawSettings, name );
15
22
  const variationClassName = getVariationClassName( variation );
16
- const hasShadowPanel = useHasShadowControl( name );
23
+ const hasEffectsPanel = useHasEffectsPanel( settings );
17
24
  return (
18
25
  <>
19
- <ScreenHeader title={ __( 'Shadow' ) } />
26
+ <ScreenHeader title={ __( 'Effects' ) } />
20
27
  <BlockPreviewPanel name={ name } variation={ variationClassName } />
21
- { hasShadowPanel && (
22
- <ShadowPanel name={ name } variation={ variation } />
28
+ { hasEffectsPanel && (
29
+ <EffectsPanel name={ name } variation={ variation } />
23
30
  ) }
24
31
  </>
25
32
  );
@@ -6,7 +6,7 @@ import { __ } from '@wordpress/i18n';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import DuotonePanel from './duotone-panel';
9
+ import FiltersPanel from './filters-panel';
10
10
  import BlockPreviewPanel from './block-preview-panel';
11
11
 
12
12
  /**
@@ -19,7 +19,7 @@ function ScreenFilters( { name } ) {
19
19
  <>
20
20
  <ScreenHeader title={ __( 'Filters' ) } />
21
21
  <BlockPreviewPanel name={ name } />
22
- <DuotonePanel name={ name } />
22
+ <FiltersPanel name={ name } />
23
23
  </>
24
24
  );
25
25
  }
@@ -1,143 +1,25 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
- import fastDeepEqual from 'fast-deep-equal/es6';
6
-
7
1
  /**
8
2
  * WordPress dependencies
9
3
  */
10
- import { store as coreStore } from '@wordpress/core-data';
11
- import { useSelect, useDispatch } from '@wordpress/data';
12
- import {
13
- useMemo,
14
- useContext,
15
- useState,
16
- useEffect,
17
- useRef,
18
- } from '@wordpress/element';
19
- import { ENTER } from '@wordpress/keycodes';
20
- import {
21
- __experimentalGrid as Grid,
22
- Card,
23
- CardBody,
24
- } from '@wordpress/components';
4
+ import { Card, CardBody } from '@wordpress/components';
25
5
  import { __ } from '@wordpress/i18n';
26
- import {
27
- store as blockEditorStore,
28
- privateApis as blockEditorPrivateApis,
29
- } from '@wordpress/block-editor';
6
+ import { store as blockEditorStore } from '@wordpress/block-editor';
7
+ import { useEffect, useRef } from '@wordpress/element';
8
+ import { useSelect, useDispatch } from '@wordpress/data';
30
9
 
31
10
  /**
32
11
  * Internal dependencies
33
12
  */
34
- import { mergeBaseAndUserConfigs } from './global-styles-provider';
35
- import StylesPreview from './preview';
36
13
  import ScreenHeader from './header';
37
- import { unlock } from '../../private-apis';
38
-
39
- const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
40
-
41
- function compareVariations( a, b ) {
42
- return (
43
- fastDeepEqual( a.styles, b.styles ) &&
44
- fastDeepEqual( a.settings, b.settings )
45
- );
46
- }
47
-
48
- function Variation( { variation } ) {
49
- const [ isFocused, setIsFocused ] = useState( false );
50
- const { base, user, setUserConfig } = useContext( GlobalStylesContext );
51
- const context = useMemo( () => {
52
- return {
53
- user: {
54
- settings: variation.settings ?? {},
55
- styles: variation.styles ?? {},
56
- },
57
- base,
58
- merged: mergeBaseAndUserConfigs( base, variation ),
59
- setUserConfig: () => {},
60
- };
61
- }, [ variation, base ] );
62
-
63
- const selectVariation = () => {
64
- setUserConfig( () => {
65
- return {
66
- settings: variation.settings,
67
- styles: variation.styles,
68
- };
69
- } );
70
- };
71
-
72
- const selectOnEnter = ( event ) => {
73
- if ( event.keyCode === ENTER ) {
74
- event.preventDefault();
75
- selectVariation();
76
- }
77
- };
78
-
79
- const isActive = useMemo( () => {
80
- return compareVariations( user, variation );
81
- }, [ user, variation ] );
82
-
83
- return (
84
- <GlobalStylesContext.Provider value={ context }>
85
- <div
86
- className={ classnames(
87
- 'edit-site-global-styles-variations_item',
88
- {
89
- 'is-active': isActive,
90
- }
91
- ) }
92
- role="button"
93
- onClick={ selectVariation }
94
- onKeyDown={ selectOnEnter }
95
- tabIndex="0"
96
- aria-label={ variation?.title }
97
- aria-current={ isActive }
98
- onFocus={ () => setIsFocused( true ) }
99
- onBlur={ () => setIsFocused( false ) }
100
- >
101
- <div className="edit-site-global-styles-variations_item-preview">
102
- <StylesPreview
103
- label={ variation?.title }
104
- isFocused={ isFocused }
105
- withHoverView
106
- />
107
- </div>
108
- </div>
109
- </GlobalStylesContext.Provider>
110
- );
111
- }
14
+ import StyleVariationsContainer from './style-variations-container';
112
15
 
113
16
  function ScreenStyleVariations() {
114
- const { variations, mode } = useSelect( ( select ) => {
17
+ const { mode } = useSelect( ( select ) => {
115
18
  return {
116
- variations:
117
- select(
118
- coreStore
119
- ).__experimentalGetCurrentThemeGlobalStylesVariations(),
120
-
121
19
  mode: select( blockEditorStore ).__unstableGetEditorMode(),
122
20
  };
123
21
  }, [] );
124
22
 
125
- const withEmptyVariation = useMemo( () => {
126
- return [
127
- {
128
- title: __( 'Default' ),
129
- settings: {},
130
- styles: {},
131
- },
132
- ...variations.map( ( variation ) => ( {
133
- ...variation,
134
- settings: variation.settings ?? {},
135
- styles: variation.styles ?? {},
136
- } ) ),
137
- ];
138
- }, [ variations ] );
139
-
140
- const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
141
23
  const shouldRevertInitialMode = useRef( null );
142
24
  useEffect( () => {
143
25
  // ignore changes to zoom-out mode as we explictily change to it on mount.
@@ -160,8 +42,11 @@ function ScreenStyleVariations() {
160
42
  }
161
43
  };
162
44
  }
45
+ // eslint-disable-next-line react-hooks/exhaustive-deps
163
46
  }, [] );
164
47
 
48
+ const { __unstableSetEditorMode } = useDispatch( blockEditorStore );
49
+
165
50
  return (
166
51
  <>
167
52
  <ScreenHeader
@@ -178,11 +63,7 @@ function ScreenStyleVariations() {
178
63
  className="edit-site-global-styles-screen-style-variations"
179
64
  >
180
65
  <CardBody>
181
- <Grid columns={ 2 }>
182
- { withEmptyVariation?.map( ( variation, index ) => (
183
- <Variation key={ index } variation={ variation } />
184
- ) ) }
185
- </Grid>
66
+ <StyleVariationsContainer />
186
67
  </CardBody>
187
68
  </Card>
188
69
  </>
@@ -0,0 +1,136 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+ import fastDeepEqual from 'fast-deep-equal/es6';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { store as coreStore } from '@wordpress/core-data';
11
+ import { useSelect } from '@wordpress/data';
12
+ import { useMemo, useContext, useState } from '@wordpress/element';
13
+ import { ENTER } from '@wordpress/keycodes';
14
+ import { __experimentalGrid as Grid } from '@wordpress/components';
15
+ import { __ } from '@wordpress/i18n';
16
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import { mergeBaseAndUserConfigs } from './global-styles-provider';
22
+ import StylesPreview from './preview';
23
+ import { unlock } from '../../private-apis';
24
+
25
+ const { GlobalStylesContext } = unlock( blockEditorPrivateApis );
26
+
27
+ function compareVariations( a, b ) {
28
+ return (
29
+ fastDeepEqual( a.styles, b.styles ) &&
30
+ fastDeepEqual( a.settings, b.settings )
31
+ );
32
+ }
33
+
34
+ function Variation( { variation } ) {
35
+ const [ isFocused, setIsFocused ] = useState( false );
36
+ const { base, user, setUserConfig } = useContext( GlobalStylesContext );
37
+ const context = useMemo( () => {
38
+ return {
39
+ user: {
40
+ settings: variation.settings ?? {},
41
+ styles: variation.styles ?? {},
42
+ },
43
+ base,
44
+ merged: mergeBaseAndUserConfigs( base, variation ),
45
+ setUserConfig: () => {},
46
+ };
47
+ }, [ variation, base ] );
48
+
49
+ const selectVariation = () => {
50
+ setUserConfig( () => {
51
+ return {
52
+ settings: variation.settings,
53
+ styles: variation.styles,
54
+ };
55
+ } );
56
+ };
57
+
58
+ const selectOnEnter = ( event ) => {
59
+ if ( event.keyCode === ENTER ) {
60
+ event.preventDefault();
61
+ selectVariation();
62
+ }
63
+ };
64
+
65
+ const isActive = useMemo( () => {
66
+ return compareVariations( user, variation );
67
+ }, [ user, variation ] );
68
+
69
+ return (
70
+ <GlobalStylesContext.Provider value={ context }>
71
+ <div
72
+ className={ classnames(
73
+ 'edit-site-global-styles-variations_item',
74
+ {
75
+ 'is-active': isActive,
76
+ }
77
+ ) }
78
+ role="button"
79
+ onClick={ selectVariation }
80
+ onKeyDown={ selectOnEnter }
81
+ tabIndex="0"
82
+ aria-label={ variation?.title }
83
+ aria-current={ isActive }
84
+ onFocus={ () => setIsFocused( true ) }
85
+ onBlur={ () => setIsFocused( false ) }
86
+ >
87
+ <div className="edit-site-global-styles-variations_item-preview">
88
+ <StylesPreview
89
+ label={ variation?.title }
90
+ isFocused={ isFocused }
91
+ withHoverView
92
+ />
93
+ </div>
94
+ </div>
95
+ </GlobalStylesContext.Provider>
96
+ );
97
+ }
98
+
99
+ export default function StyleVariationsContainer() {
100
+ const { variations } = useSelect( ( select ) => {
101
+ return {
102
+ variations:
103
+ select(
104
+ coreStore
105
+ ).__experimentalGetCurrentThemeGlobalStylesVariations() || [],
106
+ };
107
+ }, [] );
108
+
109
+ const withEmptyVariation = useMemo( () => {
110
+ return [
111
+ {
112
+ title: __( 'Default' ),
113
+ settings: {},
114
+ styles: {},
115
+ },
116
+ ...variations.map( ( variation ) => ( {
117
+ ...variation,
118
+ settings: variation.settings ?? {},
119
+ styles: variation.styles ?? {},
120
+ } ) ),
121
+ ];
122
+ }, [ variations ] );
123
+
124
+ return (
125
+ <>
126
+ <Grid
127
+ columns={ 2 }
128
+ className="edit-site-global-styles-style-variations-container"
129
+ >
130
+ { withEmptyVariation?.map( ( variation, index ) => (
131
+ <Variation key={ index } variation={ variation } />
132
+ ) ) }
133
+ </Grid>
134
+ </>
135
+ );
136
+ }
@@ -189,45 +189,6 @@
189
189
  flex-direction: column;
190
190
  }
191
191
 
192
- .edit-site-global-styles__shadow-panel {
193
- width: 230px;
194
- }
195
-
196
- .edit-site-global-styles__shadow-dropdown {
197
- display: block;
198
- padding: 0;
199
-
200
- > button {
201
- width: 100%;
202
- padding: $grid-unit-10;
203
-
204
- &.is-open {
205
- background-color: $gray-100;
206
- }
207
- }
208
- }
209
-
210
- // wrapper to clip the shadow beyond 6px
211
- .edit-site-global-styles__shadow-indicator-wrapper {
212
- padding: 6px;
213
- overflow: hidden;
214
- display: flex;
215
- align-items: center;
216
- justify-content: center;
217
- }
218
-
219
- // These styles are similar to the color palette.
220
- .edit-site-global-styles__shadow-indicator {
221
- color: $gray-800;
222
- border: $gray-200 $border-width solid;
223
- border-radius: $radius-block-ui;
224
- cursor: pointer;
225
- padding: 0;
226
-
227
- height: 24px;
228
- width: 24px;
229
- }
230
-
231
192
  .edit-site-global-styles-screen-root.edit-site-global-styles-screen-root,
232
193
  .edit-site-global-styles-screen-style-variations.edit-site-global-styles-screen-style-variations {
233
194
  background: unset;