@wordpress/edit-site 5.3.5 → 5.3.6

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 (125) hide show
  1. package/build/components/add-new-template/add-custom-template-modal.js +12 -3
  2. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  3. package/build/components/add-new-template/new-template-part.js +5 -1
  4. package/build/components/add-new-template/new-template-part.js.map +1 -1
  5. package/build/components/editor/index.js +3 -3
  6. package/build/components/editor/index.js.map +1 -1
  7. package/build/components/global-styles/screen-variations.js +1 -1
  8. package/build/components/global-styles/screen-variations.js.map +1 -1
  9. package/build/components/global-styles/shadow-panel.js +6 -4
  10. package/build/components/global-styles/shadow-panel.js.map +1 -1
  11. package/build/components/keyboard-shortcuts/edit-mode.js +124 -0
  12. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  13. package/build/components/keyboard-shortcuts/global.js +48 -0
  14. package/build/components/keyboard-shortcuts/global.js.map +1 -0
  15. package/build/components/keyboard-shortcuts/register.js +153 -0
  16. package/build/components/keyboard-shortcuts/register.js.map +1 -0
  17. package/build/components/layout/index.js +5 -1
  18. package/build/components/layout/index.js.map +1 -1
  19. package/build/components/list/added-by.js +41 -42
  20. package/build/components/list/added-by.js.map +1 -1
  21. package/build/components/list/table.js +3 -1
  22. package/build/components/list/table.js.map +1 -1
  23. package/build/components/save-button/index.js +5 -2
  24. package/build/components/save-button/index.js.map +1 -1
  25. package/build/components/sidebar/index.js +15 -3
  26. package/build/components/sidebar/index.js.map +1 -1
  27. package/build/components/sidebar-button/index.js +30 -0
  28. package/build/components/sidebar-button/index.js.map +1 -0
  29. package/build/components/sidebar-navigation-screen/index.js +6 -3
  30. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  31. package/build/components/sidebar-navigation-screen-navigation-item/index.js +9 -4
  32. package/build/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  33. package/build/components/sidebar-navigation-screen-template/index.js +8 -5
  34. package/build/components/sidebar-navigation-screen-template/index.js.map +1 -1
  35. package/build/components/sidebar-navigation-screen-templates/index.js +17 -3
  36. package/build/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  37. package/build/components/style-book/index.js +17 -2
  38. package/build/components/style-book/index.js.map +1 -1
  39. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
  40. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  41. package/build/components/sync-state-with-url/use-sync-path-with-url.js +23 -25
  42. package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  43. package/build/components/template-details/index.js +7 -9
  44. package/build/components/template-details/index.js.map +1 -1
  45. package/build/index.js +10 -22
  46. package/build/index.js.map +1 -1
  47. package/build-module/components/add-new-template/add-custom-template-modal.js +13 -4
  48. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  49. package/build-module/components/add-new-template/new-template-part.js +5 -1
  50. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  51. package/build-module/components/editor/index.js +3 -3
  52. package/build-module/components/editor/index.js.map +1 -1
  53. package/build-module/components/global-styles/screen-variations.js +1 -1
  54. package/build-module/components/global-styles/screen-variations.js.map +1 -1
  55. package/build-module/components/global-styles/shadow-panel.js +6 -4
  56. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  57. package/build-module/components/keyboard-shortcuts/edit-mode.js +108 -0
  58. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -0
  59. package/build-module/components/keyboard-shortcuts/global.js +37 -0
  60. package/build-module/components/keyboard-shortcuts/global.js.map +1 -0
  61. package/build-module/components/keyboard-shortcuts/register.js +141 -0
  62. package/build-module/components/keyboard-shortcuts/register.js.map +1 -0
  63. package/build-module/components/layout/index.js +3 -1
  64. package/build-module/components/layout/index.js.map +1 -1
  65. package/build-module/components/list/added-by.js +43 -44
  66. package/build-module/components/list/added-by.js.map +1 -1
  67. package/build-module/components/list/table.js +3 -1
  68. package/build-module/components/list/table.js.map +1 -1
  69. package/build-module/components/save-button/index.js +5 -2
  70. package/build-module/components/save-button/index.js.map +1 -1
  71. package/build-module/components/sidebar/index.js +11 -4
  72. package/build-module/components/sidebar/index.js.map +1 -1
  73. package/build-module/components/sidebar-button/index.js +18 -0
  74. package/build-module/components/sidebar-button/index.js.map +1 -0
  75. package/build-module/components/sidebar-navigation-screen/index.js +4 -4
  76. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  77. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js +8 -5
  78. package/build-module/components/sidebar-navigation-screen-navigation-item/index.js.map +1 -1
  79. package/build-module/components/sidebar-navigation-screen-template/index.js +7 -5
  80. package/build-module/components/sidebar-navigation-screen-template/index.js.map +1 -1
  81. package/build-module/components/sidebar-navigation-screen-templates/index.js +14 -3
  82. package/build-module/components/sidebar-navigation-screen-templates/index.js.map +1 -1
  83. package/build-module/components/style-book/index.js +17 -3
  84. package/build-module/components/style-book/index.js.map +1 -1
  85. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +7 -7
  86. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  87. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +21 -25
  88. package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
  89. package/build-module/components/template-details/index.js +7 -8
  90. package/build-module/components/template-details/index.js.map +1 -1
  91. package/build-module/index.js +12 -22
  92. package/build-module/index.js.map +1 -1
  93. package/build-style/style-rtl.css +23 -30
  94. package/build-style/style.css +23 -30
  95. package/package.json +10 -10
  96. package/src/components/add-new-template/add-custom-template-modal.js +14 -10
  97. package/src/components/add-new-template/new-template-part.js +4 -3
  98. package/src/components/add-new-template/style.scss +0 -5
  99. package/src/components/block-editor/style.scss +1 -1
  100. package/src/components/editor/index.js +4 -3
  101. package/src/components/global-styles/screen-variations.js +0 -1
  102. package/src/components/global-styles/shadow-panel.js +4 -3
  103. package/src/components/keyboard-shortcuts/edit-mode.js +116 -0
  104. package/src/components/keyboard-shortcuts/global.js +35 -0
  105. package/src/components/keyboard-shortcuts/register.js +157 -0
  106. package/src/components/layout/index.js +4 -0
  107. package/src/components/list/added-by.js +48 -55
  108. package/src/components/list/style.scss +5 -13
  109. package/src/components/list/table.js +4 -1
  110. package/src/components/save-button/index.js +2 -2
  111. package/src/components/sidebar/index.js +10 -4
  112. package/src/components/sidebar-button/index.js +21 -0
  113. package/src/components/sidebar-button/style.scss +23 -0
  114. package/src/components/sidebar-navigation-screen/index.js +3 -4
  115. package/src/components/sidebar-navigation-screen/style.scss +1 -10
  116. package/src/components/sidebar-navigation-screen-navigation-item/index.js +7 -9
  117. package/src/components/sidebar-navigation-screen-template/index.js +6 -6
  118. package/src/components/sidebar-navigation-screen-templates/index.js +16 -4
  119. package/src/components/sidebar-navigation-screen-templates/style.scss +0 -5
  120. package/src/components/style-book/index.js +25 -1
  121. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +5 -9
  122. package/src/components/sync-state-with-url/use-sync-path-with-url.js +24 -30
  123. package/src/components/template-details/index.js +5 -6
  124. package/src/index.js +6 -21
  125. package/src/style.scss +1 -0
