@wordpress/edit-site 5.7.0 → 5.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 (259) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template.js +2 -1
  3. package/build/components/add-new-template/new-template.js.map +1 -1
  4. package/build/components/block-editor/index.js +7 -7
  5. package/build/components/block-editor/index.js.map +1 -1
  6. package/build/components/editor/index.js +6 -4
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/editor-canvas-container/index.js +117 -0
  9. package/build/components/editor-canvas-container/index.js.map +1 -0
  10. package/build/components/global-styles/border-panel.js +81 -1
  11. package/build/components/global-styles/border-panel.js.map +1 -1
  12. package/build/components/global-styles/context-menu.js +6 -8
  13. package/build/components/global-styles/context-menu.js.map +1 -1
  14. package/build/components/global-styles/dimensions-panel.js +11 -1
  15. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  16. package/build/components/global-styles/effects-panel.js +53 -0
  17. package/build/components/global-styles/effects-panel.js.map +1 -0
  18. package/build/components/global-styles/filters-panel.js +50 -0
  19. package/build/components/global-styles/filters-panel.js.map +1 -0
  20. package/build/components/global-styles/global-styles-provider.js +4 -15
  21. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  22. package/build/components/global-styles/preview.js +1 -1
  23. package/build/components/global-styles/preview.js.map +1 -1
  24. package/build/components/global-styles/screen-block-list.js +14 -8
  25. package/build/components/global-styles/screen-block-list.js.map +1 -1
  26. package/build/components/global-styles/screen-css.js +1 -1
  27. package/build/components/global-styles/screen-css.js.map +1 -1
  28. package/build/components/global-styles/screen-effects.js +15 -7
  29. package/build/components/global-styles/screen-effects.js.map +1 -1
  30. package/build/components/global-styles/screen-filters.js +2 -2
  31. package/build/components/global-styles/screen-filters.js.map +1 -1
  32. package/build/components/global-styles/screen-style-variations.js +8 -118
  33. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  34. package/build/components/global-styles/style-variations-container.js +149 -0
  35. package/build/components/global-styles/style-variations-container.js.map +1 -0
  36. package/build/components/global-styles/ui.js +52 -15
  37. package/build/components/global-styles/ui.js.map +1 -1
  38. package/build/components/header-edit-mode/index.js +11 -7
  39. package/build/components/header-edit-mode/index.js.map +1 -1
  40. package/build/components/header-edit-mode/more-menu/index.js +1 -1
  41. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  42. package/build/components/keyboard-shortcuts/index.js +0 -137
  43. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  44. package/build/components/layout/index.js +17 -8
  45. package/build/components/layout/index.js.map +1 -1
  46. package/build/components/list/table.js +3 -3
  47. package/build/components/list/table.js.map +1 -1
  48. package/build/components/preferences-modal/index.js +4 -0
  49. package/build/components/preferences-modal/index.js.map +1 -1
  50. package/build/components/sidebar/index.js +4 -0
  51. package/build/components/sidebar/index.js.map +1 -1
  52. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +28 -13
  53. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  54. package/build/components/sidebar-navigation-screen/index.js +8 -6
  55. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  56. package/build/components/sidebar-navigation-screen-global-styles/index.js +58 -0
  57. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
  58. package/build/components/sidebar-navigation-screen-main/index.js +5 -0
  59. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  60. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +114 -9
  61. package/build/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  62. package/build/components/site-hub/index.js +40 -17
  63. package/build/components/site-hub/index.js.map +1 -1
  64. package/build/components/site-icon/index.js +8 -7
  65. package/build/components/site-icon/index.js.map +1 -1
  66. package/build/components/start-template-options/index.js +9 -8
  67. package/build/components/start-template-options/index.js.map +1 -1
  68. package/build/components/style-book/index.js +9 -41
  69. package/build/components/style-book/index.js.map +1 -1
  70. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -3
  71. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  72. package/build/components/template-details/index.js +3 -1
  73. package/build/components/template-details/index.js.map +1 -1
  74. package/build/components/welcome-guide/styles.js +1 -1
  75. package/build/components/welcome-guide/styles.js.map +1 -1
  76. package/build/hooks/commands/index.js +19 -0
  77. package/build/hooks/commands/index.js.map +1 -0
  78. package/build/hooks/commands/use-navigation-commands.js +126 -0
  79. package/build/hooks/commands/use-navigation-commands.js.map +1 -0
  80. package/build/hooks/commands/use-wp-admin-commands.js +97 -0
  81. package/build/hooks/commands/use-wp-admin-commands.js.map +1 -0
  82. package/build/hooks/template-part-edit.js +2 -1
  83. package/build/hooks/template-part-edit.js.map +1 -1
  84. package/build/index.js +2 -1
  85. package/build/index.js.map +1 -1
  86. package/build/store/private-actions.js +19 -1
  87. package/build/store/private-actions.js.map +1 -1
  88. package/build/store/private-selectors.js +13 -0
  89. package/build/store/private-selectors.js.map +1 -1
  90. package/build/store/reducer.js +23 -1
  91. package/build/store/reducer.js.map +1 -1
  92. package/build/store/selectors.js +2 -1
  93. package/build/store/selectors.js.map +1 -1
  94. package/build-module/components/add-new-template/new-template.js +3 -2
  95. package/build-module/components/add-new-template/new-template.js.map +1 -1
  96. package/build-module/components/block-editor/index.js +6 -6
  97. package/build-module/components/block-editor/index.js.map +1 -1
  98. package/build-module/components/editor/index.js +6 -4
  99. package/build-module/components/editor/index.js.map +1 -1
  100. package/build-module/components/editor-canvas-container/index.js +100 -0
  101. package/build-module/components/editor-canvas-container/index.js.map +1 -0
  102. package/build-module/components/global-styles/border-panel.js +81 -1
  103. package/build-module/components/global-styles/border-panel.js.map +1 -1
  104. package/build-module/components/global-styles/context-menu.js +6 -6
  105. package/build-module/components/global-styles/context-menu.js.map +1 -1
  106. package/build-module/components/global-styles/dimensions-panel.js +11 -1
  107. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  108. package/build-module/components/global-styles/effects-panel.js +43 -0
  109. package/build-module/components/global-styles/effects-panel.js.map +1 -0
  110. package/build-module/components/global-styles/filters-panel.js +40 -0
  111. package/build-module/components/global-styles/filters-panel.js.map +1 -0
  112. package/build-module/components/global-styles/global-styles-provider.js +5 -16
  113. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  114. package/build-module/components/global-styles/preview.js +1 -1
  115. package/build-module/components/global-styles/preview.js.map +1 -1
  116. package/build-module/components/global-styles/screen-block-list.js +13 -8
  117. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  118. package/build-module/components/global-styles/screen-css.js +1 -1
  119. package/build-module/components/global-styles/screen-css.js.map +1 -1
  120. package/build-module/components/global-styles/screen-effects.js +13 -4
  121. package/build-module/components/global-styles/screen-effects.js.map +1 -1
  122. package/build-module/components/global-styles/screen-filters.js +2 -2
  123. package/build-module/components/global-styles/screen-filters.js.map +1 -1
  124. package/build-module/components/global-styles/screen-style-variations.js +11 -114
  125. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  126. package/build-module/components/global-styles/style-variations-container.js +130 -0
  127. package/build-module/components/global-styles/style-variations-container.js.map +1 -0
  128. package/build-module/components/global-styles/ui.js +49 -16
  129. package/build-module/components/global-styles/ui.js.map +1 -1
  130. package/build-module/components/header-edit-mode/index.js +10 -7
  131. package/build-module/components/header-edit-mode/index.js.map +1 -1
  132. package/build-module/components/header-edit-mode/more-menu/index.js +1 -1
  133. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  134. package/build-module/components/keyboard-shortcuts/index.js +1 -135
  135. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  136. package/build-module/components/layout/index.js +14 -8
  137. package/build-module/components/layout/index.js.map +1 -1
  138. package/build-module/components/list/table.js +3 -3
  139. package/build-module/components/list/table.js.map +1 -1
  140. package/build-module/components/preferences-modal/index.js +4 -0
  141. package/build-module/components/preferences-modal/index.js.map +1 -1
  142. package/build-module/components/sidebar/index.js +3 -0
  143. package/build-module/components/sidebar/index.js.map +1 -1
  144. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +28 -15
  145. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  146. package/build-module/components/sidebar-navigation-screen/index.js +9 -7
  147. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  148. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +41 -0
  149. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -0
  150. package/build-module/components/sidebar-navigation-screen-main/index.js +6 -1
  151. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  152. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +113 -11
  153. package/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js.map +1 -1
  154. package/build-module/components/site-hub/index.js +40 -18
  155. package/build-module/components/site-hub/index.js.map +1 -1
  156. package/build-module/components/site-icon/index.js +8 -7
  157. package/build-module/components/site-icon/index.js.map +1 -1
  158. package/build-module/components/start-template-options/index.js +9 -8
  159. package/build-module/components/start-template-options/index.js.map +1 -1
  160. package/build-module/components/style-book/index.js +10 -41
  161. package/build-module/components/style-book/index.js.map +1 -1
  162. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -3
  163. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  164. package/build-module/components/template-details/index.js +3 -1
  165. package/build-module/components/template-details/index.js.map +1 -1
  166. package/build-module/components/welcome-guide/styles.js +1 -1
  167. package/build-module/components/welcome-guide/styles.js.map +1 -1
  168. package/build-module/hooks/commands/index.js +10 -0
  169. package/build-module/hooks/commands/index.js.map +1 -0
  170. package/build-module/hooks/commands/use-navigation-commands.js +109 -0
  171. package/build-module/hooks/commands/use-navigation-commands.js.map +1 -0
  172. package/build-module/hooks/commands/use-wp-admin-commands.js +81 -0
  173. package/build-module/hooks/commands/use-wp-admin-commands.js.map +1 -0
  174. package/build-module/hooks/template-part-edit.js +2 -1
  175. package/build-module/hooks/template-part-edit.js.map +1 -1
  176. package/build-module/index.js +2 -1
  177. package/build-module/index.js.map +1 -1
  178. package/build-module/store/private-actions.js +15 -0
  179. package/build-module/store/private-actions.js.map +1 -1
  180. package/build-module/store/private-selectors.js +11 -0
  181. package/build-module/store/private-selectors.js.map +1 -1
  182. package/build-module/store/reducer.js +23 -1
  183. package/build-module/store/reducer.js.map +1 -1
  184. package/build-module/store/selectors.js +2 -1
  185. package/build-module/store/selectors.js.map +1 -1
  186. package/build-style/style-rtl.css +133 -107
  187. package/build-style/style.css +133 -107
  188. package/package.json +34 -32
  189. package/src/components/add-new-template/new-template.js +3 -0
  190. package/src/components/block-editor/index.js +8 -8
  191. package/src/components/editor/index.js +11 -3
  192. package/src/components/editor-canvas-container/index.js +115 -0
  193. package/src/components/editor-canvas-container/style.scss +19 -0
  194. package/src/components/global-styles/border-panel.js +73 -1
  195. package/src/components/global-styles/context-menu.js +6 -6
  196. package/src/components/global-styles/dimensions-panel.js +11 -0
  197. package/src/components/global-styles/effects-panel.js +40 -0
  198. package/src/components/global-styles/filters-panel.js +39 -0
  199. package/src/components/global-styles/global-styles-provider.js +4 -18
  200. package/src/components/global-styles/preview.js +1 -1
  201. package/src/components/global-styles/screen-block-list.js +9 -5
  202. package/src/components/global-styles/screen-css.js +1 -1
  203. package/src/components/global-styles/screen-effects.js +12 -5
  204. package/src/components/global-styles/screen-filters.js +2 -2
  205. package/src/components/global-styles/screen-style-variations.js +10 -129
  206. package/src/components/global-styles/style-variations-container.js +136 -0
  207. package/src/components/global-styles/style.scss +0 -39
  208. package/src/components/global-styles/ui.js +54 -8
  209. package/src/components/header-edit-mode/index.js +14 -5
  210. package/src/components/header-edit-mode/more-menu/index.js +1 -1
  211. package/src/components/keyboard-shortcuts/index.js +1 -155
  212. package/src/components/layout/index.js +13 -16
  213. package/src/components/layout/style.scss +31 -4
  214. package/src/components/list/table.js +16 -2
  215. package/src/components/preferences-modal/index.js +7 -0
  216. package/src/components/secondary-sidebar/style.scss +23 -5
  217. package/src/components/sidebar/index.js +4 -0
  218. package/src/components/sidebar/style.scss +2 -1
  219. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +36 -17
  220. package/src/components/sidebar-navigation-screen/index.js +10 -5
  221. package/src/components/sidebar-navigation-screen/style.scss +20 -5
  222. package/src/components/sidebar-navigation-screen-global-styles/index.js +41 -0
  223. package/src/components/sidebar-navigation-screen-main/index.js +9 -1
  224. package/src/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js +134 -9
  225. package/src/components/site-hub/index.js +51 -23
  226. package/src/components/site-icon/index.js +6 -11
  227. package/src/components/site-icon/style.scss +8 -3
  228. package/src/components/start-template-options/index.js +13 -12
  229. package/src/components/start-template-options/style.scss +18 -43
  230. package/src/components/style-book/index.js +7 -51
  231. package/src/components/style-book/style.scss +0 -18
  232. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -3
  233. package/src/components/template-details/index.js +1 -0
  234. package/src/components/welcome-guide/styles.js +1 -1
  235. package/src/hooks/commands/index.js +10 -0
  236. package/src/hooks/commands/use-navigation-commands.js +112 -0
  237. package/src/hooks/commands/use-wp-admin-commands.js +79 -0
  238. package/src/hooks/template-part-edit.js +1 -0
  239. package/src/index.js +1 -0
  240. package/src/store/private-actions.js +14 -0
  241. package/src/store/private-selectors.js +11 -0
  242. package/src/store/reducer.js +18 -0
  243. package/src/store/selectors.js +2 -1
  244. package/src/style.scss +1 -0
  245. package/build/components/global-styles/duotone-panel.js +0 -78
  246. package/build/components/global-styles/duotone-panel.js.map +0 -1
  247. package/build/components/global-styles/filter-utils.js +0 -17
  248. package/build/components/global-styles/filter-utils.js.map +0 -1
  249. package/build/components/global-styles/shadow-panel.js +0 -197
  250. package/build/components/global-styles/shadow-panel.js.map +0 -1
  251. package/build-module/components/global-styles/duotone-panel.js +0 -67
  252. package/build-module/components/global-styles/duotone-panel.js.map +0 -1
  253. package/build-module/components/global-styles/filter-utils.js +0 -9
  254. package/build-module/components/global-styles/filter-utils.js.map +0 -1
  255. package/build-module/components/global-styles/shadow-panel.js +0 -178
  256. package/build-module/components/global-styles/shadow-panel.js.map +0 -1
  257. package/src/components/global-styles/duotone-panel.js +0 -82
  258. package/src/components/global-styles/filter-utils.js +0 -9
  259. package/src/components/global-styles/shadow-panel.js +0 -178
