@wordpress/edit-site 6.11.0 → 6.12.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 (190) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/app/index.js +0 -2
  3. package/build/components/app/index.js.map +1 -1
  4. package/build/components/block-editor/use-editor-iframe-props.js +6 -8
  5. package/build/components/block-editor/use-editor-iframe-props.js.map +1 -1
  6. package/build/components/editor/index.js +9 -4
  7. package/build/components/editor/index.js.map +1 -1
  8. package/build/components/editor/use-editor-title.js +29 -12
  9. package/build/components/editor/use-editor-title.js.map +1 -1
  10. package/build/components/global-styles/screen-revisions/revisions-buttons.js +24 -22
  11. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  12. package/build/components/global-styles/shadows-edit-panel.js +2 -3
  13. package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
  14. package/build/components/global-styles/ui.js +42 -2
  15. package/build/components/global-styles/ui.js.map +1 -1
  16. package/build/components/global-styles-renderer/index.js +6 -8
  17. package/build/components/global-styles-renderer/index.js.map +1 -1
  18. package/build/components/layout/hooks.js +1 -10
  19. package/build/components/layout/hooks.js.map +1 -1
  20. package/build/components/layout/index.js +1 -0
  21. package/build/components/layout/index.js.map +1 -1
  22. package/build/components/page-patterns/fields.js +3 -7
  23. package/build/components/page-patterns/fields.js.map +1 -1
  24. package/build/components/page-templates/fields.js +1 -2
  25. package/build/components/page-templates/fields.js.map +1 -1
  26. package/build/components/post-edit/index.js +14 -8
  27. package/build/components/post-edit/index.js.map +1 -1
  28. package/build/components/post-fields/index.js +3 -197
  29. package/build/components/post-fields/index.js.map +1 -1
  30. package/build/components/post-list/index.js +11 -1
  31. package/build/components/post-list/index.js.map +1 -1
  32. package/build/components/sidebar/index.js +11 -3
  33. package/build/components/sidebar/index.js.map +1 -1
  34. package/build/components/sidebar-global-styles-wrapper/index.js +129 -0
  35. package/build/components/sidebar-global-styles-wrapper/index.js.map +1 -0
  36. package/build/components/sidebar-navigation-screen-global-styles/index.js +14 -72
  37. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  38. package/build/components/sidebar-navigation-screen-main/index.js +43 -42
  39. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  40. package/build/components/site-editor-routes/styles-edit.js +6 -1
  41. package/build/components/site-editor-routes/styles-edit.js.map +1 -1
  42. package/build/components/site-editor-routes/styles-view.js +8 -2
  43. package/build/components/site-editor-routes/styles-view.js.map +1 -1
  44. package/build/components/site-hub/index.js +19 -6
  45. package/build/components/site-hub/index.js.map +1 -1
  46. package/build/components/style-book/constants.js +10 -3
  47. package/build/components/style-book/constants.js.map +1 -1
  48. package/build/components/style-book/examples.js +71 -1
  49. package/build/components/style-book/examples.js.map +1 -1
  50. package/build/components/style-book/index.js +70 -11
  51. package/build/components/style-book/index.js.map +1 -1
  52. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
  53. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  54. package/build/components/welcome-guide/index.js +4 -2
  55. package/build/components/welcome-guide/index.js.map +1 -1
  56. package/build/components/welcome-guide/page.js +1 -9
  57. package/build/components/welcome-guide/page.js.map +1 -1
  58. package/build/components/welcome-guide/template.js +1 -12
  59. package/build/components/welcome-guide/template.js.map +1 -1
  60. package/build/hooks/commands/use-common-commands.js +15 -15
  61. package/build/hooks/commands/use-common-commands.js.map +1 -1
  62. package/build/index.js +1 -0
  63. package/build/index.js.map +1 -1
  64. package/build/posts.js +1 -0
  65. package/build/posts.js.map +1 -1
  66. package/build-module/components/app/index.js +0 -2
  67. package/build-module/components/app/index.js.map +1 -1
  68. package/build-module/components/block-editor/use-editor-iframe-props.js +6 -8
  69. package/build-module/components/block-editor/use-editor-iframe-props.js.map +1 -1
  70. package/build-module/components/editor/index.js +9 -4
  71. package/build-module/components/editor/index.js.map +1 -1
  72. package/build-module/components/editor/use-editor-title.js +29 -12
  73. package/build-module/components/editor/use-editor-title.js.map +1 -1
  74. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +25 -23
  75. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  76. package/build-module/components/global-styles/shadows-edit-panel.js +2 -3
  77. package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
  78. package/build-module/components/global-styles/ui.js +43 -3
  79. package/build-module/components/global-styles/ui.js.map +1 -1
  80. package/build-module/components/global-styles-renderer/index.js +6 -8
  81. package/build-module/components/global-styles-renderer/index.js.map +1 -1
  82. package/build-module/components/layout/hooks.js +1 -9
  83. package/build-module/components/layout/hooks.js.map +1 -1
  84. package/build-module/components/layout/index.js +1 -0
  85. package/build-module/components/layout/index.js.map +1 -1
  86. package/build-module/components/page-patterns/fields.js +4 -8
  87. package/build-module/components/page-patterns/fields.js.map +1 -1
  88. package/build-module/components/page-templates/fields.js +1 -2
  89. package/build-module/components/page-templates/fields.js.map +1 -1
  90. package/build-module/components/post-edit/index.js +14 -8
  91. package/build-module/components/post-edit/index.js.map +1 -1
  92. package/build-module/components/post-fields/index.js +7 -202
  93. package/build-module/components/post-fields/index.js.map +1 -1
  94. package/build-module/components/post-list/index.js +11 -1
  95. package/build-module/components/post-list/index.js.map +1 -1
  96. package/build-module/components/sidebar/index.js +11 -3
  97. package/build-module/components/sidebar/index.js.map +1 -1
  98. package/build-module/components/sidebar-global-styles-wrapper/index.js +121 -0
  99. package/build-module/components/sidebar-global-styles-wrapper/index.js.map +1 -0
  100. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +15 -73
  101. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  102. package/build-module/components/sidebar-navigation-screen-main/index.js +43 -43
  103. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  104. package/build-module/components/site-editor-routes/styles-edit.js +6 -1
  105. package/build-module/components/site-editor-routes/styles-edit.js.map +1 -1
  106. package/build-module/components/site-editor-routes/styles-view.js +8 -2
  107. package/build-module/components/site-editor-routes/styles-view.js.map +1 -1
  108. package/build-module/components/site-hub/index.js +19 -6
  109. package/build-module/components/site-hub/index.js.map +1 -1
  110. package/build-module/components/style-book/constants.js +10 -3
  111. package/build-module/components/style-book/constants.js.map +1 -1
  112. package/build-module/components/style-book/examples.js +71 -1
  113. package/build-module/components/style-book/examples.js.map +1 -1
  114. package/build-module/components/style-book/index.js +71 -12
  115. package/build-module/components/style-book/index.js.map +1 -1
  116. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +32 -32
  117. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  118. package/build-module/components/welcome-guide/index.js +4 -2
  119. package/build-module/components/welcome-guide/index.js.map +1 -1
  120. package/build-module/components/welcome-guide/page.js +1 -9
  121. package/build-module/components/welcome-guide/page.js.map +1 -1
  122. package/build-module/components/welcome-guide/template.js +1 -11
  123. package/build-module/components/welcome-guide/template.js.map +1 -1
  124. package/build-module/hooks/commands/use-common-commands.js +15 -15
  125. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  126. package/build-module/index.js +1 -0
  127. package/build-module/index.js.map +1 -1
  128. package/build-module/posts.js +1 -0
  129. package/build-module/posts.js.map +1 -1
  130. package/build-style/posts-rtl.css +54 -5
  131. package/build-style/posts.css +54 -5
  132. package/build-style/style-rtl.css +109 -28
  133. package/build-style/style.css +109 -28
  134. package/package.json +3 -4
  135. package/src/components/app/index.js +0 -2
  136. package/src/components/block-editor/use-editor-iframe-props.js +2 -3
  137. package/src/components/editor/index.js +16 -4
  138. package/src/components/editor/use-editor-title.js +37 -13
  139. package/src/components/editor-canvas-container/style.scss +0 -1
  140. package/src/components/global-styles/screen-revisions/revisions-buttons.js +28 -31
  141. package/src/components/global-styles/screen-revisions/style.scss +11 -17
  142. package/src/components/global-styles/shadows-edit-panel.js +4 -2
  143. package/src/components/global-styles/ui.js +42 -2
  144. package/src/components/global-styles-renderer/index.js +4 -10
  145. package/src/components/layout/hooks.js +1 -7
  146. package/src/components/layout/index.js +6 -1
  147. package/src/components/page-patterns/fields.js +6 -12
  148. package/src/components/page-patterns/style.scss +0 -5
  149. package/src/components/page-templates/fields.js +2 -3
  150. package/src/components/post-edit/index.js +38 -30
  151. package/src/components/post-edit/style.scss +7 -0
  152. package/src/components/post-fields/index.js +19 -273
  153. package/src/components/post-list/index.js +9 -3
  154. package/src/components/post-list/style.scss +29 -3
  155. package/src/components/sidebar/index.js +23 -7
  156. package/src/components/sidebar-global-styles-wrapper/index.js +150 -0
  157. package/src/components/sidebar-global-styles-wrapper/style.scss +35 -0
  158. package/src/components/sidebar-navigation-item/style.scss +2 -2
  159. package/src/components/sidebar-navigation-screen-global-styles/index.js +13 -88
  160. package/src/components/sidebar-navigation-screen-main/index.js +46 -45
  161. package/src/components/site-editor-routes/styles-edit.js +10 -1
  162. package/src/components/site-editor-routes/styles-view.js +11 -1
  163. package/src/components/site-hub/index.js +33 -16
  164. package/src/components/site-icon/style.scss +16 -0
  165. package/src/components/style-book/constants.ts +11 -3
  166. package/src/components/style-book/examples.tsx +105 -1
  167. package/src/components/style-book/index.js +86 -8
  168. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +54 -64
  169. package/src/components/welcome-guide/index.js +3 -3
  170. package/src/components/welcome-guide/page.js +1 -7
  171. package/src/components/welcome-guide/template.js +1 -8
  172. package/src/hooks/commands/use-common-commands.js +253 -246
  173. package/src/index.js +1 -0
  174. package/src/posts.js +1 -0
  175. package/src/style.scss +2 -3
  176. package/build/components/async/index.js +0 -51
  177. package/build/components/async/index.js.map +0 -1
  178. package/build/components/use-edited-entity-record/index.js +0 -60
  179. package/build/components/use-edited-entity-record/index.js.map +0 -1
  180. package/build/hooks/commands/use-edit-mode-commands.js +0 -179
  181. package/build/hooks/commands/use-edit-mode-commands.js.map +0 -1
  182. package/build-module/components/async/index.js +0 -44
  183. package/build-module/components/async/index.js.map +0 -1
  184. package/build-module/components/use-edited-entity-record/index.js +0 -53
  185. package/build-module/components/use-edited-entity-record/index.js.map +0 -1
  186. package/build-module/hooks/commands/use-edit-mode-commands.js +0 -171
  187. package/build-module/hooks/commands/use-edit-mode-commands.js.map +0 -1
  188. package/src/components/async/index.js +0 -43
  189. package/src/components/use-edited-entity-record/index.js +0 -58
  190. package/src/hooks/commands/use-edit-mode-commands.js +0 -168
