@wordpress/edit-site 5.4.0 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +12 -3
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/new-template-part.js +8 -7
  5. package/build/components/add-new-template/new-template-part.js.map +1 -1
  6. package/build/components/add-new-template/new-template.js +3 -6
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/editor/index.js +3 -3
  9. package/build/components/editor/index.js.map +1 -1
  10. package/build/components/global-styles/border-panel.js +1 -1
  11. package/build/components/global-styles/border-panel.js.map +1 -1
  12. package/build/components/global-styles/context-menu.js +11 -8
  13. package/build/components/global-styles/context-menu.js.map +1 -1
  14. package/build/components/global-styles/dimensions-panel.js +41 -487
  15. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  16. package/build/components/global-styles/duotone-panel.js +78 -0
  17. package/build/components/global-styles/duotone-panel.js.map +1 -0
  18. package/build/components/global-styles/filter-utils.js +17 -0
  19. package/build/components/global-styles/filter-utils.js.map +1 -0
  20. package/build/components/global-styles/preview.js +9 -5
  21. package/build/components/global-styles/preview.js.map +1 -1
  22. package/build/components/global-styles/screen-block-list.js +4 -8
  23. package/build/components/global-styles/screen-block-list.js.map +1 -1
  24. package/build/components/global-styles/screen-border.js +1 -1
  25. package/build/components/global-styles/screen-border.js.map +1 -1
  26. package/build/components/global-styles/screen-filters.js +46 -0
  27. package/build/components/global-styles/screen-filters.js.map +1 -0
  28. package/build/components/global-styles/screen-layout.js +13 -5
  29. package/build/components/global-styles/screen-layout.js.map +1 -1
  30. package/build/components/global-styles/screen-variations.js +1 -1
  31. package/build/components/global-styles/screen-variations.js.map +1 -1
  32. package/build/components/global-styles/shadow-panel.js +6 -4
  33. package/build/components/global-styles/shadow-panel.js.map +1 -1
  34. package/build/components/global-styles/typography-panel.js +2 -5
  35. package/build/components/global-styles/typography-panel.js.map +1 -1
  36. package/build/components/global-styles/ui.js +7 -1
  37. package/build/components/global-styles/ui.js.map +1 -1
  38. package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
  39. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  40. package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
  41. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  42. package/build/components/keyboard-shortcuts/global.js +48 -0
  43. package/build/components/keyboard-shortcuts/global.js.map +1 -0
  44. package/build/components/keyboard-shortcuts/index.js +67 -0
  45. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  46. package/build/components/keyboard-shortcuts/register.js +153 -0
  47. package/build/components/keyboard-shortcuts/register.js.map +1 -0
  48. package/build/components/layout/index.js +5 -1
  49. package/build/components/layout/index.js.map +1 -1
  50. package/build/components/list/added-by.js +41 -42
  51. package/build/components/list/added-by.js.map +1 -1
  52. package/build/components/list/table.js +3 -2
  53. package/build/components/list/table.js.map +1 -1
  54. package/build/components/navigation-inspector/navigation-menu.js +22 -5
  55. package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
  56. package/build/components/save-button/index.js +5 -2
  57. package/build/components/save-button/index.js.map +1 -1
  58. package/build/components/save-panel/index.js +11 -1
  59. package/build/components/save-panel/index.js.map +1 -1
  60. package/build/components/sidebar/index.js +28 -16
  61. package/build/components/sidebar/index.js.map +1 -1
  62. package/build/components/sidebar-button/index.js +30 -0
  63. package/build/components/sidebar-button/index.js.map +1 -0
  64. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  65. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  66. package/build/components/sidebar-navigation-screen/index.js +10 -10
  67. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  68. package/build/components/sidebar-navigation-screen-main/index.js +3 -3
  69. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  70. package/build/components/sidebar-navigation-screen-navigation-item/index.js +17 -16
  71. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  72. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +10 -4
  73. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  74. package/build/components/sidebar-navigation-screen-template/index.js +9 -19
  75. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  76. package/build/components/sidebar-navigation-screen-templates/index.js +25 -15
  77. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  78. package/build/components/sidebar-navigation-screen-templates-browse/index.js +8 -7
  79. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  80. package/build/components/style-book/index.js +17 -2
  81. package/build/components/style-book/index.js.map +1 -1
  82. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
  83. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  84. package/build/components/sync-state-with-url/use-sync-path-with-url.js +65 -18
  85. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  86. package/build/components/template-details/index.js +7 -9
  87. package/build/components/template-details/index.js.map +1 -1
  88. package/build/index.js +10 -22
  89. package/build/index.js.map +1 -1
  90. package/build/store/actions.js +2 -2
  91. package/build/store/actions.js.map +1 -1
  92. package/build/utils/get-is-list-page.js +1 -1
  93. package/build/utils/get-is-list-page.js.map +1 -1
  94. package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
  95. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  96. package/build-module/components/add-new-template/new-template-part.js +8 -7
  97. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  98. package/build-module/components/add-new-template/new-template.js +3 -6
  99. package/build-module/components/add-new-template/new-template.js.map +1 -1
  100. package/build-module/components/editor/index.js +3 -3
  101. package/build-module/components/editor/index.js.map +1 -1
  102. package/build-module/components/global-styles/border-panel.js +1 -1
  103. package/build-module/components/global-styles/border-panel.js.map +1 -1
  104. package/build-module/components/global-styles/context-menu.js +12 -9
  105. package/build-module/components/global-styles/context-menu.js.map +1 -1
  106. package/build-module/components/global-styles/dimensions-panel.js +43 -480
  107. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  108. package/build-module/components/global-styles/duotone-panel.js +67 -0
  109. package/build-module/components/global-styles/duotone-panel.js.map +1 -0
  110. package/build-module/components/global-styles/filter-utils.js +9 -0
  111. package/build-module/components/global-styles/filter-utils.js.map +1 -0
  112. package/build-module/components/global-styles/preview.js +10 -6
  113. package/build-module/components/global-styles/preview.js.map +1 -1
  114. package/build-module/components/global-styles/screen-block-list.js +4 -6
  115. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  116. package/build-module/components/global-styles/screen-border.js +1 -1
  117. package/build-module/components/global-styles/screen-border.js.map +1 -1
  118. package/build-module/components/global-styles/screen-filters.js +33 -0
  119. package/build-module/components/global-styles/screen-filters.js.map +1 -0
  120. package/build-module/components/global-styles/screen-layout.js +11 -2
  121. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  122. package/build-module/components/global-styles/screen-variations.js +1 -1
  123. package/build-module/components/global-styles/screen-variations.js.map +1 -1
  124. package/build-module/components/global-styles/shadow-panel.js +6 -4
  125. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  126. package/build-module/components/global-styles/typography-panel.js +2 -5
  127. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  128. package/build-module/components/global-styles/ui.js +6 -1
  129. package/build-module/components/global-styles/ui.js.map +1 -1
  130. package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
  131. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  132. package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
  133. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  134. package/build-module/components/keyboard-shortcuts/global.js +37 -0
  135. package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
  136. package/build-module/components/keyboard-shortcuts/index.js +65 -0
  137. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  138. package/build-module/components/keyboard-shortcuts/register.js +141 -0
  139. package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
  140. package/build-module/components/layout/index.js +3 -1
  141. package/build-module/components/layout/index.js.map +1 -1
  142. package/build-module/components/list/added-by.js +43 -44
  143. package/build-module/components/list/added-by.js.map +1 -1
  144. package/build-module/components/list/table.js +3 -2
  145. package/build-module/components/list/table.js.map +1 -1
  146. package/build-module/components/navigation-inspector/navigation-menu.js +25 -8
  147. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
  148. package/build-module/components/save-button/index.js +5 -2
  149. package/build-module/components/save-button/index.js.map +1 -1
  150. package/build-module/components/save-panel/index.js +8 -1
  151. package/build-module/components/save-panel/index.js.map +1 -1
  152. package/build-module/components/sidebar/index.js +25 -18
  153. package/build-module/components/sidebar/index.js.map +1 -1
  154. package/build-module/components/sidebar-button/index.js +18 -0
  155. package/build-module/components/sidebar-button/index.js.map +1 -0
  156. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +8 -2
  157. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  158. package/build-module/components/sidebar-navigation-screen/index.js +8 -11
  159. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  160. package/build-module/components/sidebar-navigation-screen-main/index.js +3 -3
  161. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  162. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +16 -17
  163. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  164. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +10 -4
  165. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  166. package/build-module/components/sidebar-navigation-screen-template/index.js +8 -18
  167. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  168. package/build-module/components/sidebar-navigation-screen-templates/index.js +23 -16
  169. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  170. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +7 -7
  171. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  172. package/build-module/components/style-book/index.js +17 -3
  173. package/build-module/components/style-book/index.js.map +1 -1
  174. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +36 -34
  175. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  176. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +63 -18
  177. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  178. package/build-module/components/template-details/index.js +7 -8
  179. package/build-module/components/template-details/index.js.map +1 -1
  180. package/build-module/index.js +12 -22
  181. package/build-module/index.js.map +1 -1
  182. package/build-module/store/actions.js +2 -2
  183. package/build-module/store/actions.js.map +1 -1
  184. package/build-module/utils/get-is-list-page.js +1 -1
  185. package/build-module/utils/get-is-list-page.js.map +1 -1
  186. package/build-style/style-rtl.css +41 -38
  187. package/build-style/style.css +41 -38
  188. package/package.json +31 -31
  189. package/src/components/add-new-template/add-custom-template-modal.js +14 -10
  190. package/src/components/add-new-template/new-template-part.js +7 -9
  191. package/src/components/add-new-template/new-template.js +3 -6
  192. package/src/components/add-new-template/style.scss +0 -5
  193. package/src/components/block-editor/style.scss +1 -1
  194. package/src/components/editor/index.js +4 -3
  195. package/src/components/editor/style.scss +0 -6
  196. package/src/components/global-styles/border-panel.js +1 -1
  197. package/src/components/global-styles/context-menu.js +16 -10
  198. package/src/components/global-styles/dimensions-panel.js +43 -577
  199. package/src/components/global-styles/duotone-panel.js +82 -0
  200. package/src/components/global-styles/filter-utils.js +9 -0
  201. package/src/components/global-styles/preview.js +155 -140
  202. package/src/components/global-styles/screen-block-list.js +4 -9
  203. package/src/components/global-styles/screen-border.js +1 -1
  204. package/src/components/global-styles/screen-filters.js +27 -0
  205. package/src/components/global-styles/screen-layout.js +9 -2
  206. package/src/components/global-styles/screen-variations.js +0 -1
  207. package/src/components/global-styles/shadow-panel.js +4 -3
  208. package/src/components/global-styles/typography-panel.js +5 -7
  209. package/src/components/global-styles/ui.js +6 -1
  210. package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
  211. package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
  212. package/src/components/keyboard-shortcuts/global.js +35 -0
  213. package/src/components/keyboard-shortcuts/index.js +70 -0
  214. package/src/components/keyboard-shortcuts/register.js +157 -0
  215. package/src/components/layout/index.js +4 -0
  216. package/src/components/layout/style.scss +8 -1
  217. package/src/components/list/added-by.js +48 -55
  218. package/src/components/list/style.scss +5 -13
  219. package/src/components/list/table.js +4 -5
  220. package/src/components/navigation-inspector/navigation-menu.js +24 -6
  221. package/src/components/save-button/index.js +2 -2
  222. package/src/components/save-panel/index.js +8 -1
  223. package/src/components/sidebar/index.js +32 -14
  224. package/src/components/sidebar-button/index.js +21 -0
  225. package/src/components/sidebar-button/style.scss +23 -0
  226. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +3 -7
  227. package/src/components/sidebar-edit-mode/style.scss +16 -0
  228. package/src/components/sidebar-navigation-screen/index.js +31 -38
  229. package/src/components/sidebar-navigation-screen/style.scss +1 -9
  230. package/src/components/sidebar-navigation-screen-main/index.js +3 -3
  231. package/src/components/sidebar-navigation-screen-navigation-item/index.js +24 -20
  232. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +7 -3
  233. package/src/components/sidebar-navigation-screen-template/index.js +7 -19
  234. package/src/components/sidebar-navigation-screen-templates/index.js +22 -14
  235. package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
  236. package/src/components/sidebar-navigation-screen-templates-browse/index.js +6 -11
  237. package/src/components/style-book/index.js +25 -1
  238. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +28 -23
  239. package/src/components/sync-state-with-url/use-sync-path-with-url.js +72 -17
  240. package/src/components/template-details/index.js +5 -6
  241. package/src/index.js +6 -21
  242. package/src/store/actions.js +2 -2
  243. package/src/style.scss +1 -0
  244. package/src/utils/get-is-list-page.js +1 -1