@@ -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;
@@ -10,17 +10,24 @@ import {
10
10
  } from '@wordpress/components';
11
11
  import { getBlockTypes, store as blocksStore } from '@wordpress/blocks';
12
12
  import { useSelect, useDispatch } from '@wordpress/data';
13
- import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
13
+ import {
14
+ privateApis as blockEditorPrivateApis,
15
+ store as blockEditorStore,
16
+ } from '@wordpress/block-editor';
14
17
  import { __ } from '@wordpress/i18n';
15
18
  import { store as preferencesStore } from '@wordpress/preferences';
16
19
  import { moreVertical } from '@wordpress/icons';
17
20
  import { store as coreStore } from '@wordpress/core-data';
21
+ import { useEffect, useRef } from '@wordpress/element';
18
22
 
19
23
  /**
20
24
  * Internal dependencies
21
25
  */
22
26
  import ScreenRoot from './screen-root';
23
- import ScreenBlockList from './screen-block-list';
27
+ import {
28
+ useBlockHasGlobalStyles,
29
+ default as ScreenBlockList,
30
+ } from './screen-block-list';
24
31
  import ScreenBlock from './screen-block';
25
32
  import ScreenTypography from './screen-typography';
26
33
  import ScreenTypographyElement from './screen-typography-element';