@@ -9,7 +9,9 @@
9
9
  width: 100%;
10
10
  border-radius: $grid-unit-05;
11
11
 
12
- &.is-layout-table:not(:has(.edit-site-post-list__featured-image-button)),
12
+ &.is-layout-table:not(
13
+ :has(.edit-site-post-list__featured-image-button)
14
+ ),
13
15
  &.is-layout-table .edit-site-post-list__featured-image-button {
14
16
  width: $grid-unit-40;
15
17
  height: $grid-unit-40;
@@ -46,7 +48,9 @@
46
48
  border-radius: $grid-unit-05;
47
49
 
48
50
  &:focus-visible {
49
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
51
+ box-shadow:
52
+ 0 0 0 var(--wp-admin-border-width-focus)
53
+ var(--wp-admin-theme-color);
50
54
  // Windows High Contrast mode will show this outline, but not the box-shadow.
51
55
  outline: 2px solid transparent;
52
56
  }
@@ -54,7 +58,9 @@
54
58
 
55
59
  .dataviews-view-grid__card.is-selected {
56
60
  .edit-site-post-list__featured-image-button::after {
57
- box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
61
+ box-shadow:
62
+ inset 0 0 0 var(--wp-admin-border-width-focus)
63
+ var(--wp-admin-theme-color);
58
64
  background: rgba(var(--wp-admin-theme-color--rgb), 0.04);
59
65
  }
60
66
  }
@@ -64,6 +70,26 @@
64
70
  overflow: hidden;
65
71
  }