@@ -0,0 +1,157 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect } from '@wordpress/element';
5
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
6
+ import { isAppleOS } from '@wordpress/keycodes';
7
+ import { useDispatch } from '@wordpress/data';
8
+ import { __ } from '@wordpress/i18n';
9
+
10
+ function KeyboardShortcutsRegister() {
11
+ // Registering the shortcuts.
12
+ const { registerShortcut } = useDispatch( keyboardShortcutsStore );
13
+ useEffect( () => {
14
+ registerShortcut( {
15
+ name: 'core/edit-site/save',
16
+ category: 'global',
17
+ description: __( 'Save your changes.' ),
18
+ keyCombination: {
19
+ modifier: 'primary',
20
+ character: 's',
21
+ },
22
+ } );
23
+
24
+ registerShortcut( {
25
+ name: 'core/edit-site/undo',
26
+ category: 'global',
27
+ description: __( 'Undo your last changes.' ),
28
+ keyCombination: {
29
+ modifier: 'primary',
30
+ character: 'z',
31
+ },
32
+ } );
33
+
34
+ registerShortcut( {
35
+ name: 'core/edit-site/redo',
36
+ category: 'global',
37
+ description: __( 'Redo your last undo.' ),
38
+ keyCombination: {
39
+ modifier: 'primaryShift',
40
+ character: 'z',
41
+ },
42
+ // Disable on Apple OS because it conflicts with the browser's
43
+ // history shortcut. It's a fine alias for both Windows and Linux.
44
+ // Since there's no conflict for Ctrl+Shift+Z on both Windows and
45
+ // Linux, we keep it as the default for consistency.
46
+ aliases: isAppleOS()
47
+ ? []
48
+ : [
49
+ {
50
+ modifier: 'primary',
51
+ character: 'y',
52
+ },
53
+ ],
54
+ } );
55
+
56
+ registerShortcut( {
57
+ name: 'core/edit-site/toggle-list-view',
58
+ category: 'global',
59
+ description: __( 'Open the block list view.' ),
60
+ keyCombination: {
61
+ modifier: 'access',
62
+ character: 'o',
63
+ },
64
+ } );
65
+
66
+ registerShortcut( {
67
+ name: 'core/edit-site/toggle-block-settings-sidebar',
68
+ category: 'global',
69
+ description: __( 'Show or hide the block settings sidebar.' ),
70
+ keyCombination: {
71
+ modifier: 'primaryShift',
72
+ character: ',',
73
+ },
74
+ } );
75
+
76
+ registerShortcut( {
77
+ name: 'core/edit-site/keyboard-shortcuts',
78
+ category: 'main',
79
+ description: __( 'Display these keyboard shortcuts.' ),
80
+ keyCombination: {
81
+ modifier: 'access',
82
+ character: 'h',
83
+ },
84
+ } );
85
+
86
+ registerShortcut( {
87
+ name: 'core/edit-site/next-region',
88
+ category: 'global',
89
+ description: __( 'Navigate to the next part of the editor.' ),
90
+ keyCombination: {
91
+ modifier: 'ctrl',
92
+ character: '`',
93
+ },
94
+ aliases: [
95
+ {
96
+ modifier: 'access',
97
+ character: 'n',
98
+ },
99
+ ],
100
+ } );
101
+
102
+ registerShortcut( {
103
+ name: 'core/edit-site/previous-region',
104
+ category: 'global',
105
+ description: __( 'Navigate to the previous part of the editor.' ),
106
+ keyCombination: {
107
+ modifier: 'ctrlShift',
108
+ character: '`',
109
+ },
110
+ aliases: [
111
+ {
112
+ modifier: 'access',
113
+ character: 'p',
114
+ },
115
+ {
116
+ modifier: 'ctrlShift',
117
+ character: '~',
118
+ },
119
+ ],
120
+ } );
121
+ registerShortcut( {
122
+ name: 'core/edit-site/toggle-mode',
123
+ category: 'global',
124
+ description: __( 'Switch between visual editor and code editor.' ),
125
+ keyCombination: {
126
+ modifier: 'secondary',
127
+ character: 'm',
128
+ },
129
+ } );
130
+
131
+ registerShortcut( {
132
+ name: `core/edit-site/transform-heading-to-paragraph`,
133
+ category: 'block-library',
134
+ description: __( 'Transform heading to paragraph.' ),
135
+ keyCombination: {
136
+ modifier: 'access',
137
+ character: `0`,
138
+ },
139
+ } );
140
+
141
+ [ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {
142
+ registerShortcut( {
143
+ name: `core/edit-site/transform-paragraph-to-heading-${ level }`,
144
+ category: 'block-library',
145
+ description: __( 'Transform paragraph to heading.' ),
146
+ keyCombination: {
147
+ modifier: 'access',
148
+ character: `${ level }`,
149
+ },
150
+ } );
151
+ } );
152
+ }, [ registerShortcut ] );
153
+
154
+ return null;
155
+ }
156
+
157
+ export default KeyboardShortcutsRegister;
@@ -40,6 +40,8 @@ import ResizeHandle from '../block-editor/resize-handle';
40
40
  import useSyncCanvasModeWithURL from '../sync-state-with-url/use-sync-canvas-mode-with-url';