@@ -35,6 +42,7 @@ import StyleBook from '../style-book';
35
42
  import ScreenCSS from './screen-css';
36
43
  import { unlock } from '../../private-apis';
37
44
  import ScreenEffects from './screen-effects';
45
+ import { store as editSiteStore } from '../../store';
38
46
 
39
47
  const SLOT_FILL_NAME = 'GlobalStylesMenu';
40
48
  const { Slot: GlobalStylesMenuSlot, Fill: GlobalStylesMenuFill } =
@@ -232,7 +240,7 @@ function ContextScreens( { name, parentMenu = '', variation = '' } ) {
232
240
  );
233
241
  }
234
242
 
235
- function GlobalStylesStyleBook( { onClose } ) {
243
+ function GlobalStylesStyleBook() {
236
244
  const navigator = useNavigator();
237
245
  const { path } = navigator.location;
238
246
  return (
@@ -250,14 +258,51 @@ function GlobalStylesStyleBook( { onClose } ) {
250
258
  // Now go to the selected block.
251
259
  navigator.goTo( '/blocks/' + encodeURIComponent( blockName ) );
252
260
  } }
253
- onClose={ onClose }
254
261
  />
255
262
  );
256
263
  }
257
264
 
258
- function GlobalStylesUI( { isStyleBookOpened, onCloseStyleBook } ) {
259
- const blocks = getBlockTypes();
265
+ function GlobalStylesBlockLink() {
266
+ const navigator = useNavigator();
267
+ const isMounted = useRef();
268
+ const { selectedBlockName, selectedBlockClientId } = useSelect(
269
+ ( select ) => {
270
+ const { getSelectedBlockClientId, getBlockName } =
271
+ select( blockEditorStore );
272
+ const clientId = getSelectedBlockClientId();
273
+ return {
274
+ selectedBlockName: getBlockName( clientId ),
275
+ selectedBlockClientId: clientId,
276
+ };
277
+ },
278
+ []
279
+ );
280
+ const blockHasGlobalStyles = useBlockHasGlobalStyles( selectedBlockName );
281
+ useEffect( () => {
282
+ // Avoid navigating to the block screen on mount.
283
+ if ( ! isMounted.current ) {
284
+ isMounted.current = true;
285
+ return;
286
+ }
287
+ if ( ! selectedBlockClientId || ! blockHasGlobalStyles ) {
288
+ return;
289
+ }
290
+ const path = '/blocks/' + encodeURIComponent( selectedBlockName );
291
+ // Avoid navigating to the same path. This can happen when selecting
292
+ // a new block of the same type.
293
+ if ( path !== navigator.location.path ) {
294
+ navigator.goTo( path, { skipFocus: true } );
295
+ }
296
+ }, [ selectedBlockClientId, selectedBlockName, blockHasGlobalStyles ] );
297
+ }
260
298
 
299
+ function GlobalStylesUI() {
300
+ const blocks = getBlockTypes();
301
+ const editorCanvasContainerView = useSelect(
302
+ ( select ) =>
303
+ unlock( select( editSiteStore ) ).getEditorCanvasContainerView(),
304
+ []
305
+ );
261
306
  return (
262
307
  <NavigatorProvider
263
308
  className="edit-site-global-styles-sidebar__navigator-provider"
@@ -302,11 +347,12 @@ function GlobalStylesUI( { isStyleBookOpened, onCloseStyleBook } ) {
302
347
  />
303
348
  );
304
349
  } ) }
