@wordpress/edit-site 4.4.0 → 4.7.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 (134) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/add-new-template/new-template.js +24 -22
  3. package/build/components/add-new-template/new-template.js.map +1 -1
  4. package/build/components/block-editor/index.js +29 -23
  5. package/build/components/block-editor/index.js.map +1 -1
  6. package/build/components/code-editor/code-editor-text-area.js +11 -9
  7. package/build/components/code-editor/code-editor-text-area.js.map +1 -1
  8. package/build/components/global-styles/border-panel.js +2 -7
  9. package/build/components/global-styles/border-panel.js.map +1 -1
  10. package/build/components/global-styles/context-menu.js +3 -3
  11. package/build/components/global-styles/context-menu.js.map +1 -1
  12. package/build/components/global-styles/header.js +15 -11
  13. package/build/components/global-styles/header.js.map +1 -1
  14. package/build/components/global-styles/hooks.js +2 -2
  15. package/build/components/global-styles/hooks.js.map +1 -1
  16. package/build/components/global-styles/navigation-button.js +4 -4
  17. package/build/components/global-styles/navigation-button.js.map +1 -1
  18. package/build/components/global-styles/palette.js +1 -1
  19. package/build/components/global-styles/palette.js.map +1 -1
  20. package/build/components/global-styles/preview.js +13 -2
  21. package/build/components/global-styles/preview.js.map +1 -1
  22. package/build/components/global-styles/screen-block-list.js +1 -1
  23. package/build/components/global-styles/screen-block-list.js.map +1 -1
  24. package/build/components/global-styles/screen-colors.js +3 -3
  25. package/build/components/global-styles/screen-colors.js.map +1 -1
  26. package/build/components/global-styles/screen-root.js +13 -3
  27. package/build/components/global-styles/screen-root.js.map +1 -1
  28. package/build/components/global-styles/screen-typography.js +1 -1
  29. package/build/components/global-styles/screen-typography.js.map +1 -1
  30. package/build/components/global-styles/use-global-styles-output.js +1 -7
  31. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  32. package/build/components/list/table.js +1 -1
  33. package/build/components/list/table.js.map +1 -1
  34. package/build/components/navigation-sidebar/navigation-panel/constants.js +2 -2
  35. package/build/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
  36. package/build/components/preferences-modal/index.js +5 -1
  37. package/build/components/preferences-modal/index.js.map +1 -1
  38. package/build/components/routes/use-title.js +3 -1
  39. package/build/components/routes/use-title.js.map +1 -1
  40. package/build/components/secondary-sidebar/list-view-sidebar.js +1 -5
  41. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  42. package/build/components/sidebar/global-styles-sidebar.js +2 -4
  43. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  44. package/build/components/sidebar/index.js +1 -1
  45. package/build/components/sidebar/index.js.map +1 -1
  46. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
  47. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  48. package/build/components/template-details/index.js +4 -2
  49. package/build/components/template-details/index.js.map +1 -1
  50. package/build/index.js +11 -3
  51. package/build/index.js.map +1 -1
  52. package/build-module/components/add-new-template/new-template.js +24 -23
  53. package/build-module/components/add-new-template/new-template.js.map +1 -1
  54. package/build-module/components/block-editor/index.js +29 -24
  55. package/build-module/components/block-editor/index.js.map +1 -1
  56. package/build-module/components/code-editor/code-editor-text-area.js +12 -10
  57. package/build-module/components/code-editor/code-editor-text-area.js.map +1 -1
  58. package/build-module/components/global-styles/border-panel.js +2 -7
  59. package/build-module/components/global-styles/border-panel.js.map +1 -1
  60. package/build-module/components/global-styles/context-menu.js +4 -4
  61. package/build-module/components/global-styles/context-menu.js.map +1 -1
  62. package/build-module/components/global-styles/header.js +16 -11
  63. package/build-module/components/global-styles/header.js.map +1 -1
  64. package/build-module/components/global-styles/hooks.js +2 -2
  65. package/build-module/components/global-styles/hooks.js.map +1 -1
  66. package/build-module/components/global-styles/navigation-button.js +3 -3
  67. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  68. package/build-module/components/global-styles/palette.js +2 -2
  69. package/build-module/components/global-styles/palette.js.map +1 -1
  70. package/build-module/components/global-styles/preview.js +14 -3
  71. package/build-module/components/global-styles/preview.js.map +1 -1
  72. package/build-module/components/global-styles/screen-block-list.js +2 -2
  73. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  74. package/build-module/components/global-styles/screen-colors.js +4 -4
  75. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  76. package/build-module/components/global-styles/screen-root.js +15 -5
  77. package/build-module/components/global-styles/screen-root.js.map +1 -1
  78. package/build-module/components/global-styles/screen-typography.js +2 -2
  79. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  80. package/build-module/components/global-styles/use-global-styles-output.js +1 -7
  81. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  82. package/build-module/components/list/table.js +1 -1
  83. package/build-module/components/list/table.js.map +1 -1
  84. package/build-module/components/navigation-sidebar/navigation-panel/constants.js +2 -2
  85. package/build-module/components/navigation-sidebar/navigation-panel/constants.js.map +1 -1
  86. package/build-module/components/preferences-modal/index.js +5 -1
  87. package/build-module/components/preferences-modal/index.js.map +1 -1
  88. package/build-module/components/routes/use-title.js +2 -1
  89. package/build-module/components/routes/use-title.js.map +1 -1
  90. package/build-module/components/secondary-sidebar/list-view-sidebar.js +1 -5
  91. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  92. package/build-module/components/sidebar/global-styles-sidebar.js +2 -4
  93. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  94. package/build-module/components/sidebar/index.js +3 -3
  95. package/build-module/components/sidebar/index.js.map +1 -1
  96. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
  97. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  98. package/build-module/components/template-details/index.js +4 -2
  99. package/build-module/components/template-details/index.js.map +1 -1
  100. package/build-module/index.js +10 -3
  101. package/build-module/index.js.map +1 -1
  102. package/build-style/style-rtl.css +22 -71
  103. package/build-style/style.css +22 -71
  104. package/package.json +30 -30
  105. package/src/components/add-new-template/new-template.js +22 -17
  106. package/src/components/block-editor/index.js +59 -38
  107. package/src/components/code-editor/code-editor-text-area.js +12 -7
  108. package/src/components/global-styles/border-panel.js +2 -12
  109. package/src/components/global-styles/context-menu.js +7 -7
  110. package/src/components/global-styles/header.js +20 -17
  111. package/src/components/global-styles/hooks.js +1 -1
  112. package/src/components/global-styles/navigation-button.js +3 -3
  113. package/src/components/global-styles/palette.js +3 -3
  114. package/src/components/global-styles/preview.js +17 -2
  115. package/src/components/global-styles/screen-block-list.js +3 -3
  116. package/src/components/global-styles/screen-colors.js +7 -7
  117. package/src/components/global-styles/screen-root.js +34 -24
  118. package/src/components/global-styles/screen-typography.js +3 -3
  119. package/src/components/global-styles/use-global-styles-output.js +1 -4
  120. package/src/components/header/document-actions/style.scss +1 -1
  121. package/src/components/header/style.scss +14 -29
  122. package/src/components/list/style.scss +1 -0
  123. package/src/components/list/table.js +1 -4
  124. package/src/components/navigation-sidebar/navigation-panel/constants.js +2 -2
  125. package/src/components/preferences-modal/index.js +8 -1
  126. package/src/components/routes/use-title.js +3 -2
  127. package/src/components/secondary-sidebar/list-view-sidebar.js +1 -5
  128. package/src/components/sidebar/global-styles-sidebar.js +1 -1
  129. package/src/components/sidebar/index.js +4 -2
  130. package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -7
  131. package/src/components/sidebar/navigation-menu-sidebar/style.scss +0 -1
  132. package/src/components/sidebar/style.scss +4 -47
  133. package/src/components/template-details/index.js +4 -1
  134. package/src/index.js +17 -1
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { filter, find, includes, map } from 'lodash';
4
+ import { filter, includes, map } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -37,10 +37,11 @@ import { store as noticesStore } from '@wordpress/notices';
37
37
  * Internal dependencies