@@ -4,9 +4,11 @@
4
4
  import {
5
5
  privateApis as blockEditorPrivateApis,
6
6
  store as blockEditorStore,
7
+ BlockList,
8
+ BlockTools,
7
9
  } from '@wordpress/block-editor';
8
10
  import { useEffect } from '@wordpress/element';
9
- import { useDispatch } from '@wordpress/data';
11
+ import { useSelect, useDispatch } from '@wordpress/data';
10
12
 
11
13
  /**
12
14
  * Internal dependencies
@@ -34,9 +36,16 @@ const ALLOWED_BLOCKS = {
34
36
  'core/navigation-link',
35
37
  'core/navigation-submenu',
36
38
  ],
39
+ 'core/page-list': [ 'core/page-list-item' ],
37
40
  };
38
41
 
39
42
  export default function NavigationMenu( { innerBlocks, onSelect } ) {
43
+ const { clientIdsTree } = useSelect( ( select ) => {
44
+ const { __unstableGetClientIdsTree } = select( blockEditorStore );
45
+ return {
46
+ clientIdsTree: __unstableGetClientIdsTree(),
47
+ };
48
+ } );
40
49
  const { updateBlockListSettings } = useDispatch( blockEditorStore );
41
50
 
42
51
  const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorPrivateApis );
@@ -56,11 +65,20 @@ export default function NavigationMenu( { innerBlocks, onSelect } ) {
56
65
  } );
57
66
  }, [ updateBlockListSettings, innerBlocks ] );
58
67
 
68
+ // The hidden block is needed because it makes block edit side effects trigger.
69
+ // For example a navigation page list load its items has an effect on edit to load its items.
59
70
  return (
60
- <OffCanvasEditor
61
- blocks={ innerBlocks }
62
- onSelect={ onSelect }
63
- LeafMoreMenu={ LeafMoreMenu }
64
- />
71
+ <>
72
+ <OffCanvasEditor
73
+ blocks={ clientIdsTree }
74
+ onSelect={ onSelect }
75
+ LeafMoreMenu={ LeafMoreMenu }
76
+ />
77
+ <div style={ { display: 'none' } }>
78
+ <BlockTools>
79
+ <BlockList />
80
+ </BlockTools>
81
+ </div>
82
+ </>
65
83
  );
66
84
  }
@@ -12,7 +12,7 @@ import { displayShortcut } from '@wordpress/keycodes';
12
12
  */