66
72
 
73
+ .dataviews-view-grid__primary-field.dataviews-view-grid__primary-field--clickable
74
+ .edit-site-post-list__title
75
+ span,
76
+ .dataviews-view-table__primary-field > .dataviews-view-table__cell-content--clickable
77
+ .edit-site-post-list__title
78
+ span {
79
+ text-decoration: none;
80
+ text-overflow: ellipsis;
81
+ white-space: nowrap;
82
+ overflow: hidden;
83
+ display: block;
84
+ flex-grow: 0;
85
+ color: $gray-900;
86
+
87
+ &:hover {
88
+ color: var(--wp-admin-theme-color);
89
+ }
90
+ @include link-reset();
91
+ }
92
+
67
93
  .edit-site-post-list__title-badge {
68
94
  background: $gray-100;
69
95
  color: $gray-800;
@@ -55,7 +55,7 @@ function createNavState() {
55
55
  };
56
56
  }
57
57
 
58
- function SidebarContentWrapper( { children } ) {
58
+ function SidebarContentWrapper( { children, shouldAnimate } ) {
59
59
  const navState = useContext( SidebarNavigationContext );
60
60
  const wrapperRef = useRef();
61
61
  const [ navAnimation, setNavAnimation ] = useState( null );
@@ -66,10 +66,19 @@ function SidebarContentWrapper( { children } ) {
66
66
  setNavAnimation( direction );
67
67
  }, [ navState ] );
68
68
 
69
- const wrapperCls = clsx( 'edit-site-sidebar__screen-wrapper', {
70
- 'slide-from-left': navAnimation === 'back',
71
- 'slide-from-right': navAnimation === 'forward',
72
- } );
69
+ const wrapperCls = clsx(
70
+ 'edit-site-sidebar__screen-wrapper',
71
+ /*
72
+ * Some panes do not have sub-panes and therefore
73
+ * should not animate when clicked on.
74
+ */
75
+ shouldAnimate
76
+ ? {
77
+ 'slide-from-left': navAnimation === 'back',
78
+ 'slide-from-right': navAnimation === 'forward',
79
+ }
80
+ : {}
81
+ );
73
82
 
74
83
  return (
75
84
  <div ref={ wrapperRef } className={ wrapperCls }>
@@ -78,13 +87,20 @@ function SidebarContentWrapper( { children } ) {
78
87
  );
79
88
  }
80
89
 
81
- export default function SidebarContent( { routeKey, children } ) {
90
+ export default function SidebarContent( {
91
+ routeKey,
92
+ shouldAnimate,
93
+ children,
94
+ } ) {
82
95
  const [ navState ] = useState( createNavState );
83
96
 
84
97
  return (
85
98
  <SidebarNavigationContext.Provider value={ navState }>
86
99
  <div className="edit-site-sidebar__content">
87
- <SidebarContentWrapper key={ routeKey }>
100
+ <SidebarContentWrapper
101
+ shouldAnimate={ shouldAnimate }
102
+ key={ routeKey }
103
+ >
88
104
  { children }
89
105
  </SidebarContentWrapper>
90
106
  </div>
@@ -0,0 +1,150 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { useMemo, useState } from '@wordpress/element';
6
+ import { privateApis as routerPrivateApis } from '@wordpress/router';
7
+ import { useViewportMatch } from '@wordpress/compose';
8
+ import {
9
+ Button,
10
+ privateApis as componentsPrivateApis,
11
+ } from '@wordpress/components';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import GlobalStylesUI from '../global-styles/ui';
17
+ import Page from '../page';
18
+ import { unlock } from '../../lock-unlock';
19
+ import StyleBook from '../style-book';
20
+ import { STYLE_BOOK_COLOR_GROUPS } from '../style-book/constants';
21
+
22
+ const { useLocation, useHistory } = unlock( routerPrivateApis );
23
+ const { Menu } = unlock( componentsPrivateApis );
24
+ const GLOBAL_STYLES_PATH_PREFIX = '/wp_global_styles';
25
+
26
+ const GlobalStylesPageActions = ( {
27
+ isStyleBookOpened,
28
+ setIsStyleBookOpened,
29
+ } ) => {
30
+ return (
31
+ <Menu
32
+ trigger={
33
+ <Button __next40pxDefaultSize variant="tertiary" size="compact">
34
+ { __( 'Preview' ) }
35
+ </Button>
36
+ }
37
+ >
38
+ <Menu.RadioItem
39
+ value
40
+ checked={ isStyleBookOpened }
41
+ name="styles-preview-actions"
42
+ onChange={ () => setIsStyleBookOpened( true ) }
43
+ defaultChecked
44
+ >
45
+ <Menu.ItemLabel>{ __( 'Style book' ) }</Menu.ItemLabel>
46
+ <Menu.ItemHelpText>
47
+ { __( 'Preview blocks and styles.' ) }
48
+ </Menu.ItemHelpText>
49
+ </Menu.RadioItem>
50
+ <Menu.RadioItem
51
+ value={ false }
52
+ checked={ ! isStyleBookOpened }
53
+ name="styles-preview-actions"
54
+ onChange={ () => setIsStyleBookOpened( false ) }
55
+ >
56
+ <Menu.ItemLabel>{ __( 'Site' ) }</Menu.ItemLabel>
57
+ <Menu.ItemHelpText>
58
+ { __( 'Preview your site.' ) }
59
+ </Menu.ItemHelpText>
60
+ </Menu.RadioItem>
61
+ </Menu>
62
+ );
63
+ };
64
+
65
+ export default function GlobalStylesUIWrapper() {
66
+ const { params } = useLocation();
67
+ const history = useHistory();
68
+ const { canvas = 'view' } = params;
69
+ const [ isStyleBookOpened, setIsStyleBookOpened ] = useState( false );
70
+ const isMobileViewport = useViewportMatch( 'medium', '<' );
71
+ const pathWithPrefix = params.path;
72
+ const [ path, onPathChange ] = useMemo( () => {
73
+ const processedPath = pathWithPrefix.substring(
74
+ GLOBAL_STYLES_PATH_PREFIX.length
75
+ );
76
+ return [
77
+ processedPath ? processedPath : '/',
78
+ ( newPath ) => {
79
+ history.push( {
80
+ path:
81
+ ! newPath || newPath === '/'
82
+ ? GLOBAL_STYLES_PATH_PREFIX
83
+ : `${ GLOBAL_STYLES_PATH_PREFIX }${ newPath }`,
84
+ } );
85
+ },
86
+ ];
87
+ }, [ pathWithPrefix, history ] );
88
+
89
+ return (
90
+ <>
91
+ <Page
92
+ actions={
93
+ ! isMobileViewport ? (
94
+ <GlobalStylesPageActions
95
+ isStyleBookOpened={ isStyleBookOpened }
96
+ setIsStyleBookOpened={ setIsStyleBookOpened }
97
+ />
98
+ ) : null
99
+ }
100
+ className="edit-site-styles"
101
+ title={ __( 'Styles' ) }
102
+ >
103
+ <GlobalStylesUI path={ path } onPathChange={ onPathChange } />
104
+ </Page>
105
+ { canvas === 'view' && isStyleBookOpened && (
106
+ <StyleBook
107
+ enableResizing={ false }
108
+ showCloseButton={ false }
109
+ showTabs={ false }
110
+ isSelected={ ( blockName ) =>
111
+ // Match '/blocks/core%2Fbutton' and
112
+ // '/blocks/core%2Fbutton/typography', but not
113
+ // '/blocks/core%2Fbuttons'.
114
+ path ===
115
+ `/wp_global_styles/blocks/${ encodeURIComponent(
116
+ blockName
117
+ ) }` ||
118
+ path.startsWith(
119
+ `/wp_global_styles/blocks/${ encodeURIComponent(
120
+ blockName
121
+ ) }/`
122
+ )
123
+ }
124
+ path={ path }
125
+ onSelect={ ( blockName ) => {
126
+ if (
127
+ STYLE_BOOK_COLOR_GROUPS.find(
128
+ ( group ) => group.slug === blockName
129
+ )
130
+ ) {
131
+ // Go to color palettes Global Styles.
132
+ onPathChange( '/colors/palette' );
133
+ return;
134
+ }
135
+ if ( blockName === 'typography' ) {
136
+ // Go to typography Global Styles.
137
+ onPathChange( '/typography' );
138
+ return;
139
+ }
140
+
141
+ // Now go to the selected block.
142
+ onPathChange(
143
+ `/blocks/${ encodeURIComponent( blockName ) }`
144
+ );
145
+ } }
146
+ />
147
+ ) }
148
+ </>
149
+ );
150
+ }
@@ -0,0 +1,35 @@
1
+ .edit-site-styles .edit-site-page-content {
2
+ .edit-site-global-styles-screen-root {
3
+ box-shadow: none;
4
+ & > div > hr {
5
+ display: none;
6
+ }
7
+ }
8
+ .edit-site-global-styles-sidebar__navigator-provider {
9
+ .components-tools-panel {
10
+ border-top: none;
11
+ }
12
+ overflow-y: auto;
13
+ padding-left: 0;
14
+ padding-right: 0;
15
+
16
+ .edit-site-global-styles-sidebar__navigator-screen {
17
+ padding-top: $grid-unit-15;
18
+ padding-left: $grid-unit-15;
19
+ padding-right: $grid-unit-15;
20
+ padding-bottom: $grid-unit-15;
21
+ outline: none;
22
+ }
23
+ }
24
+ .edit-site-page-header {
25
+ padding-left: $grid-unit-60;
26
+ padding-right: $grid-unit-60;
27
+ @container (max-width: 430px) {
28
+ padding-left: $grid-unit-30;
29
+ padding-right: $grid-unit-30;
30
+ }
31
+ }
32
+ .edit-site-sidebar-button {
33
+ color: $gray-900;
34
+ }
35
+ }
@@ -7,7 +7,7 @@
7
7
 
8
8
  &:hover,
9
9
  &:focus,
10
- &[aria-current] {
10
+ &[aria-current="true"] {
11
11
  color: $gray-200;
12
12
  background: $gray-800;
13
13
 
@@ -16,7 +16,7 @@
16
16
  }
17
17
  }
18
18
 
19
- &[aria-current] {
19
+ &[aria-current="true"] {
20
20
  background: var(--wp-admin-theme-color);
21
21
  color: $white;
22
22
  }
@@ -2,12 +2,9 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { edit, seen } from '@wordpress/icons';
6
5
  import { useSelect, useDispatch } from '@wordpress/data';
7
6
  import { store as coreStore } from '@wordpress/core-data';
8
- import { useViewportMatch } from '@wordpress/compose';
9
7
  import { useCallback } from '@wordpress/element';
10
- import { store as editorStore } from '@wordpress/editor';
11
8
  import { store as preferencesStore } from '@wordpress/preferences';
12
9
  import { privateApis as routerPrivateApis } from '@wordpress/router';
13
10
 
@@ -17,18 +14,14 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
17
14
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
18
15
  import { unlock } from '../../lock-unlock';
19
16
  import { store as editSiteStore } from '../../store';
20
- import SidebarButton from '../sidebar-button';
21
17
  import SidebarNavigationItem from '../sidebar-navigation-item';
22
- import StyleBook from '../style-book';
23
18
  import useGlobalStylesRevisions from '../global-styles/screen-revisions/use-global-styles-revisions';
24
19
  import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer';
25
- import SidebarNavigationScreenGlobalStylesContent from './content';
20
+ import { MainSidebarNavigationContent } from '../sidebar-navigation-screen-main';
26
21
 
27
22
  const { useLocation, useHistory } = unlock( routerPrivateApis );
28
23
 
29
24
  export function SidebarNavigationItemGlobalStyles( props ) {
30
- const { openGeneralSidebar } = useDispatch( editSiteStore );
31
- const history = useHistory();
32
25
  const { params } = useLocation();
33
26
  const hasGlobalStyleVariations = useSelect(
34
27
  ( select ) =>
@@ -43,47 +36,25 @@ export function SidebarNavigationItemGlobalStyles( props ) {
43
36
  { ...props }
44
37
  params={ { path: '/wp_global_styles' } }
45
38
  uid="global-styles-navigation-item"
39
+ aria-current={
40
+ params.path && params.path.startsWith( '/wp_global_styles' )
41
+ }
46
42
  />
47
43
  );
48
44
  }
49
- return (
50
- <SidebarNavigationItem
51
- { ...props }
52
- onClick={ () => {
53
- // Switch to edit mode.
54
- history.push(
55
- {
56
- ...params,
57
- canvas: 'edit',
58
- },
59
- undefined,
60
- {
61
- transition: 'canvas-mode-edit-transition',
62
- }
63
- );
64
- // Open global styles sidebar.
65
- openGeneralSidebar( 'edit-site/global-styles' );
66
- } }
67
- />
68
- );
45
+ return <SidebarNavigationItem { ...props } />;
69
46
  }
70
47
 
71
- export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
48
+ export default function SidebarNavigationScreenGlobalStyles() {
72
49
  const history = useHistory();
73
50
  const { params } = useLocation();
74
- const { canvas = 'view' } = params;
75
51
  const { revisions, isLoading: isLoadingRevisions } =
76
52
  useGlobalStylesRevisions();
77
53
  const { openGeneralSidebar } = useDispatch( editSiteStore );
78
- const { setIsListViewOpened } = useDispatch( editorStore );
79
- const isMobileViewport = useViewportMatch( 'medium', '<' );
80
54
  const { setEditorCanvasContainerView } = unlock(
81
55
  useDispatch( editSiteStore )
82
56
  );
83
- const { isStyleBookOpened, revisionsCount } = useSelect( ( select ) => {
84
- const { getEditorCanvasContainerView } = unlock(
85
- select( editSiteStore )
86
- );
57
+ const { revisionsCount } = useSelect( ( select ) => {
87
58
  const { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =
88
59
  select( coreStore );
89
60
  const globalStylesId = __experimentalGetCurrentGlobalStylesId();
@@ -91,7 +62,6 @@ export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
91
62
  ? getEntityRecord( 'root', 'globalStyles', globalStylesId )
92
63
  : undefined;
93
64
  return {
94
- isStyleBookOpened: 'style-book' === getEditorCanvasContainerView(),
95
65
  revisionsCount:
96
66
  globalStyles?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0,
97
67
  };
@@ -115,19 +85,6 @@ export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
115
85
  ] );
116
86
  }, [ history, params, openGeneralSidebar, setPreference ] );
117
87
 
118
- const openStyleBook = useCallback( async () => {
119
- await openGlobalStyles();
120
- // Open the Style Book once the canvas mode is set to edit,
121
- // and the global styles sidebar is open. This ensures that
122
- // the Style Book is not prematurely closed.
123
- setEditorCanvasContainerView( 'style-book' );
124
- setIsListViewOpened( false );
125
- }, [
126
- openGlobalStyles,
127
- setEditorCanvasContainerView,
128
- setIsListViewOpened,
129
- ] );
130
-
131
88
  const openRevisions = useCallback( async () => {
132
89
  await openGlobalStyles();
133
90
  // Open the global styles revisions once the canvas mode is set to edit,
@@ -142,16 +99,17 @@ export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
142
99
  const modifiedDateTime = revisions?.[ 0 ]?.modified;
143
100
  const shouldShowGlobalStylesFooter =
144
101
  hasRevisions && ! isLoadingRevisions && modifiedDateTime;
145
-
146
102
  return (
147
103
  <>
148
104
  <SidebarNavigationScreen
149
- title={ __( 'Styles' ) }
105
+ title={ __( 'Design' ) }
106
+ isRoot
150
107
  description={ __(
151
- 'Choose a different style combination for the theme styles.'
108
+ 'Customize the appearance of your website using the block editor.'
152
109
  ) }
153
- backPath={ backPath }
154
- content={ <SidebarNavigationScreenGlobalStylesContent /> }
110
+ content={
111
+ <MainSidebarNavigationContent activeItem="styles-navigation-item" />
112
+ }
155
113
  footer={
156
114
  shouldShowGlobalStylesFooter && (
157
115
  <SidebarNavigationScreenDetailsFooter
@@ -160,40 +118,7 @@ export default function SidebarNavigationScreenGlobalStyles( { backPath } ) {
160
118
  />
161
119
  )
162
120
  }
163
- actions={
164
- <>
165
- { ! isMobileViewport && (
166
- <SidebarButton
167
- icon={ seen }
168
- label={ __( 'Style Book' ) }
169
- onClick={ () =>
170
- setEditorCanvasContainerView(
171
- ! isStyleBookOpened
172
- ? 'style-book'
173
- : undefined
174
- )
175
- }
176
- isPressed={ isStyleBookOpened }
177
- />
178
- ) }
179
- <SidebarButton
180
- icon={ edit }
181
- label={ __( 'Edit styles' ) }
182
- onClick={ async () => await openGlobalStyles() }
183
- />
184
- </>
185
- }
186
121
  />
187
- { isStyleBookOpened && ! isMobileViewport && canvas === 'view' && (
188
- <StyleBook
189
- enableResizing={ false }
190
- isSelected={ () => false }
191
- onClick={ openStyleBook }
192
- onSelect={ openStyleBook }
193
- showCloseButton={ false }
194
- showTabs={ false }
195
- />
196
- ) }
197
122
  </>
198
123
  );
199
124
  }
@@ -21,6 +21,51 @@ import {
21
21
  PATTERN_TYPES,
22
22
  } from '../../utils/constants';
23
23
 
24
+ export function MainSidebarNavigationContent() {
25
+ return (
26
+ <ItemGroup>
27
+ <SidebarNavigationItem
28
+ uid="navigation-navigation-item"
29
+ params={ { postType: NAVIGATION_POST_TYPE } }
30
+ withChevron
31
+ icon={ navigation }
32
+ >
33
+ { __( 'Navigation' ) }
34
+ </SidebarNavigationItem>
35
+ <SidebarNavigationItemGlobalStyles
36
+ uid="styles-navigation-item"
37
+ icon={ styles }
38
+ >
39
+ { __( 'Styles' ) }
40
+ </SidebarNavigationItemGlobalStyles>
41
+ <SidebarNavigationItem
42
+ uid="page-navigation-item"
43
+ params={ { postType: 'page' } }
44
+ withChevron
45
+ icon={ page }
46
+ >
47
+ { __( 'Pages' ) }
48
+ </SidebarNavigationItem>
49
+ <SidebarNavigationItem
50
+ uid="template-navigation-item"
51
+ params={ { postType: TEMPLATE_POST_TYPE } }
52
+ withChevron
53
+ icon={ layout }
54
+ >
55
+ { __( 'Templates' ) }
56
+ </SidebarNavigationItem>
57
+ <SidebarNavigationItem
58
+ uid="patterns-navigation-item"
59
+ params={ { postType: PATTERN_TYPES.user } }
60
+ withChevron
61
+ icon={ symbol }
62
+ >
63
+ { __( 'Patterns' ) }
64
+ </SidebarNavigationItem>
65
+ </ItemGroup>
66
+ );
67
+ }
68
+
24
69
  export default function SidebarNavigationScreenMain() {
25
70
  const { setEditorCanvasContainerView } = unlock(
26
71
  useDispatch( editSiteStore )
@@ -38,51 +83,7 @@ export default function SidebarNavigationScreenMain() {
38
83
  description={ __(
39
84
  'Customize the appearance of your website using the block editor.'
40
85
  ) }
41
- content={
42
- <>
43
- <ItemGroup>
44
- <SidebarNavigationItem
45
- uid="navigation-navigation-item"
46
- params={ { postType: NAVIGATION_POST_TYPE } }
47
- withChevron
48
- icon={ navigation }
49
- >
50
- { __( 'Navigation' ) }
51
- </SidebarNavigationItem>
52
- <SidebarNavigationItemGlobalStyles
53
- uid="styles-navigation-item"
54
- withChevron
55
- icon={ styles }
56
- >
57
- { __( 'Styles' ) }
58
- </SidebarNavigationItemGlobalStyles>
59
- <SidebarNavigationItem
60
- uid="page-navigation-item"
61
- params={ { postType: 'page' } }
62
- withChevron
63
- icon={ page }
64
- >
65
- { __( 'Pages' ) }
66
- </SidebarNavigationItem>
67
- <SidebarNavigationItem
68
- uid="template-navigation-item"
69
- params={ { postType: TEMPLATE_POST_TYPE } }
70
- withChevron
71
- icon={ layout }
72
- >
73
- { __( 'Templates' ) }
74
- </SidebarNavigationItem>
75
- <SidebarNavigationItem
76
- uid="patterns-navigation-item"
77
- params={ { postType: PATTERN_TYPES.user } }
78
- withChevron
79
- icon={ symbol }
80
- >
81
- { __( 'Patterns' ) }
82
- </SidebarNavigationItem>
83
- </ItemGroup>
84
- </>
85
- }
86
+ content={ <MainSidebarNavigationContent /> }
86
87
  />
87
88
  );
88
89
  }
@@ -3,15 +3,24 @@
3
3
  */
4
4
  import Editor from '../editor';
5
5
  import SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-global-styles';
6
+ import GlobalStylesUIWrapper from '../sidebar-global-styles-wrapper';
6
7
 
7
8
  export const stylesEditRoute = {
8
9
  name: 'styles-edit',
9
10
  match: ( params ) => {
10
- return params.path === '/wp_global_styles' && params.canvas === 'edit';
11
+ return (
12
+ params.path &&
13
+ params.path.startsWith( '/wp_global_styles' ) &&
14
+ params.canvas !== 'edit'
15
+ );
11
16
  },
12
17
  areas: {
18
+ content: <GlobalStylesUIWrapper />,
13
19
  sidebar: <SidebarNavigationScreenGlobalStyles backPath={ {} } />,
14
20
  preview: <Editor />,
15
21
  mobile: <Editor />,
16
22
  },
23
+ widths: {
24
+ content: 380,
25
+ },
17
26
  };
@@ -3,14 +3,24 @@
3
3
  */
4
4
  import Editor from '../editor';
5
5
  import SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-global-styles';
6
+ import GlobalStylesUIWrapper from '../sidebar-global-styles-wrapper';
6
7
 
7
8
  export const stylesViewRoute = {
8
9
  name: 'styles-view',
9
10
  match: ( params ) => {
10
- return params.path === '/wp_global_styles' && params.canvas !== 'edit';
11
+ return (
12
+ params.path &&
13
+ params.path.startsWith( '/wp_global_styles' ) &&
14
+ params.canvas !== 'edit'
15
+ );
11
16
  },
12
17
  areas: {
18
+ content: <GlobalStylesUIWrapper />,
13
19
  sidebar: <SidebarNavigationScreenGlobalStyles backPath={ {} } />,
14
20
  preview: <Editor />,
21
+ mobile: <GlobalStylesUIWrapper />,
22
+ },
23
+ widths: {
24
+ content: 380,
15
25
  },
16
26
  };