38
38
  */
39
39
  import { useHistory } from '../routes';
40
+ import { store as editSiteStore } from '../../store';
40
41
 
41
42
  const DEFAULT_TEMPLATE_SLUGS = [
42
43
  'front-page',
43
- 'single-post',
44
+ 'single',
44
45
  'page',
45
46
  'index',
46
47
  'archive',
@@ -55,7 +56,7 @@ const DEFAULT_TEMPLATE_SLUGS = [
55
56
 
56
57
  const TEMPLATE_ICONS = {
57
58
  'front-page': home,
58
- 'single-post': post,
59
+ single: post,
59
60
  page,
60
61
  archive,
61
62
  search,
@@ -86,30 +87,34 @@ export default function NewTemplate( { postType } ) {
86
87
  );
87
88
  const { saveEntityRecord } = useDispatch( coreStore );
88
89
  const { createErrorNotice } = useDispatch( noticesStore );
90
+ const { setTemplate } = useDispatch( editSiteStore );
89
91
 
90
- async function createTemplate( { slug } ) {
92
+ async function createTemplate( template ) {
91
93
  try {
92
- const { title, description } = find( defaultTemplateTypes, {
93
- slug,
94
- } );
94
+ const { title, description, slug } = template;
95
95
 
96
- const template = await saveEntityRecord(
96
+ const newTemplate = await saveEntityRecord(
97
97
  'postType',
98
98
  'wp_template',
99
99
  {
100
- excerpt: description,
100
+ description,
101
101
  // Slugs need to be strings, so this is for template `404`
102
102
  slug: slug.toString(),
103
103
  status: 'publish',
104
104
  title,
105
+ // This adds a post meta field in template that is part of `is_custom` value calculation.
106
+ is_wp_suggestion: true,
105
107
  },
106
108
  { throwOnError: true }
107
109
  );
108
110
 
111
+ // Set template before navigating away to avoid initial stale value.
112
+ setTemplate( newTemplate.id, newTemplate.slug );
113
+
109
114
  // Navigate to the created template editor.
110
115
  history.push( {
111
- postId: template.id,
112
- postType: template.type,
116
+ postId: newTemplate.id,
117
+ postType: newTemplate.type,
113
118
  } );
114
119
 
115
120
  // TODO: Add a success notice?
@@ -162,23 +167,23 @@ export default function NewTemplate( { postType } ) {
162
167
  { () => (
163
168
  <NavigableMenu className="edit-site-new-template-dropdown__popover">
164
169
  <MenuGroup label={ postType.labels.add_new_item }>
165
- { map(
166
- missingTemplates,
167
- ( { title, description, slug } ) => (
170
+ { map( missingTemplates, ( template ) => {
171
+ const { title, description, slug } = template;
172
+ return (
168
173
  <MenuItem
169
174
  icon={ TEMPLATE_ICONS[ slug ] }
170
175
  iconPosition="left"
171
176
  info={ description }
172
177
  key={ slug }
173
178
  onClick={ () => {
174
- createTemplate( { slug } );
179
+ createTemplate( template );
175
180
  // We will be navigated way so no need to close the dropdown.
176
181
  } }
177
182
  >
178
183
  { title }
179
184
  </MenuItem>
180
- )
181
- ) }
185
+ );
186
+ } ) }
182
187
  </MenuGroup>
183
188
  </NavigableMenu>
184
189
  ) }
@@ -2,12 +2,13 @@
2
2
  * External dependencies
3
3
  */
4
4
  import classnames from 'classnames';
5
+ import { omit, unionBy } from 'lodash';
5
6
 
6
7
  /**
7
8
  * WordPress dependencies
8
9
  */
9
10
  import { useSelect, useDispatch } from '@wordpress/data';
10
- import { useCallback, useRef } from '@wordpress/element';
11
+ import { useCallback, useMemo, useRef, Fragment } from '@wordpress/element';
11
12
  import { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';
12
13
  import {
13
14
  BlockList,
@@ -48,44 +49,17 @@ const LAYOUT = {
48
49
  };
49
50
 
50
51
  export default function BlockEditor( { setIsInserterOpen } ) {
51
- const { settings } = useSelect(
52
+ const { storedSettings, templateType, templateId, page } = useSelect(
52
53
  ( select ) => {
53
- let storedSettings = select( editSiteStore ).getSettings(
54
- setIsInserterOpen
55
- );
56
-
57
- if ( ! storedSettings.__experimentalBlockPatterns ) {
58
- storedSettings = {
59
- ...storedSettings,
60
- __experimentalBlockPatterns: select(
61
- coreStore
62
- ).getBlockPatterns(),
63
- };
64
- }
65
-
66
- if ( ! storedSettings.__experimentalBlockPatternCategories ) {
67
- storedSettings = {
68
- ...storedSettings,
69
- __experimentalBlockPatternCategories: select(
70
- coreStore
71
- ).getBlockPatternCategories(),
72
- };
73
- }
74
-
75
- return {
76
- settings: storedSettings,
77
- };
78
- },
79
- [ setIsInserterOpen ]
80
- );
81
-
82
- const { templateType, templateId, page } = useSelect(
83
- ( select ) => {
84
- const { getEditedPostType, getEditedPostId, getPage } = select(
85
- editSiteStore
86
- );
54
+ const {
55
+ getSettings,
56
+ getEditedPostType,
57
+ getEditedPostId,
58
+ getPage,
59
+ } = select( editSiteStore );
87
60
 
88
61
  return {
62
+ storedSettings: getSettings( setIsInserterOpen ),
89
63
  templateType: getEditedPostType(),
90
64
  templateId: getEditedPostId(),
91
65
  page: getPage(),
@@ -94,6 +68,50 @@ export default function BlockEditor( { setIsInserterOpen } ) {
94
68
  [ setIsInserterOpen ]
95
69
  );
96
70
 
71
+ const settingsBlockPatterns =
72
+ storedSettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0
73
+ storedSettings.__experimentalBlockPatterns; // WP 5.9
74
+ const settingsBlockPatternCategories =
75
+ storedSettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0
76
+ storedSettings.__experimentalBlockPatternCategories; // WP 5.9
77
+
78
+ const { restBlockPatterns, restBlockPatternCategories } = useSelect(
79
+ ( select ) => ( {
80
+ restBlockPatterns: select( coreStore ).getBlockPatterns(),
81
+ restBlockPatternCategories: select(
82
+ coreStore
83
+ ).getBlockPatternCategories(),
84
+ } ),
85
+ []
86
+ );
87
+
88
+ const blockPatterns = useMemo(
89
+ () => unionBy( settingsBlockPatterns, restBlockPatterns, 'name' ),
90
+ [ settingsBlockPatterns, restBlockPatterns ]
91
+ );
92
+
93
+ const blockPatternCategories = useMemo(
94
+ () =>
95
+ unionBy(
96
+ settingsBlockPatternCategories,
97
+ restBlockPatternCategories,
98
+ 'name'
99
+ ),
100
+ [ settingsBlockPatternCategories, restBlockPatternCategories ]
101
+ );
102
+
103
+ const settings = useMemo(
104
+ () => ( {
105
+ ...omit( storedSettings, [
106
+ '__experimentalAdditionalBlockPatterns',
107
+ '__experimentalAdditionalBlockPatternCategories',
108
+ ] ),
109
+ __experimentalBlockPatterns: blockPatterns,
110
+ __experimentalBlockPatternCategories: blockPatternCategories,
111
+ } ),
112
+ [ storedSettings, blockPatterns, blockPatternCategories ]
113
+ );
114
+
97
115
  const [ blocks, onInput, onChange ] = useEntityBlockEditor(
98
116
  'postType',
99
117
  templateType
@@ -112,6 +130,7 @@ export default function BlockEditor( { setIsInserterOpen } ) {
112
130
  const { clearSelectedBlock } = useDispatch( blockEditorStore );
113
131
 
114
132
  const isTemplatePart = templateType === 'wp_template_part';
133
+ const hasBlocks = blocks.length !== 0;
115
134
 
116
135
  const NavMenuSidebarToggle = () => (
117
136
  <ToolbarGroup>
@@ -127,7 +146,7 @@ export default function BlockEditor( { setIsInserterOpen } ) {
127
146
  // Conditionally include NavMenu sidebar in Plugin only.
128
147
  // Optimise for dead code elimination.
129
148
  // See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
130
- let MaybeNavMenuSidebarToggle = 'Fragment';
149
+ let MaybeNavMenuSidebarToggle = Fragment;
131
150
 
132
151
  if ( process.env.IS_GUTENBERG_PLUGIN ) {
133
152
  MaybeNavMenuSidebarToggle = NavMenuSidebarToggle;
@@ -186,7 +205,9 @@ export default function BlockEditor( { setIsInserterOpen } ) {
186
205
  <BlockList
187
206
  className="edit-site-block-editor__block-list wp-site-blocks"
188
207
  __experimentalLayout={ LAYOUT }
189
- renderAppender={ isTemplatePart ? false : undefined }
208
+ renderAppender={
209
+ isTemplatePart && hasBlocks ? false : undefined
210
+ }
190
211
  />
191
212
  </ResizableEditor>
192
213
  <__unstableBlockSettingsMenuFirstItem>
@@ -3,17 +3,11 @@
3
3
  */
4
4
  import Textarea from 'react-autosize-textarea';
5
5
 
6
- /**
7
- * WordPress dependencies
8
- */
9
- /**
10
- * WordPress dependencies
11
- */
12
6
  /**
13
7
  * WordPress dependencies
14
8
  */
15
9
  import { __ } from '@wordpress/i18n';
16
- import { useState } from '@wordpress/element';
10
+ import { useEffect, useState, useRef } from '@wordpress/element';
17
11
  import { useInstanceId } from '@wordpress/compose';
18
12
  import { VisuallyHidden } from '@wordpress/components';
19
13
 
@@ -21,6 +15,7 @@ export default function CodeEditorTextArea( { value, onChange, onInput } ) {
21
15
  const [ stateValue, setStateValue ] = useState( value );
22
16
  const [ isDirty, setIsDirty ] = useState( false );
23
17
  const instanceId = useInstanceId( CodeEditorTextArea );
18
+ const valueRef = useRef();
24
19
 
25
20
  if ( ! isDirty && stateValue !== value ) {
26
21
  setStateValue( value );
@@ -42,6 +37,7 @@ export default function CodeEditorTextArea( { value, onChange, onInput } ) {
42
37
  onInput( newValue );
43
38
  setStateValue( newValue );
44
39
  setIsDirty( true );
40
+ valueRef.current = newValue;
45
41
  };
46
42
 
47
43
  /**
@@ -56,6 +52,15 @@ export default function CodeEditorTextArea( { value, onChange, onInput } ) {
56
52
  }
57
53
  };
58
54
 
55
+ // Ensure changes aren't lost when component unmounts.
56
+ useEffect( () => {
57
+ return () => {
58
+ if ( valueRef.current ) {
59
+ onChange( valueRef.current );
60
+ }
61
+ };
62
+ }, [] );
63
+
59
64
  return (
60
65
  <>
61
66
  <VisuallyHidden
@@ -182,18 +182,8 @@ export default function BorderPanel( { name } ) {
182
182
  onChange={ onBorderChange }
183
183
  showStyle={ showBorderStyle }
184
184
  value={ border }
185
- popoverClassNames={ {
186
- linked:
187
- 'edit-site-global-styles-sidebar__border-box-control__popover',
188
- top:
189
- 'edit-site-global-styles-sidebar__border-box-control__popover-top',
190
- right:
191
- 'edit-site-global-styles-sidebar__border-box-control__popover-right',
192
- bottom:
193
- 'edit-site-global-styles-sidebar__border-box-control__popover-bottom',
194
- left:
195
- 'edit-site-global-styles-sidebar__border-box-control__popover-left',
196
- } }
185
+ popoverPlacement="left-start"
186
+ popoverOffset={ 40 }
197
187
  __experimentalHasMultipleOrigins={ true }
198
188
  __experimentalIsRenderedInSidebar={ true }
199
189
  />
@@ -12,7 +12,7 @@ import { useHasBorderPanel } from './border-panel';
12
12
  import { useHasColorPanel } from './color-utils';
13
13
  import { useHasDimensionsPanel } from './dimensions-panel';
14
14
  import { useHasTypographyPanel } from './typography-panel';
15
- import { NavigationButton } from './navigation-button';
15
+ import { NavigationButtonAsItem } from './navigation-button';
16
16
 
17
17
  function ContextMenu( { name, parentMenu = '' } ) {
18
18
  const hasTypographyPanel = useHasTypographyPanel( name );
@@ -24,28 +24,28 @@ function ContextMenu( { name, parentMenu = '' } ) {
24
24
  return (
25
25
  <ItemGroup>
26
26
  { hasTypographyPanel && (
27
- <NavigationButton
27
+ <NavigationButtonAsItem
28
28
  icon={ typography }
29
29
  path={ parentMenu + '/typography' }
30
30
  >
31
31
  { __( 'Typography' ) }
32
- </NavigationButton>
32
+ </NavigationButtonAsItem>
33
33
  ) }
34
34
  { hasColorPanel && (
35
- <NavigationButton
35
+ <NavigationButtonAsItem
36
36
  icon={ color }
37
37
  path={ parentMenu + '/colors' }
38
38
  >
39
39
  { __( 'Colors' ) }
40
- </NavigationButton>
40
+ </NavigationButtonAsItem>
41
41
  ) }
42
42
  { hasLayoutPanel && (
43
- <NavigationButton
43
+ <NavigationButtonAsItem
44
44
  icon={ layout }
45
45
  path={ parentMenu + '/layout' }
46
46
  >
47
47
  { __( 'Layout' ) }
48
- </NavigationButton>
48
+ </NavigationButtonAsItem>
49
49
  ) }
50
50
  </ItemGroup>
51
51
  );
@@ -7,30 +7,33 @@ import {
7
7
  __experimentalSpacer as Spacer,
8
8
  __experimentalHeading as Heading,
9
9
  __experimentalView as View,
10
+ __experimentalNavigatorBackButton as NavigatorBackButton,
10
11
  } from '@wordpress/components';
11
12
  import { isRTL, __ } from '@wordpress/i18n';
12
13
  import { chevronRight, chevronLeft } from '@wordpress/icons';
13
14
 
14
- /**
15
- * Internal dependencies
16
- */
17
- import { NavigationBackButton } from './navigation-button';
18
-
19
15
  function ScreenHeader( { title, description } ) {
20
16
  return (
21
- <VStack spacing={ 2 }>
22
- <HStack spacing={ 2 }>
23
- <View>
24
- <NavigationBackButton
25
- icon={ isRTL() ? chevronRight : chevronLeft }
26
- size="small"
27
- aria-label={ __( 'Navigate to the previous view' ) }
28
- />
29
- </View>
30
- <Spacer>
31
- <Heading level={ 5 }>{ title }</Heading>
17
+ <VStack spacing={ 0 }>
18
+ <View>
19
+ <Spacer marginBottom={ 0 } paddingX={ 4 } paddingY={ 3 }>
20
+ <HStack spacing={ 2 }>
21
+ <NavigatorBackButton
22
+ style={
23
+ // TODO: This style override is also used in ToolsPanelHeader.
24
+ // It should be supported out-of-the-box by Button.
25
+ { minWidth: 24, padding: 0 }
26
+ }
27
+ icon={ isRTL() ? chevronRight : chevronLeft }
28
+ isSmall
29
+ aria-label={ __( 'Navigate to the previous view' ) }
30
+ />
31
+ <Spacer>
32
+ <Heading level={ 5 }>{ title }</Heading>
33
+ </Spacer>
34
+ </HStack>
32
35
  </Spacer>
33
- </HStack>
36
+ </View>
34
37
  { description && (
35
38
  <p className="edit-site-global-styles-header__description">
36
39
  { description }
@@ -20,7 +20,7 @@ import {
20
20
  import { getValueFromVariable, getPresetVariableFromValue } from './utils';
21
21
  import { GlobalStylesContext } from './context';
22
22
 
23
- const EMPTY_CONFIG = { isGlobalStylesUserThemeJSON: true, version: 1 };
23
+ const EMPTY_CONFIG = { settings: {}, styles: {} };
24
24
 
25
25
  export const useGlobalStylesReset = () => {
26
26
  const { user: config, setUserConfig } = useContext( GlobalStylesContext );
@@ -28,12 +28,12 @@ function GenericNavigationButton( { icon, children, ...props } ) {
28
28
  );
29
29
  }
30
30
 
31
- function NavigationButton( props ) {
31
+ function NavigationButtonAsItem( props ) {
32
32
  return <NavigatorButton as={ GenericNavigationButton } { ...props } />;
33
33
  }
34
34
 
35
- function NavigationBackButton( props ) {
35
+ function NavigationBackButtonAsItem( props ) {
36
36
  return <NavigatorBackButton as={ GenericNavigationButton } { ...props } />;
37
37
  }
38
38
 
39
- export { NavigationButton, NavigationBackButton };
39
+ export { NavigationButtonAsItem, NavigationBackButtonAsItem };
@@ -16,7 +16,7 @@ import { useMemo } from '@wordpress/element';
16
16
  * Internal dependencies
17
17
  */
18
18
  import Subtitle from './subtitle';
19
- import { NavigationButton } from './navigation-button';
19
+ import { NavigationButtonAsItem } from './navigation-button';
20
20
  import { useSetting } from './hooks';
21
21
  import ColorIndicatorWrapper from './color-indicator-wrapper';
22
22
 
@@ -58,7 +58,7 @@ function Palette( { name } ) {
58
58
  <VStack spacing={ 3 }>
59
59
  <Subtitle>{ __( 'Palette' ) }</Subtitle>
60
60
  <ItemGroup isBordered isSeparated>
61
- <NavigationButton path={ screenPath }>
61
+ <NavigationButtonAsItem path={ screenPath }>
62
62
  <HStack
63
63
  direction={
64
64
  colors.length === 0 ? 'row-reverse' : 'row'
@@ -73,7 +73,7 @@ function Palette( { name } ) {
73
73
  </ZStack>
74
74
  <FlexItem>{ paletteButtonText }</FlexItem>
75
75
  </HStack>
76
- </NavigationButton>
76
+ </NavigationButtonAsItem>
77
77
  </ItemGroup>
78
78
  </VStack>
79
79
  );
@@ -11,7 +11,7 @@ import {
11
11
  __experimentalVStack as VStack,
12
12
  } from '@wordpress/components';
13
13
  import { useReducedMotion, useResizeObserver } from '@wordpress/compose';
14
- import { useState } from '@wordpress/element';
14
+ import { useState, useMemo } from '@wordpress/element';
15
15
 
16
16
  /**
17
17
  * Internal dependencies
@@ -79,10 +79,25 @@ const StylesPreview = ( { label, isFocused } ) => {
79
79
  )
80
80
  .slice( 0, 2 );
81
81
 
82
+ // Reset leaked styles from WP common.css.
83
+ const editorStyles = useMemo( () => {
84
+ if ( styles ) {
85
+ return [
86
+ ...styles,
87
+ {
88
+ css: 'body{min-width: 0;}',
89
+ isGlobalStyles: true,
90
+ },
91
+ ];
92
+ }
93
+
94
+ return styles;
95
+ }, [ styles ] );
96
+
82
97
  return (
83
98
  <Iframe
84
99
  className="edit-site-global-styles-preview__iframe"
85
- head={ <EditorStyles styles={ styles } /> }
100
+ head={ <EditorStyles styles={ editorStyles } /> }
86
101
  style={ {
87
102
  height: normalizedHeight * ratio,
88
103
  visibility: ! width ? 'hidden' : 'visible',
@@ -22,7 +22,7 @@ import { useHasColorPanel } from './color-utils';
22
22
  import { useHasDimensionsPanel } from './dimensions-panel';
23
23
  import { useHasTypographyPanel } from './typography-panel';
24
24
  import ScreenHeader from './header';
25
- import { NavigationButton } from './navigation-button';
25
+ import { NavigationButtonAsItem } from './navigation-button';
26
26
 
27
27
  function useSortedBlockTypes() {
28
28
  const blockItems = useSelect(
@@ -61,12 +61,12 @@ function BlockMenuItem( { block } ) {
61
61
  }
62
62
 
63
63
  return (
64
- <NavigationButton path={ '/blocks/' + block.name }>
64
+ <NavigationButtonAsItem path={ '/blocks/' + block.name }>
65
65
  <HStack justify="flex-start">
66
66
  <BlockIcon icon={ block.icon } />
67
67
  <FlexItem>{ block.title }</FlexItem>
68
68
  </HStack>
69
- </NavigationButton>
69
+ </NavigationButtonAsItem>
70
70
  );
71
71
  }
72
72
 
@@ -15,7 +15,7 @@ import {
15
15
  */
16
16
  import ScreenHeader from './header';
17
17
  import Palette from './palette';
18
- import { NavigationButton } from './navigation-button';
18
+ import { NavigationButtonAsItem } from './navigation-button';
19
19
  import { getSupportedGlobalStylesPanels, useStyle } from './hooks';
20
20
  import Subtitle from './subtitle';
21
21
  import ColorIndicatorWrapper from './color-indicator-wrapper';
@@ -33,7 +33,7 @@ function BackgroundColorItem( { name, parentMenu } ) {
33
33
  }
34
34
 
35
35
  return (
36
- <NavigationButton path={ parentMenu + '/colors/background' }>
36
+ <NavigationButtonAsItem path={ parentMenu + '/colors/background' }>
37
37
  <HStack justify="flex-start">
38
38
  <ColorIndicatorWrapper expanded={ false }>
39
39
  <ColorIndicator
@@ -42,7 +42,7 @@ function BackgroundColorItem( { name, parentMenu } ) {
42
42
  </ColorIndicatorWrapper>
43
43
  <FlexItem>{ __( 'Background' ) }</FlexItem>
44
44
  </HStack>
45
- </NavigationButton>
45
+ </NavigationButtonAsItem>
46
46
  );
47
47
  }
48
48
 
@@ -56,14 +56,14 @@ function TextColorItem( { name, parentMenu } ) {
56
56
  }
57
57
 
58
58
  return (
59
- <NavigationButton path={ parentMenu + '/colors/text' }>
59
+ <NavigationButtonAsItem path={ parentMenu + '/colors/text' }>
60
60
  <HStack justify="flex-start">
61
61
  <ColorIndicatorWrapper expanded={ false }>
62
62
  <ColorIndicator colorValue={ color } />
63
63
  </ColorIndicatorWrapper>
64
64
  <FlexItem>{ __( 'Text' ) }</FlexItem>
65
65
  </HStack>
66
- </NavigationButton>
66
+ </NavigationButtonAsItem>
67
67
  );
68
68
  }
69
69
 
@@ -77,14 +77,14 @@ function LinkColorItem( { name, parentMenu } ) {
77
77
  }
78
78
 
79
79
  return (
80
- <NavigationButton path={ parentMenu + '/colors/link' }>
80
+ <NavigationButtonAsItem path={ parentMenu + '/colors/link' }>
81
81
  <HStack justify="flex-start">
82
82
  <ColorIndicatorWrapper expanded={ false }>
83
83
  <ColorIndicator colorValue={ color } />
84
84
  </ColorIndicatorWrapper>
85
85
  <FlexItem>{ __( 'Links' ) }</FlexItem>
86
86
  </HStack>
87
- </NavigationButton>
87
+ </NavigationButtonAsItem>
88
88
  );
89
89
  }
90
90