13
13
  import { store as editSiteStore } from '../../store';
14
14
 
15
- export default function SaveButton() {
15
+ export default function SaveButton( { showTooltip = true } ) {
16
16
  const { isDirty, isSaving, isSaveViewOpen } = useSelect( ( select ) => {
17
17
  const { __experimentalGetDirtyEntityRecords, isSavingEntityRecord } =
18
18
  select( coreStore );
@@ -52,7 +52,7 @@ export default function SaveButton() {
52
52
  * of the button that we want to avoid. By setting `showTooltip`,
53
53
  & the tooltip is always rendered even when there's no keyboard shortcut.
54
54
  */
55
- showTooltip
55
+ showTooltip={ showTooltip }
56
56
  >
57
57
  { label }
58
58
  </Button>
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -46,7 +51,9 @@ export default function SavePanel() {
46
51
 
47
52
  return (
48
53
  <NavigableRegion
49
- className="edit-site-layout__actions"
54
+ className={ classnames( 'edit-site-layout__actions', {
55
+ 'is-entity-save-view-open': isSaveViewOpen,
56
+ } ) }
50
57
  ariaLabel={ __( 'Save sidebar' ) }
51
58
  >
52
59
  { isSaveViewOpen ? (
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { memo } from '@wordpress/element';
5
- import { __experimentalNavigatorProvider as NavigatorProvider } from '@wordpress/components';
4
+ import { memo, useRef } from '@wordpress/element';
5
+ import {
6
+ __experimentalNavigatorProvider as NavigatorProvider,
7
+ __experimentalNavigatorScreen as NavigatorScreen,
8
+ } from '@wordpress/components';
6
9
 
7
10
  /**
8
11
  * Internal dependencies
@@ -10,42 +13,57 @@ import { __experimentalNavigatorProvider as NavigatorProvider } from '@wordpress
10
13
  import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
11
14
  import SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';
12
15
  import SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';
13
- import useSyncPathWithURL from '../sync-state-with-url/use-sync-path-with-url';
16
+ import useSyncPathWithURL, {
17
+ getPathFromURL,
18
+ } from '../sync-state-with-url/use-sync-path-with-url';
14
19
  import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
15
20
  import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
16
21
  import SaveButton from '../save-button';
17
22
  import SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';
23
+ import { useLocation } from '../routes';
18
24
 
19
25
  function SidebarScreens() {
20
26
  useSyncPathWithURL();
21
27
 
22
28
  return (
23
29
  <>
24
- <SidebarNavigationScreenMain />
25
- <SidebarNavigationScreenNavigationMenus />
26
- <SidebarNavigationScreenNavigationItem />
27
- <SidebarNavigationScreenTemplates postType="wp_template" />
28
- <SidebarNavigationScreenTemplates postType="wp_template_part" />
29
- <SidebarNavigationScreenTemplate postType="wp_template" />
30
- <SidebarNavigationScreenTemplate postType="wp_template_part" />
31
- <SidebarNavigationScreenTemplatesBrowse postType="wp_template" />
32
- <SidebarNavigationScreenTemplatesBrowse postType="wp_template_part" />
30
+ <NavigatorScreen path="/">
31
+ <SidebarNavigationScreenMain />
32
+ </NavigatorScreen>
33
+ <NavigatorScreen path="/navigation">
34
+ <SidebarNavigationScreenNavigationMenus />
35
+ </NavigatorScreen>
36
+ <NavigatorScreen path="/navigation/:postType/:postId">
37
+ <SidebarNavigationScreenNavigationItem />
38
+ </NavigatorScreen>
39
+ <NavigatorScreen path="/:postType(wp_template|wp_template_part)">
40
+ <SidebarNavigationScreenTemplates />
41
+ </NavigatorScreen>
42
+ <NavigatorScreen path="/:postType(wp_template|wp_template_part)/all">
43
+ <SidebarNavigationScreenTemplatesBrowse />
44
+ </NavigatorScreen>
45
+ <NavigatorScreen path="/:postType(wp_template|wp_template_part)/:postId">
46
+ <SidebarNavigationScreenTemplate />
47
+ </NavigatorScreen>
33
48
  </>
34
49
  );
35
50
  }
36
51
 
37
52
  function Sidebar() {
53
+ const { params: urlParams } = useLocation();
54
+ const initialPath = useRef( getPathFromURL( urlParams ) );
55
+
38
56
  return (
39
57
  <>
40
58
  <NavigatorProvider
41
59
  className="edit-site-sidebar__content"
42
- initialPath="/"
60
+ initialPath={ initialPath.current }
43
61
  >
44
62
  <SidebarScreens />
45
63
  </NavigatorProvider>
46
64
 
47
65
  <div className="edit-site-sidebar__footer">
48
- <SaveButton />
66
+ <SaveButton showTooltip={ false } />
49
67
  </div>
50
68
  </>
51
69
  );
@@ -0,0 +1,21 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Button } from '@wordpress/components';
10
+
11
+ export default function SidebarButton( props ) {
12
+ return (
13
+ <Button
14
+ { ...props }
15
+ className={ classnames(
16
+ 'edit-site-sidebar-button',
17
+ props.className
18
+ ) }
19
+ />
20
+ );
21
+ }
@@ -0,0 +1,23 @@
1
+ .edit-site-sidebar-button {
2
+ color: $gray-200;
3
+ flex-shrink: 0;
4
+
5
+ // Focus (resets default button focus and use focus-visible).
6
+ &:focus:not(:disabled) {
7
+ box-shadow: none;
8
+ outline: none;
9
+ }
10
+ &:focus-visible:not(:disabled) {
11
+ box-shadow:
12
+ 0 0 0 var(--wp-admin-border-width-focus)
13
+ var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
14
+ outline: 3px solid transparent;
15
+ }
16
+
17
+ &:hover,
18
+ &:focus-visible,
19
+ &:focus,
20
+ &:not([aria-disabled="true"]):active {
21
+ color: $white;
22
+ }
23
+ }
@@ -37,18 +37,14 @@ export default function GlobalStylesSidebar() {
37
37
  closeLabel={ __( 'Close Styles sidebar' ) }
38
38
  panelClassName="edit-site-global-styles-sidebar__panel"
39
39
  header={
40
- <Flex>
41
- <FlexBlock>
40
+ <Flex className="edit-site-global-styles-sidebar__header">
41
+ <FlexBlock style={ { minWidth: 'min-content' } }>
42
42
  <strong>{ __( 'Styles' ) }</strong>
43
43
  </FlexBlock>
44
44
  <FlexItem>
45
45
  <Button
46
46
  icon={ seen }
47
- label={
48
- isStyleBookOpened
49
- ? __( 'Close Style Book' )
50
- : __( 'Open Style Book' )
51
- }
47
+ label={ __( 'Style Book' ) }
52
48
  isPressed={ isStyleBookOpened }
53
49
  disabled={ editorMode !== 'visual' }
54
50
  onClick={ () => {
@@ -83,3 +83,19 @@
83
83
  .edit-site-global-styles-sidebar hr {
84
84
  margin: 0;
85
85
  }
86
+
87
+ .show-icon-labels {
88
+ .edit-site-global-styles-sidebar__header {
89
+ .components-button.has-icon {
90
+ // Hide the button icons when labels are set to display...
91
+ svg {
92
+ display: none;
93
+ }
94
+ // ... and display labels.
95
+ &::after {
96
+ content: attr(aria-label);
97
+ font-size: $helptext-font-size;
98
+ }
99
+ }
100
+ }
101
+ }
@@ -5,8 +5,6 @@ import {
5
5
  __experimentalHStack as HStack,
6
6
  __experimentalVStack as VStack,
7
7
  __experimentalNavigatorToParentButton as NavigatorToParentButton,
8
- Button,
9
- __experimentalNavigatorScreen as NavigatorScreen,
10
8
  } from '@wordpress/components';
11
9
  import { isRTL, __ } from '@wordpress/i18n';
12
10
  import { chevronRight, chevronLeft } from '@wordpress/icons';
@@ -17,9 +15,10 @@ import { useSelect } from '@wordpress/data';
17
15
  */
18
16
  import { store as editSiteStore } from '../../store';
19
17
  import { unlock } from '../../private-apis';
18
+ import SidebarButton from '../sidebar-button';
20
19
 
21
20
  export default function SidebarNavigationScreen( {
22
- path,
21
+ isRoot,
23
22
  title,
24
23
  actions,
25
24
  content,
@@ -32,41 +31,35 @@ export default function SidebarNavigationScreen( {
32
31
  }, [] );
33
32
 
34
33
  return (
35
- <NavigatorScreen
36
- className="edit-site-sidebar-navigation-screen"
37
- path={ path }
38
- >
39
- <VStack spacing={ 2 }>
40
- <HStack
41
- spacing={ 4 }
42
- justify="flex-start"
43
- className="edit-site-sidebar-navigation-screen__title-icon"
44
- >
45
- { path !== '/' ? (
46
- <NavigatorToParentButton
47
- className="edit-site-sidebar-navigation-screen__back"
48
- icon={ isRTL() ? chevronRight : chevronLeft }
49
- aria-label={ __( 'Back' ) }
50
- />
51
- ) : (
52
- <Button
53
- className="edit-site-sidebar-navigation-screen__back"
54
- icon={ isRTL() ? chevronRight : chevronLeft }
55
- aria-label={ __( 'Navigate to the Dashboard' ) }
56
- href={ dashboardLink || 'index.php' }
57
- label={ __( 'Dashboard' ) }
58
- />
59
- ) }
60
- <h2 className="edit-site-sidebar-navigation-screen__title">
61
- { title }
62
- </h2>
63
- { actions }
64
- </HStack>
34
+ <VStack spacing={ 2 }>
35
+ <HStack
36
+ spacing={ 4 }
37
+ justify="flex-start"
38
+ className="edit-site-sidebar-navigation-screen__title-icon"
39
+ >
40
+ { ! isRoot ? (
41
+ <NavigatorToParentButton
42
+ as={ SidebarButton }
43
+ icon={ isRTL() ? chevronRight : chevronLeft }
44
+ aria-label={ __( 'Back' ) }
45
+ />
46
+ ) : (
47
+ <SidebarButton
48
+ icon={ isRTL() ? chevronRight : chevronLeft }
49
+ aria-label={ __( 'Navigate to the Dashboard' ) }
50
+ href={ dashboardLink || 'index.php' }
51
+ label={ __( 'Dashboard' ) }
52
+ />
53
+ ) }
54
+ <h2 className="edit-site-sidebar-navigation-screen__title">
55
+ { title }
56
+ </h2>
57
+ { actions }
58
+ </HStack>
65
59
 
66
- <nav className="edit-site-sidebar-navigation-screen__content">
67
- { content }
68
- </nav>
69
- </VStack>
70
- </NavigatorScreen>
60
+ <nav className="edit-site-sidebar-navigation-screen__content">
61
+ { content }
62
+ </nav>
63
+ </VStack>
71
64
  );
72
65
  }
@@ -23,17 +23,9 @@
23
23
 
24
24
  .edit-site-sidebar-navigation-screen__title {
25
25
  font-size: calc(1.56 * 13px);
26
+ line-height: normal;
26
27
  font-weight: 500;
27
28
  flex-grow: 1;
28
29
  color: $white;
29
30
  margin: 0;
30
31
  }
31
-
32
- .edit-site-sidebar-navigation-screen__back {
33
- color: $gray-200;
34
-
35
- &:hover,
36
- &:not([aria-disabled="true"]):active {
37
- color: $white;
38
- }
39
- }
@@ -29,7 +29,7 @@ export default function SidebarNavigationScreenMain() {
29
29
 
30
30
  return (
31
31
  <SidebarNavigationScreen
32
- path="/"
32
+ isRoot
33
33
  title={ __( 'Design' ) }
34
34
  content={
35
35
  <ItemGroup>
@@ -45,7 +45,7 @@ export default function SidebarNavigationScreenMain() {
45
45
  ) }
46
46
  <NavigatorButton
47
47
  as={ SidebarNavigationItem }
48
- path="/templates"
48
+ path="/wp_template"
49
49
  withChevron
50
50
  icon={ layout }
51
51
  >
@@ -53,7 +53,7 @@ export default function SidebarNavigationScreenMain() {
53
53
  </NavigatorButton>
54
54
  <NavigatorButton
55
55
  as={ SidebarNavigationItem }
56
- path="/template-parts"
56
+ path="/wp_template_part"
57
57
  withChevron
58
58
  icon={ symbolFilled }
59
59
  >
@@ -3,9 +3,10 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { useDispatch, useSelect } from '@wordpress/data';
6
- import { Button } from '@wordpress/components';
6
+ import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
7
7
  import { store as coreStore } from '@wordpress/core-data';
8
8
  import { decodeEntities } from '@wordpress/html-entities';
9
+ import { pencil } from '@wordpress/icons';
9
10
 
10
11
  /**
11
12
  * Internal dependencies
@@ -13,36 +14,39 @@ import { decodeEntities } from '@wordpress/html-entities';
13
14
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
14
15
  import { unlock } from '../../private-apis';
15
16
  import { store as editSiteStore } from '../../store';
17
+ import SidebarButton from '../sidebar-button';
16
18
 
17
19
  export default function SidebarNavigationScreenNavigationItem() {
18
20
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
21
+ const {
22
+ params: { postType, postId },
23
+ } = useNavigator();
19
24
 
20
- const { post } = useSelect( ( select ) => {
21
- const { getEditedPostContext } = select( editSiteStore );
22
- const { getEntityRecord } = select( coreStore );
23
- const { postType, postId } = getEditedPostContext() ?? {};
25
+ const { post } = useSelect(
26
+ ( select ) => {
27
+ const { getEntityRecord } = select( coreStore );
24
28
 
25
- // The currently selected entity to display.
26
- // Typically template or template part in the site editor.
27
- return {
28
- post:
29
- postId && postType
30
- ? getEntityRecord( 'postType', postType, postId )
31
- : null,
32
- };
33
- }, [] );
29
+ // The currently selected entity to display.
30
+ // Typically template or template part in the site editor.
31
+ return {
32
+ post:
33
+ postId && postType
34
+ ? getEntityRecord( 'postType', postType, postId )
35
+ : null,
36
+ };
37
+ },
38
+ [ postType, postId ]
39
+ );
34
40
 
35
41
  return (
36
42
  <SidebarNavigationScreen
37
- path="/navigation/single"
38
43
  title={ post ? decodeEntities( post?.title?.rendered ) : null }
39
44
  actions={
40
- <Button
41
- variant="primary"
45
+ <SidebarButton
42
46
  onClick={ () => setCanvasMode( 'edit' ) }
43
- >
44
- { __( 'Edit' ) }
45
- </Button>
47
+ label={ __( 'Edit' ) }
48
+ icon={ pencil }
49
+ />
46
50
  }
47
51
  content={
48
52
  post ? decodeEntities( post?.description?.rendered ) : null
@@ -15,7 +15,7 @@ export default function SidebarNavigationScreenNavigationMenus() {
15
15
  const history = useHistory();
16
16
  const onSelect = useCallback(
17
17
  ( selectedBlock ) => {
18
- const { attributes } = selectedBlock;
18
+ const { attributes, name } = selectedBlock;
19
19
  if (
20
20
  attributes.kind === 'post-type' &&
21
21
  attributes.id &&
@@ -25,7 +25,12 @@ export default function SidebarNavigationScreenNavigationMenus() {
25
25
  history.push( {
26
26
  postType: attributes.type,
27
27
  postId: attributes.id,
28
- path: '/navigation/single',
28
+ } );
29
+ }
30
+ if ( name === 'core/page-list-item' && attributes.id && history ) {
31
+ history.push( {
32
+ postType: 'page',
33
+ postId: attributes.id,
29
34
  } );
30
35
  }
31
36
  },
@@ -33,7 +38,6 @@ export default function SidebarNavigationScreenNavigationMenus() {
33
38
  );
34
39
  return (
35
40
  <SidebarNavigationScreen
36
- path="/navigation"
37
41
  title={ __( 'Navigation' ) }
38
42
  content={
39
43
  <div className="edit-site-sidebar-navigation-screen-navigation-menus">
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { useDispatch } from '@wordpress/data';
6
- import { Button } from '@wordpress/components';
6
+ import { pencil } from '@wordpress/icons';
7
7
 
8
8
  /**
9
9
  * Internal dependencies
@@ -12,19 +12,9 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
12
12
  import useEditedEntityRecord from '../use-edited-entity-record';
13
13
  import { unlock } from '../../private-apis';
14
14
  import { store as editSiteStore } from '../../store';
15
+ import SidebarButton from '../sidebar-button';
15
16
 
16
- const config = {
17
- wp_template: {
18
- path: '/templates/single',
19
- },
20
- wp_template_part: {
21
- path: '/template-parts/single',
22
- },
23
- };
24
-
25
- export default function SidebarNavigationScreenTemplate( {
26
- postType = 'wp_template',
27
- } ) {
17
+ export default function SidebarNavigationScreenTemplate() {
28
18
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
29
19
  const { getDescription, getTitle, record } = useEditedEntityRecord();
30
20
  let description = getDescription();
@@ -36,15 +26,13 @@ export default function SidebarNavigationScreenTemplate( {
36
26
 
37
27
  return (
38
28
  <SidebarNavigationScreen
39
- path={ config[ postType ].path }
40
29
  title={ getTitle() }
41
30
  actions={
42
- <Button
43
- variant="primary"
31
+ <SidebarButton
44
32
  onClick={ () => setCanvasMode( 'edit' ) }
45
- >
46
- { __( 'Edit' ) }
47
- </Button>
33
+ label={ __( 'Edit' ) }
34
+ icon={ pencil }
35
+ />
48
36
  }
49
37
  content={ description ? <p>{ description }</p> : undefined }
50
38
  />
@@ -4,9 +4,11 @@
4
4
  import {
5
5
  __experimentalItemGroup as ItemGroup,
6
6
  __experimentalItem as Item,
7
+ __experimentalUseNavigator as useNavigator,
7
8
  } from '@wordpress/components';
8
9
  import { __ } from '@wordpress/i18n';
9
10
  import { useEntityRecords } from '@wordpress/core-data';
11
+ import { useSelect } from '@wordpress/data';
10
12
  import { decodeEntities } from '@wordpress/html-entities';
11
13
  import { useViewportMatch } from '@wordpress/compose';
12
14
 
@@ -17,10 +19,11 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen';
17
19
  import { useLink } from '../routes/link';
18
20
  import SidebarNavigationItem from '../sidebar-navigation-item';
19
21
  import AddNewTemplate from '../add-new-template';
22
+ import { store as editSiteStore } from '../../store';
23
+ import SidebarButton from '../sidebar-button';
20
24
 
21
25
  const config = {
22
26
  wp_template: {
23
- path: '/templates',
24
27
  labels: {
25
28
  title: __( 'Templates' ),
26
29
  loading: __( 'Loading templates' ),
@@ -29,7 +32,6 @@ const config = {
29
32
  },
30
33
  },
31
34
  wp_template_part: {
32
- path: '/template-parts',
33
35
  labels: {
34
36
  title: __( 'Template parts' ),
35
37
  loading: __( 'Loading template parts' ),
@@ -43,15 +45,20 @@ const TemplateItem = ( { postType, postId, ...props } ) => {
43
45
  const linkInfo = useLink( {
44
46
  postType,
45
47
  postId,
46
- path: config[ postType ].path + '/single',
47
48
  } );
48
49
  return <SidebarNavigationItem { ...linkInfo } { ...props } />;
49
50
  };
50
51
 
51
- export default function SidebarNavigationScreenTemplates( {
52
- postType = 'wp_template',
53
- } ) {
52
+ export default function SidebarNavigationScreenTemplates() {
53
+ const {
54
+ params: { postType },
55
+ } = useNavigator();
54
56
  const isMobileViewport = useViewportMatch( 'medium', '<' );
57
+ const isTemplatePartsMode = useSelect( ( select ) => {
58
+ const settings = select( editSiteStore ).getSettings();
59
+
60
+ return !! settings.supportsTemplatePartsMode;
61
+ }, [] );
55
62
 
56
63
  const { records: templates, isResolving: isLoading } = useEntityRecords(
57
64
  'postType',
@@ -60,24 +67,25 @@ export default function SidebarNavigationScreenTemplates( {
60
67
  per_page: -1,
61
68
  }
62
69
  );
70
+ const sortedTemplates = templates ? [ ...templates ] : [];
71
+ sortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );
63
72
 
64
73
  const browseAllLink = useLink( {
65
- postType,
66
- postId: undefined,
67
- path: config[ postType ].path + '/all',
74
+ path: '/' + postType + '/all',
68
75
  } );
69
76
 
77
+ const canCreate = ! isMobileViewport && ! isTemplatePartsMode;
78
+
70
79
  return (
71
80
  <SidebarNavigationScreen
72
- path={ config[ postType ].path }
81
+ isRoot={ isTemplatePartsMode }
73
82
  title={ config[ postType ].labels.title }
74
83
  actions={
75
- ! isMobileViewport && (
84
+ canCreate && (
76
85
  <AddNewTemplate
77
86
  templateType={ postType }
78
87
  toggleProps={ {
79
- className:
80
- 'edit-site-sidebar-navigation-screen-templates__add-button',
88
+ as: SidebarButton,
81
89
  } }
82
90
  />
83
91
  )
@@ -92,7 +100,7 @@ export default function SidebarNavigationScreenTemplates( {
92
100
  { config[ postType ].labels.notFound }
93
101
  </Item>
94
102
  ) }
95
- { ( templates ?? [] ).map( ( template ) => (
103
+ { sortedTemplates.map( ( template ) => (
96
104
  <TemplateItem
97
105
  postType={ postType }
98
106
  postId={ template.id }
@@ -2,8 +2,3 @@
2
2
  /* Overrides the margin that comes from the Item component */
3
3
  margin-top: $grid-unit-20 !important;
4
4
  }
5
-
6
- .edit-site-sidebar-navigation-screen-templates__add-button {
7
- /* Overrides the color for all states of the button */
8
- color: inherit !important;
9
- }