305
- { isStyleBookOpened && (
306
- <GlobalStylesStyleBook onClose={ onCloseStyleBook } />
350
+ { 'style-book' === editorCanvasContainerView && (
351
+ <GlobalStylesStyleBook />
307
352
  ) }
308
353
 
309
354
  <GlobalStylesActionMenu />
355
+ <GlobalStylesBlockLink />
310
356
  </NavigatorProvider>
311
357
  );
312
358
  }
@@ -38,7 +38,8 @@ import UndoButton from './undo-redo/undo';
38
38
  import RedoButton from './undo-redo/redo';
39
39
  import DocumentActions from './document-actions';
40
40
  import { store as editSiteStore } from '../../store';
41
- import { useHasStyleBook } from '../style-book';
41
+ import { getEditorCanvasContainerTitle } from '../editor-canvas-container';
42
+ import { unlock } from '../../private-apis';
42
43
 
43
44
  const preventDefault = ( event ) => {
44
45
  event.preventDefault();
@@ -56,6 +57,7 @@ export default function HeaderEditMode() {
56
57
  blockEditorMode,
57
58
  homeUrl,
58
59
  showIconLabels,
60
+ editorCanvasView,
59
61
  } = useSelect( ( select ) => {
60
62
  const {
61
63
  __experimentalGetPreviewDeviceType,
@@ -88,6 +90,9 @@ export default function HeaderEditMode() {
88
90
  'core/edit-site',
89
91
  'showIconLabels'
90
92
  ),
93
+ editorCanvasView: unlock(
94
+ select( editSiteStore )
95
+ ).getEditorCanvasContainerView(),
91
96
  };
92
97
  }, [] );
93
98
 
@@ -117,7 +122,7 @@ export default function HeaderEditMode() {
117
122
  [ setIsListViewOpened, isListViewOpen ]
118
123
  );
119
124
 
120
- const hasStyleBook = useHasStyleBook();
125
+ const hasDefaultEditorCanvasView = ! editorCanvasView;
121
126
 
122
127
  const isFocusMode = templateType === 'wp_template_part';
123
128
 
@@ -138,7 +143,7 @@ export default function HeaderEditMode() {
138
143
  'show-icon-labels': showIconLabels,
139
144
  } ) }