41
41
  import { unlock } from '../../private-apis';
42
42
  import SavePanel from '../save-panel';
43
+ import KeyboardShortcutsRegister from '../keyboard-shortcuts/register';
44
+ import KeyboardShortcutsGlobal from '../keyboard-shortcuts/global';
43
45
 
44
46
  const ANIMATION_DURATION = 0.5;
45
47
  const emptyResizeHandleStyles = {
@@ -121,6 +123,8 @@ export default function Layout() {
121
123
 
122
124
  return (
123
125
  <>
126
+ <KeyboardShortcutsRegister />
127
+ <KeyboardShortcutsGlobal />
124
128
  { fullResizer }
125
129
  <div
126
130
  { ...navigateRegionsProps }
@@ -6,11 +6,7 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import {
10
- __experimentalHStack as HStack,
11
- Icon,
12
- Tooltip,
13
- } from '@wordpress/components';
9
+ import { __experimentalHStack as HStack, Icon } from '@wordpress/components';
14
10
  import { store as coreStore } from '@wordpress/core-data';
15
11
  import { useSelect } from '@wordpress/data';
16
12
  import { useState } from '@wordpress/element';
@@ -20,62 +16,47 @@ import {
20
16
  plugins as pluginIcon,
21
17
  globe as globeIcon,
22
18
  } from '@wordpress/icons';
23
- import { __ } from '@wordpress/i18n';
19
+ import { _x } from '@wordpress/i18n';
24
20
 
25
21
  const TEMPLATE_POST_TYPE_NAMES = [ 'wp_template', 'wp_template_part' ];
26
22
 
27
- function CustomizedTooltip( { isCustomized, children } ) {
28
- if ( ! isCustomized ) {
29
- return children;
30
- }
31
-
32
- return (
33
- <Tooltip text={ __( 'This template has been customized' ) }>
34
- { children }
35
- </Tooltip>
36
- );
37
- }
38
-
39
- function BaseAddedBy( { text, icon, imageUrl, isCustomized } ) {
23
+ function BaseAddedBy( { text, icon, imageUrl, isCustomized, templateType } ) {
40
24
  const [ isImageLoaded, setIsImageLoaded ] = useState( false );
41
25
 
42
26
  return (
43
27
  <HStack alignment="left">
44
- <CustomizedTooltip isCustomized={ isCustomized }>
45
- { imageUrl ? (
46
- <div
47
- className={ classnames(
48
- 'edit-site-list-added-by__avatar',
49
- {
50
- 'is-loaded': isImageLoaded,
51
- }
52
- ) }
53
- >
54
- <img
55
- onLoad={ () => setIsImageLoaded( true ) }
56
- alt=""
57
- src={ imageUrl }
58
- />
59
- </div>
60
- ) : (
61
- <div
62
- className={ classnames(
63
- 'edit-site-list-added-by__icon',
64
- {
65
- 'is-customized': isCustomized,
66
- }
67
- ) }
68
- >
69
- <Icon icon={ icon } />
70
- </div>
28
+ { imageUrl ? (
29
+ <div
30
+ className={ classnames( 'edit-site-list-added-by__avatar', {
31
+ 'is-loaded': isImageLoaded,
32
+ } ) }
33
+ >
34
+ <img
35
+ onLoad={ () => setIsImageLoaded( true ) }
36
+ alt=""
37
+ src={ imageUrl }
38
+ />
39
+ </div>
40
+ ) : (
41
+ <div className="edit-site-list-added-by__icon">
42
+ <Icon icon={ icon } />
43
+ </div>
44
+ ) }
45
+ <span>
46
+ { text }
47
+ { isCustomized && (
48
+ <span className="edit-site-list-added-by__customized-info">
49
+ { templateType === 'wp_template'
50
+ ? _x( 'Customized', 'template' )
51
+ : _x( 'Customized', 'template part' ) }
52
+ </span>
71
53
  ) }
72
- </CustomizedTooltip>
73
- <span>{ text }</span>
54
+ </span>
74
55
  </HStack>
75
56
  );
76
57
  }
77
58
 
78
- function AddedByTheme( { slug, isCustomized } ) {
59
+ function AddedByTheme( { slug, isCustomized, templateType } ) {
79
60
  const theme = useSelect(
80
61
  ( select ) => select( coreStore ).getTheme( slug ),
81
62
  [ slug ]
@@ -86,11 +67,12 @@ function AddedByTheme( { slug, isCustomized } ) {
86
67
  icon={ themeIcon }
87
68
  text={ theme?.name?.rendered || slug }
88
69
  isCustomized={ isCustomized }
70
+ templateType={ templateType }
89
71
  />
90
72
  );
91
73
  }
92
74
 
93
- function AddedByPlugin( { slug, isCustomized } ) {
75
+ function AddedByPlugin( { slug, isCustomized, templateType } ) {
94
76
  const plugin = useSelect(
95
77
  ( select ) => select( coreStore ).getPlugin( slug ),
96
78
  [ slug ]
@@ -101,11 +83,12 @@ function AddedByPlugin( { slug, isCustomized } ) {
101
83
  icon={ pluginIcon }
102
84
  text={ plugin?.name || slug }
103
85
  isCustomized={ isCustomized }
86
+ templateType={ templateType }
104
87
  />
105
88
  );
106
89
  }
107
90
 
108
- function AddedByAuthor( { id } ) {
91
+ function AddedByAuthor( { id, templateType } ) {
109
92
  const user = useSelect(
110
93
  ( select ) => select( coreStore ).getUser( id ),
111
94
  [ id ]
@@ -116,11 +99,12 @@ function AddedByAuthor( { id } ) {
116
99
  icon={ authorIcon }
117
100
  imageUrl={ user?.avatar_urls?.[ 48 ] }
118
101
  text={ user?.nickname }
102
+ templateType={ templateType }
119
103
  />
120
104
  );
121
105
  }
122
106
 
123
- function AddedBySite() {
107
+ function AddedBySite( { templateType } ) {
124
108
  const { name, logoURL } = useSelect( ( select ) => {
125
109
  const { getEntityRecord, getMedia } = select( coreStore );
126
110
  const siteData = getEntityRecord( 'root', '__unstableBase' );
@@ -134,7 +118,12 @@ function AddedBySite() {
134
118
  }, [] );
135
119
 
136
120
  return (
137
- <BaseAddedBy icon={ globeIcon } imageUrl={ logoURL } text={ name } />
121
+ <BaseAddedBy
122
+ icon={ globeIcon }
123
+ imageUrl={ logoURL }
124
+ text={ name }
125
+ templateType={ templateType }
126
+ />
138
127
  );
139
128
  }
140
129
 
@@ -158,6 +147,7 @@ export default function AddedBy( { templateType, template } ) {
158
147
  <AddedByTheme
159
148
  slug={ template.theme }
160
149
  isCustomized={ template.source === 'custom' }
150
+ templateType={ templateType }
161
151
  />
162
152
  );
163
153
  }
@@ -168,6 +158,7 @@ export default function AddedBy( { templateType, template } ) {
168
158
  <AddedByPlugin
169
159
  slug={ template.theme }
170
160
  isCustomized={ template.source === 'custom' }
161
+ templateType={ templateType }
171
162
  />
172
163
  );
173
164
  }
@@ -180,11 +171,13 @@ export default function AddedBy( { templateType, template } ) {
180
171
  template.source === 'custom' &&
181
172
  ! template.author
182
173
  ) {
183
- return <AddedBySite />;
174
+ return <AddedBySite templateType={ templateType } />;
184
175
  }
185
176
  }
186
177
 
187
178
  // Simply show the author for templates created from scratch that have an
188
179
  // author or for any other post type.
189
- return <AddedByAuthor id={ template.author } />;
180
+ return (
181
+ <AddedByAuthor id={ template.author } templateType={ templateType } />
182
+ );
190
183
  }
@@ -141,7 +141,6 @@
141
141
  .edit-site-list-added-by__icon {
142
142
  display: flex;
143
143
  flex-shrink: 0;
144
- position: relative;
145
144
  align-items: center;
146
145
  justify-content: center;
147
146
  width: $grid-unit-40;
@@ -152,18 +151,6 @@
152
151
  svg {
153
152
  fill: $white;
154
153
  }
155
-
156
- &.is-customized::after {
157
- position: absolute;
158
- content: "";
159
- background: var(--wp-admin-theme-color);
160
- height: $grid-unit-10;
161
- width: $grid-unit-10;
162
- outline: 2px solid $white;
163
- border-radius: 100%;
164
- top: -1px;
165
- right: -1px;
166
- }
167
154
  }
168
155
 
169
156
  .edit-site-list-added-by__avatar {
@@ -189,3 +176,8 @@
189
176
  }
190
177
  }
191
178
  }
179
+
180
+ .edit-site-list-added-by__customized-info {
181
+ display: block;
182
+ color: $gray-700;
183
+ }
@@ -46,6 +46,9 @@ export default function Table( { templateType } ) {
46
46
  );
47
47
  }
48
48
 
49
+ const sortedTemplates = [ ...templates ];
50
+ sortedTemplates.sort( ( a, b ) => a.slug.localeCompare( b.slug ) );
51
+
49
52
  return (
50
53
  // These explicit aria roles are needed for Safari.
51
54
  // See https://developer.mozilla.org/en-US/docs/Web/CSS/display#tables
@@ -74,7 +77,7 @@ export default function Table( { templateType } ) {
74
77
  </thead>
75
78
 
76
79
  <tbody>
77
- { templates.map( ( template ) => (
80
+ { sortedTemplates.map( ( template ) => (
78
81
  <tr
79
82
  key={ template.id }
80
83
  className="edit-site-list-table-row"
@@ -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,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { memo } from '@wordpress/element';
4
+ import { memo, useRef } from '@wordpress/element';
5
5
  import {
6
6
  __experimentalNavigatorProvider as NavigatorProvider,
7
7
  __experimentalNavigatorScreen as NavigatorScreen,
@@ -13,11 +13,14 @@ import {
13
13
  import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main';
14
14
  import SidebarNavigationScreenTemplates from '../sidebar-navigation-screen-templates';
15
15
  import SidebarNavigationScreenTemplate from '../sidebar-navigation-screen-template';
16
- 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';
17
19
  import SidebarNavigationScreenNavigationMenus from '../sidebar-navigation-screen-navigation-menus';
18
20
  import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen-templates-browse';
19
21
  import SaveButton from '../save-button';
20
22
  import SidebarNavigationScreenNavigationItem from '../sidebar-navigation-screen-navigation-item';
23
+ import { useLocation } from '../routes';
21
24
 
22
25
  function SidebarScreens() {
23
26
  useSyncPathWithURL();
@@ -47,17 +50,20 @@ function SidebarScreens() {
47
50
  }
48
51
 
49
52
  function Sidebar() {
53
+ const { params: urlParams } = useLocation();
54
+ const initialPath = useRef( getPathFromURL( urlParams ) );
55
+
50
56
  return (
51
57
  <>
52
58
  <NavigatorProvider
53
59
  className="edit-site-sidebar__content"
54
- initialPath="/"
60
+ initialPath={ initialPath.current }
55
61
  >
56
62
  <SidebarScreens />
57
63
  </NavigatorProvider>
58
64
 
59
65
  <div className="edit-site-sidebar__footer">
60
- <SaveButton />
66
+ <SaveButton showTooltip={ false } />
61
67
  </div>
62
68
  </>
63
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
+ }
@@ -5,7 +5,6 @@ import {
5
5
  __experimentalHStack as HStack,
6
6
  __experimentalVStack as VStack,
7
7
  __experimentalNavigatorToParentButton as NavigatorToParentButton,
8
- Button,
9
8
  } from '@wordpress/components';
10
9
  import { isRTL, __ } from '@wordpress/i18n';
11
10
  import { chevronRight, chevronLeft } from '@wordpress/icons';
@@ -16,6 +15,7 @@ import { useSelect } from '@wordpress/data';
16
15
  */
17
16
  import { store as editSiteStore } from '../../store';
18
17
  import { unlock } from '../../private-apis';
18
+ import SidebarButton from '../sidebar-button';
19
19
 
20
20
  export default function SidebarNavigationScreen( {
21
21
  isRoot,
@@ -39,13 +39,12 @@ export default function SidebarNavigationScreen( {
39
39
  >
40
40
  { ! isRoot ? (
41
41
  <NavigatorToParentButton
42
- className="edit-site-sidebar-navigation-screen__back"
42
+ as={ SidebarButton }
43
43
  icon={ isRTL() ? chevronRight : chevronLeft }
44
44
  aria-label={ __( 'Back' ) }
45
45
  />
46
46
  ) : (
47
- <Button
48
- className="edit-site-sidebar-navigation-screen__back"
47
+ <SidebarButton
49
48
  icon={ isRTL() ? chevronRight : chevronLeft }
50
49
  aria-label={ __( 'Navigate to the Dashboard' ) }
51
50
  href={ dashboardLink || 'index.php' }
@@ -23,18 +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
- &:focus,
37
- &:not([aria-disabled="true"]):active {
38
- color: $white;
39
- }
40
- }
@@ -3,12 +3,10 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { useDispatch, useSelect } from '@wordpress/data';
6
- import {
7
- Button,
8
- __experimentalUseNavigator as useNavigator,
9
- } from '@wordpress/components';
6
+ import { __experimentalUseNavigator as useNavigator } from '@wordpress/components';
10
7
  import { store as coreStore } from '@wordpress/core-data';
11
8
  import { decodeEntities } from '@wordpress/html-entities';
9
+ import { pencil } from '@wordpress/icons';
12
10
 
13
11
  /**
14
12
  * Internal dependencies
@@ -16,6 +14,7 @@ import { decodeEntities } from '@wordpress/html-entities';
16
14
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
17
15
  import { unlock } from '../../private-apis';
18
16
  import { store as editSiteStore } from '../../store';
17
+ import SidebarButton from '../sidebar-button';
19
18
 
20
19
  export default function SidebarNavigationScreenNavigationItem() {
21
20
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
@@ -43,12 +42,11 @@ export default function SidebarNavigationScreenNavigationItem() {
43
42
  <SidebarNavigationScreen
44
43
  title={ post ? decodeEntities( post?.title?.rendered ) : null }
45
44
  actions={
46
- <Button
47
- variant="primary"
45
+ <SidebarButton
48
46
  onClick={ () => setCanvasMode( 'edit' ) }
49
- >
50
- { __( 'Edit' ) }
51
- </Button>
47
+ label={ __( 'Edit' ) }
48
+ icon={ pencil }
49
+ />
52
50
  }
53
51
  content={
54
52
  post ? decodeEntities( post?.description?.rendered ) : null
@@ -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,6 +12,7 @@ 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
17
  export default function SidebarNavigationScreenTemplate() {
17
18
  const { setCanvasMode } = unlock( useDispatch( editSiteStore ) );
@@ -27,12 +28,11 @@ export default function SidebarNavigationScreenTemplate() {
27
28
  <SidebarNavigationScreen
28
29
  title={ getTitle() }
29
30
  actions={
30
- <Button
31
- variant="primary"
31
+ <SidebarButton
32
32
  onClick={ () => setCanvasMode( 'edit' ) }
33
- >
34
- { __( 'Edit' ) }
35
- </Button>
33
+ label={ __( 'Edit' ) }
34
+ icon={ pencil }
35
+ />
36
36
  }
37
37
  content={ description ? <p>{ description }</p> : undefined }
38
38
  />