140
145
  >
141
- { ! hasStyleBook && (
146
+ { hasDefaultEditorCanvasView && (
142
147
  <NavigableToolbar
143
148
  className="edit-site-header-edit-mode__start"
144
149
  aria-label={ __( 'Document tools' ) }
@@ -223,12 +228,16 @@ export default function HeaderEditMode() {
223
228
  ) }
224
229
 
225
230
  <div className="edit-site-header-edit-mode__center">
226
- { hasStyleBook ? __( 'Style Book' ) : <DocumentActions /> }
231
+ { ! hasDefaultEditorCanvasView ? (
232
+ getEditorCanvasContainerTitle( editorCanvasView )
233
+ ) : (
234
+ <DocumentActions />
235
+ ) }
227
236
  </div>
228
237
 
229
238
  <div className="edit-site-header-edit-mode__end">
230
239
  <div className="edit-site-header-edit-mode__actions">
231
- { ! isFocusMode && ! hasStyleBook && (
240
+ { ! isFocusMode && hasDefaultEditorCanvasView && (
232
241
  <div
233
242
  className={ classnames(
234
243
  'edit-site-header-edit-mode__preview-options',
@@ -93,7 +93,7 @@ export default function MoreMenu( { showIconLabels } ) {
93
93
  icon={ external }
94
94
  role="menuitem"
95
95
  href={ __(
96
- 'https://wordpress.org/support/article/site-editor/'
96
+ 'https://wordpress.org/documentation/article/site-editor/'
97
97
  ) }
98
98
  target="_blank"
99
99
  rel="noopener noreferrer"