@wordpress/edit-site 5.3.7 → 5.3.9

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 (38) hide show
  1. package/build/components/add-new-template/new-template.js +16 -10
  2. package/build/components/add-new-template/new-template.js.map +1 -1
  3. package/build/components/sidebar-navigation-screen-main/index.js +2 -1
  4. package/build/components/sidebar-navigation-screen-main/index.js.map +1 -1
  5. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +1 -40
  6. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  7. package/build/components/sidebar-navigation-screen-templates-browse/index.js +1 -1
  8. package/build/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  9. package/build/components/site-hub/index.js +3 -1
  10. package/build/components/site-hub/index.js.map +1 -1
  11. package/build/components/style-book/index.js +134 -19
  12. package/build/components/style-book/index.js.map +1 -1
  13. package/build-module/components/add-new-template/new-template.js +18 -11
  14. package/build-module/components/add-new-template/new-template.js.map +1 -1
  15. package/build-module/components/sidebar-navigation-screen-main/index.js +2 -1
  16. package/build-module/components/sidebar-navigation-screen-main/index.js.map +1 -1
  17. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +2 -39
  18. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  19. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js +1 -1
  20. package/build-module/components/sidebar-navigation-screen-templates-browse/index.js.map +1 -1
  21. package/build-module/components/site-hub/index.js +3 -1
  22. package/build-module/components/site-hub/index.js.map +1 -1
  23. package/build-module/components/style-book/index.js +135 -22
  24. package/build-module/components/style-book/index.js.map +1 -1
  25. package/build-style/style-rtl.css +21 -47
  26. package/build-style/style.css +21 -47
  27. package/package.json +10 -10
  28. package/src/components/add-new-template/new-template.js +57 -32
  29. package/src/components/add-new-template/style.scss +12 -1
  30. package/src/components/sidebar-navigation-item/style.scss +1 -3
  31. package/src/components/sidebar-navigation-screen-main/index.js +4 -1
  32. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +3 -40
  33. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +4 -0
  34. package/src/components/sidebar-navigation-screen-templates-browse/index.js +1 -1
  35. package/src/components/site-hub/index.js +5 -1
  36. package/src/components/site-hub/style.scss +5 -1
  37. package/src/components/style-book/index.js +209 -54
  38. package/src/components/style-book/style.scss +1 -45
@@ -7,7 +7,8 @@ import {
7
7
  DropdownMenu,
8
8
  MenuGroup,
9
9
  MenuItem,
10
- NavigableMenu,
10
+ Tooltip,
11
+ VisuallyHidden,
11
12
  } from '@wordpress/components';
12
13
  import { useState } from '@wordpress/element';
13
14
  import { useDispatch } from '@wordpress/data';
@@ -179,6 +180,11 @@ export default function NewTemplate( {
179
180
  if ( ! missingTemplates.length ) {
180
181
  return null;
181
182
  }
183
+
184
+ const customTemplateDescription = __(
185
+ 'A custom template can be manually applied to any post or page.'
186
+ );
187
+
182
188
  return (
183
189
  <>
184
190
  <DropdownMenu
@@ -196,7 +202,7 @@ export default function NewTemplate( {
196
202
  { isCreatingTemplate && (
197
203
  <TemplateActionsLoadingScreen />
198
204
  ) }
199
- <NavigableMenu className="edit-site-new-template-dropdown__popover">
205
+ <div className="edit-site-new-template-dropdown__menu-groups">
200
206
  <MenuGroup label={ postType.labels.add_new_item }>
201
207
  { missingTemplates.map( ( template ) => {
202
208
  const {
@@ -207,44 +213,63 @@ export default function NewTemplate( {
207
213
  icon,
208
214
  } = template;
209
215
  return (
210
- <MenuItem
211
- icon={
212
- icon ||
213
- TEMPLATE_ICONS[ slug ] ||
214
- post
215
- }
216
- iconPosition="left"
217
- info={ description }
216
+ <Tooltip
218
217
  key={ slug }
219
- onClick={ () =>
220
- onClick
221
- ? onClick( template )
222
- : createTemplate( template )
223
- }
218
+ position="top right"
219
+ text={ description }
220
+ className="edit-site-new-template-dropdown__menu-item-tooltip"
224
221
  >
225
- { title }
226
- </MenuItem>
222
+ <MenuItem
223
+ icon={
224
+ icon ||
225
+ TEMPLATE_ICONS[ slug ] ||
226
+ post
227
+ }
228
+ iconPosition="left"
229
+ onClick={ () =>
230
+ onClick
231
+ ? onClick( template )
232
+ : createTemplate(
233
+ template
234
+ )
235
+ }
236
+ >
237
+ { title }
238
+ { /* TODO: This probably won't be needed if the <Tooltip> component is accessible.
239
+ * @see https://github.com/WordPress/gutenberg/issues/48222 */ }
240
+ <VisuallyHidden>
241
+ { description }
242
+ </VisuallyHidden>
243
+ </MenuItem>
244
+ </Tooltip>
227
245
  );
228
246
  } ) }
229
247
  </MenuGroup>
230
248
  <MenuGroup>
231
- <MenuItem
232
- icon={ customGenericTemplateIcon }
233
- iconPosition="left"
234
- info={ __(
235
- 'Custom templates can be applied to any post or page.'
236
- ) }
237
- key="custom-template"
238
- onClick={ () =>
239
- setShowCustomGenericTemplateModal(
240
- true
241
- )
242
- }
249
+ <Tooltip
250
+ position="top right"
251
+ text={ customTemplateDescription }
252
+ className="edit-site-new-template-dropdown__menu-item-tooltip"
243
253
  >
244
- { __( 'Custom template' ) }
245
- </MenuItem>
254
+ <MenuItem
255
+ icon={ customGenericTemplateIcon }
256
+ iconPosition="left"
257
+ onClick={ () =>
258
+ setShowCustomGenericTemplateModal(
259
+ true
260
+ )
261
+ }
262
+ >
263
+ { __( 'Custom template' ) }
264
+ { /* TODO: This probably won't be needed if the <Tooltip> component is accessible.
265
+ * @see https://github.com/WordPress/gutenberg/issues/48222 */ }
266
+ <VisuallyHidden>
267
+ { customTemplateDescription }
268
+ </VisuallyHidden>
269
+ </MenuItem>
270
+ </Tooltip>
246
271
  </MenuGroup>
247
- </NavigableMenu>
272
+ </div>
248
273
  </>
249
274
  ) }
250
275
  </DropdownMenu>
@@ -1,9 +1,20 @@
1
1
  .edit-site-new-template-dropdown {
2
- .edit-site-new-template-dropdown__popover {
2
+ .edit-site-new-template-dropdown__menu-groups {
3
3
  @include break-small() {
4
4
  min-width: 300px;
5
5
  }
6
6
  }
7
+
8
+ // The specificity is needed to override the default tooltip styles.
9
+ &__menu-item-tooltip.components-tooltip .components-popover__content {
10
+ max-width: 320px;
11
+ padding: $grid-unit-10 $grid-unit-15;
12
+ border-radius: 2px;
13
+ white-space: pre-wrap;
14
+ min-width: 0;
15
+ width: auto;
16
+ text-align: left;
17
+ }
7
18
  }
8
19
 
9
20
  .edit-site-custom-template-modal {
@@ -1,13 +1,12 @@
1
1
  .edit-site-sidebar-navigation-item.components-item {
2
2
  color: $gray-600;
3
- border-width: $border-width-tab;
3
+ margin: 0 $grid-unit-05;
4
4
 
5
5
  &:hover,
6
6
  &:focus,
7
7
  &[aria-current] {
8
8
  color: $white;
9
9
  background: $gray-800;
10
- border-width: $border-width-tab;
11
10
  }
12
11
 
13
12
  &[aria-current] {
@@ -17,6 +16,5 @@
17
16
 
18
17
  .edit-site-sidebar-navigation-screen__content .block-editor-list-view-block-select-button {
19
18
  cursor: grab;
20
- width: calc(100% - #{ $border-width-focus });
21
19
  padding: $grid-unit-10;
22
20
  }
@@ -27,6 +27,9 @@ export default function SidebarNavigationScreenMain() {
27
27
  };
28
28
  } );
29
29
 
30
+ const showNavigationScreen = process.env.IS_GUTENBERG_PLUGIN
31
+ ? navigationMenus?.length > 0
32
+ : false;
30
33
  return (
31
34
  <SidebarNavigationScreen
32
35
  isRoot
@@ -36,7 +39,7 @@ export default function SidebarNavigationScreenMain() {
36
39
  ) }
37
40
  content={
38
41
  <ItemGroup>
39
- { !! navigationMenus && navigationMenus.length > 0 && (
42
+ { showNavigationScreen && (
40
43
  <NavigatorButton
41
44
  as={ SidebarNavigationItem }
42
45
  path="/navigation"
@@ -5,10 +5,7 @@ import { __ } from '@wordpress/i18n';
5
5
  import { useCallback, useMemo } from '@wordpress/element';
6
6
  import { useSelect } from '@wordpress/data';
7
7
  import { store as coreStore } from '@wordpress/core-data';
8
- import {
9
- BlockEditorProvider,
10
- privateApis as blockEditorPrivateApis,
11
- } from '@wordpress/block-editor';
8
+ import { BlockEditorProvider } from '@wordpress/block-editor';
12
9
  import { createBlock } from '@wordpress/blocks';
13
10
 
14
11
  /**
@@ -17,7 +14,6 @@ import { createBlock } from '@wordpress/blocks';
17
14
  import SidebarNavigationScreen from '../sidebar-navigation-screen';
18
15
  import { useHistory } from '../routes';
19
16
  import NavigationMenuContent from './navigation-menu-content';
20
- import SidebarButton from '../sidebar-button';
21
17
  import { NavigationMenuLoader } from './loader';
22
18
  import { unlock } from '../../private-apis';
23
19
  import { store as editSiteStore } from '../../store';
@@ -38,11 +34,6 @@ function SidebarNavigationScreenWrapper( { children, actions } ) {
38
34
  );
39
35
  }
40
36
 
41
- const prioritizedInserterBlocks = [
42
- 'core/navigation-link/page',
43
- 'core/navigation-link',
44
- ];
45
-
46
37
  export default function SidebarNavigationScreenNavigationMenus() {
47
38
  const history = useHistory();
48
39
  const { navigationMenus, hasResolvedNavigationMenus, storedSettings } =
@@ -109,18 +100,6 @@ export default function SidebarNavigationScreenNavigationMenus() {
109
100
  },
110
101
  [ history ]
111
102
  );
112
- const orderInitialBlockItems = useCallback( ( items ) => {
113
- items.sort( ( { id: aName }, { id: bName } ) => {
114
- // Sort block items according to `prioritizedInserterBlocks`.
115
- let aIndex = prioritizedInserterBlocks.indexOf( aName );
116
- let bIndex = prioritizedInserterBlocks.indexOf( bName );
117
- // All other block items should come after that.
118
- if ( aIndex < 0 ) aIndex = prioritizedInserterBlocks.length;
119
- if ( bIndex < 0 ) bIndex = prioritizedInserterBlocks.length;
120
- return aIndex - bIndex;
121
- } );
122
- return items;
123
- }, [] );
124
103
 
125
104
  if ( hasResolvedNavigationMenus && ! hasNavigationMenus ) {
126
105
  return (
@@ -137,7 +116,7 @@ export default function SidebarNavigationScreenNavigationMenus() {
137
116
  </SidebarNavigationScreenWrapper>
138
117
  );
139
118
  }
140
- const { PrivateInserter } = unlock( blockEditorPrivateApis );
119
+
141
120
  return (
142
121
  <BlockEditorProvider
143
122
  settings={ storedSettings }
@@ -145,23 +124,7 @@ export default function SidebarNavigationScreenNavigationMenus() {
145
124
  onChange={ noop }
146
125
  onInput={ noop }
147
126
  >
148
- <SidebarNavigationScreenWrapper
149
- actions={
150
- <PrivateInserter
151
- rootClientId={ blocks[ 0 ].clientId }
152
- position="bottom right"
153
- isAppender
154
- selectBlockOnInsert={ false }
155
- shouldDirectInsert={ false }
156
- __experimentalIsQuick
157
- toggleProps={ {
158
- as: SidebarButton,
159
- label: __( 'Add menu item' ),
160
- } }
161
- orderInitialBlockItems={ orderInitialBlockItems }
162
- />
163
- }
164
- >
127
+ <SidebarNavigationScreenWrapper>
165
128
  <div className="edit-site-sidebar-navigation-screen-navigation-menus__content">
166
129
  <NavigationMenuContent
167
130
  rootClientId={ blocks[ 0 ].clientId }
@@ -61,3 +61,7 @@
61
61
  }
62
62
  }
63
63
  }
64
+
65
+ .edit-site-sidebar-navigation-screen-navigation-menus__content .popover-slot .wp-block-navigation-submenu {
66
+ display: none;
67
+ }
@@ -19,7 +19,7 @@ const config = {
19
19
  wp_template_part: {
20
20
  title: __( 'All template parts' ),
21
21
  description: __(
22
- 'Create new template parts, or reset any customisations made to the template parts supplied by your theme.'
22
+ 'Create new template parts, or reset any customizations made to the template parts supplied by your theme.'
23
23
  ),
24
24
  },
25
25
  };
@@ -95,7 +95,11 @@ const SiteHub = forwardRef( ( props, ref ) => {
95
95
  </Button>
96
96
  </motion.div>
97
97
 
98
- { showLabels && <div>{ siteTitle }</div> }
98
+ { showLabels && (
99
+ <div className="edit-site-site-hub__site-title">
100
+ { siteTitle }
101
+ </div>
102
+ ) }
99
103
  </HStack>
100
104
  </motion.div>
101
105
  );
@@ -11,7 +11,7 @@
11
11
 
12
12
  .edit-site-site-hub__view-mode-toggle-container {
13
13
  height: $header-height;
14
- width: $header-height + 4px;
14
+ width: $header-height;
15
15
  flex-shrink: 0;
16
16
  background: $gray-900;
17
17
  }
@@ -26,3 +26,7 @@
26
26
  white-space: nowrap;
27
27
  overflow: hidden;
28
28
  }
29
+
30
+ .edit-site-site-hub__site-title {
31
+ margin-left: $grid-unit-05;
32
+ }
@@ -8,6 +8,10 @@ import classnames from 'classnames';
8
8
  */
9
9
  import {
10
10
  Button,
11
+ __unstableComposite as Composite,
12
+ __unstableUseCompositeState as useCompositeState,
13
+ __unstableCompositeItem as CompositeItem,
14
+ Disabled,
11
15
  TabPanel,
12
16
  createSlotFill,
13
17
  __experimentalUseSlotFills as useSlotFills,
@@ -20,9 +24,13 @@ import {
20
24
  createBlock,
21
25
  } from '@wordpress/blocks';
22
26
  import {
23
- BlockPreview,
27
+ BlockList,
24
28
  privateApis as blockEditorPrivateApis,
29
+ store as blockEditorStore,
30
+ __unstableEditorStyles as EditorStyles,
31
+ __unstableIframe as Iframe,
25
32
  } from '@wordpress/block-editor';
33
+ import { useSelect } from '@wordpress/data';
26
34
  import { closeSmall } from '@wordpress/icons';
27
35
  import {
28
36
  useResizeObserver,
@@ -38,12 +46,84 @@ import { ESCAPE } from '@wordpress/keycodes';
38
46
  */
39
47
  import { unlock } from '../../private-apis';
40
48
 
41
- const { useGlobalStyle } = unlock( blockEditorPrivateApis );
49
+ const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(
50
+ blockEditorPrivateApis
51
+ );
42
52
 
43
53
  const SLOT_FILL_NAME = 'EditSiteStyleBook';
44
54
  const { Slot: StyleBookSlot, Fill: StyleBookFill } =
45
55
  createSlotFill( SLOT_FILL_NAME );
46
56
 
57
+ // The content area of the Style Book is rendered within an iframe so that global styles
58
+ // are applied to elements within the entire content area. To support elements that are
59
+ // not part of the block previews, such as headings and layout for the block previews,
60
+ // additional CSS rules need to be passed into the iframe. These are hard-coded below.
61
+ // Note that button styles are unset, and then focus rules from the `Button` component are
62
+ // applied to the `button` element, targeted via `.edit-site-style-book__example`.
63
+ // This is to ensure that browser default styles for buttons are not applied to the previews.
64
+ const STYLE_BOOK_IFRAME_STYLES = `
65
+ .edit-site-style-book__examples {
66
+ max-width: 900px;
67
+ margin: 0 auto;
68
+ }
69
+
70
+ .edit-site-style-book__example {
71
+ border-radius: 2px;
72
+ cursor: pointer;
73
+ display: flex;
74
+ flex-direction: column;
75
+ gap: 40px;
76
+ margin-bottom: 40px;
77
+ padding: 16px;
78
+ width: 100%;
79
+ box-sizing: border-box;
80
+ }
81
+
82
+ .edit-site-style-book__example.is-selected {
83
+ box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
84
+ }
85
+
86
+ .edit-site-style-book__example:focus:not(:disabled) {
87
+ box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
88
+ outline: 3px solid transparent;
89
+ }
90
+
91
+ .edit-site-style-book__examples.is-wide .edit-site-style-book__example {
92
+ flex-direction: row;
93
+ }
94
+
95
+ .edit-site-style-book__example-title {
96
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
97
+ font-size: 11px;
98
+ font-weight: 500;
99
+ line-height: normal;
100
+ margin: 0;
101
+ text-align: left;
102
+ text-transform: uppercase;
103
+ }
104
+
105
+ .edit-site-style-book__examples.is-wide .edit-site-style-book__example-title {
106
+ text-align: right;
107
+ width: 120px;
108
+ }
109
+
110
+ .edit-site-style-book__example-preview {
111
+ width: 100%;
112
+ }
113
+
114
+ .edit-site-style-book__example-preview .block-editor-block-list__insertion-point,
115
+ .edit-site-style-book__example-preview .block-list-appender {
116
+ display: none;
117
+ }
118
+
119
+ .edit-site-style-book__example-preview .is-root-container > .wp-block:first-child {
120
+ margin-top: 0;
121
+ }
122
+ .edit-site-style-book__example-preview .is-root-container > .wp-block:last-child {
123
+ margin-bottom: 0;
124
+ }
125
+ `;
126
+
47
127
  function getExamples() {
48
128
  // Use our own example for the Heading block so that we can show multiple
49
129
  // heading levels.
@@ -118,6 +198,15 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
118
198
  [ examples ]
119
199
  );
120
200
 
201
+ const originalSettings = useSelect(
202
+ ( select ) => select( blockEditorStore ).getSettings(),
203
+ []
204
+ );
205
+ const settings = useMemo(
206
+ () => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
207
+ [ originalSettings ]
208
+ );
209
+
121
210
  function closeOnEscape( event ) {
122
211
  if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
123
212
  event.preventDefault();
@@ -156,12 +245,47 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
156
245
  tabs={ tabs }
157
246
  >
158
247
  { ( tab ) => (
159
- <Examples
160
- examples={ examples }
161
- category={ tab.name }
162
- isSelected={ isSelected }
163
- onSelect={ onSelect }
164
- />
248
+ <Iframe
249
+ className="edit-site-style-book__iframe"
250
+ head={
251
+ <>
252
+ <EditorStyles styles={ settings.styles } />
253
+ <style>
254
+ {
255
+ // Forming a "block formatting context" to prevent margin collapsing.
256
+ // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
257
+ `.is-root-container { display: flow-root; }
258
+ body { position: relative; padding: 32px !important; }` +
259
+ STYLE_BOOK_IFRAME_STYLES
260
+ }
261
+ </style>
262
+ </>
263
+ }
264
+ name="style-book-canvas"
265
+ tabIndex={ 0 }
266
+ >
267
+ { /* Filters need to be rendered before children to avoid Safari rendering issues. */ }
268
+ { settings.svgFilters }
269
+ <Examples
270
+ className={ classnames(
271
+ 'edit-site-style-book__examples',
272
+ {
273
+ 'is-wide': sizes.width > 600,
274
+ }
275
+ ) }
276
+ examples={ examples }
277
+ category={ tab.name }
278
+ label={ sprintf(
279
+ // translators: %s: Category of blocks, e.g. Text.
280
+ __(
281
+ 'Examples of blocks in the %s category'
282
+ ),
283
+ tab.title
284
+ ) }
285
+ isSelected={ isSelected }
286
+ onSelect={ onSelect }
287
+ />
288
+ </Iframe>
165
289
  ) }
166
290
  </TabPanel>
167
291
  </section>
@@ -169,52 +293,83 @@ function StyleBook( { isSelected, onSelect, onClose } ) {
169
293
  );
170
294
  }
171
295
 
172
- const Examples = memo( ( { examples, category, isSelected, onSelect } ) => (
173
- <div className="edit-site-style-book__examples">
174
- { examples
175
- .filter( ( example ) => example.category === category )
176
- .map( ( example ) => (
177
- <Example
178
- key={ example.name }
179
- title={ example.title }
180
- blocks={ example.blocks }
181
- isSelected={ isSelected( example.name ) }
182
- onClick={ () => {
183
- onSelect( example.name );
184
- } }
185
- />
186
- ) ) }
187
- </div>
188
- ) );
189
-
190
- const Example = memo( ( { title, blocks, isSelected, onClick } ) => (
191
- <button
192
- className={ classnames( 'edit-site-style-book__example', {
193
- 'is-selected': isSelected,
194
- } ) }
195
- aria-label={ sprintf(
196
- // translators: %s: Title of a block, e.g. Heading.
197
- __( 'Open %s styles in Styles panel' ),
198
- title
199
- ) }
200
- onClick={ onClick }
201
- >
202
- <span className="edit-site-style-book__example-title">{ title }</span>
203
- <div className="edit-site-style-book__example-preview">
204
- <BlockPreview
205
- blocks={ blocks }
206
- viewportWidth={ 0 }
207
- additionalStyles={ [
208
- {
209
- css:
210
- '.wp-block:first-child { margin-top: 0; }' +
211
- '.wp-block:last-child { margin-bottom: 0; }',
212
- },
213
- ] }
214
- />
215
- </div>
216
- </button>
217
- ) );
296
+ const Examples = memo(
297
+ ( { className, examples, category, label, isSelected, onSelect } ) => {
298
+ const composite = useCompositeState( { orientation: 'vertical' } );
299
+ return (
300
+ <Composite
301
+ { ...composite }
302
+ className={ className }
303
+ aria-label={ label }
304
+ >
305
+ { examples
306
+ .filter( ( example ) => example.category === category )
307
+ .map( ( example ) => (
308
+ <Example
309
+ key={ example.name }
310
+ id={ `example-${ example.name }` }
311
+ composite={ composite }
312
+ title={ example.title }
313
+ blocks={ example.blocks }
314
+ isSelected={ isSelected( example.name ) }
315
+ onClick={ () => {
316
+ onSelect( example.name );
317
+ } }
318
+ />
319
+ ) ) }
320
+ </Composite>
321
+ );
322
+ }
323
+ );
324
+
325
+ const Example = ( { composite, id, title, blocks, isSelected, onClick } ) => {
326
+ const originalSettings = useSelect(
327
+ ( select ) => select( blockEditorStore ).getSettings(),
328
+ []
329
+ );
330
+ const settings = useMemo(
331
+ () => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
332
+ [ originalSettings ]
333
+ );
334
+
335
+ // Cache the list of blocks to avoid additional processing when the component is re-rendered.
336
+ const renderedBlocks = useMemo(
337
+ () => ( Array.isArray( blocks ) ? blocks : [ blocks ] ),
338
+ [ blocks ]
339
+ );
340
+
341
+ return (
342
+ <CompositeItem
343
+ { ...composite }
344
+ className={ classnames( 'edit-site-style-book__example', {
345
+ 'is-selected': isSelected,
346
+ } ) }
347
+ id={ id }
348
+ aria-label={ sprintf(
349
+ // translators: %s: Title of a block, e.g. Heading.
350
+ __( 'Open %s styles in Styles panel' ),
351
+ title
352
+ ) }
353
+ onClick={ onClick }
354
+ role="button"
355
+ as="div"
356
+ >
357
+ <span className="edit-site-style-book__example-title">
358
+ { title }
359
+ </span>
360
+ <div className="edit-site-style-book__example-preview" aria-hidden>
361
+ <Disabled className="edit-site-style-book__example-preview__content">
362
+ <ExperimentalBlockEditorProvider
363
+ value={ renderedBlocks }
364
+ settings={ settings }
365
+ >
366
+ <BlockList renderAppender={ false } />
367
+ </ExperimentalBlockEditorProvider>
368
+ </Disabled>
369
+ </div>
370
+ </CompositeItem>
371
+ );
372
+ };
218
373
 
219
374
  function useHasStyleBook() {
220
375
  const fills = useSlotFills( SLOT_FILL_NAME );
@@ -26,53 +26,9 @@
26
26
  bottom: 0;
27
27
  left: 0;
28
28
  overflow: auto;
29
- padding: $grid-unit-40;
29
+ padding: 0;
30
30
  position: absolute;
31
31
  right: 0;
32
32
  top: $grid-unit-60; // Height of tabs.
33
33
  }
34
34
  }
35
-
36
- .edit-site-style-book__examples {
37
- max-width: 900px;
38
- margin: 0 auto;
39
- }
40
-
41
- .edit-site-style-book__example {
42
- background: none;
43
- border-radius: $radius-block-ui;
44
- border: none;
45
- color: inherit;
46
- cursor: pointer;
47
- display: flex;
48
- flex-direction: column;
49
- gap: $grid-unit-50;
50
- margin-bottom: $grid-unit-50;
51
- padding: $grid-unit-20;
52
- width: 100%;
53
-
54
- &.is-selected {
55
- box-shadow: 0 0 0 1px var(--wp-admin-theme-color);
56
- }
57
-
58
- .edit-site-style-book.is-wide & {
59
- flex-direction: row;
60
- }
61
- }
62
-
63
- .edit-site-style-book__example-title {
64
- font-size: 11px;
65
- font-weight: 500;
66
- margin: 0;
67
- text-align: left;
68
- text-transform: uppercase;
69
-
70
- .edit-site-style-book.is-wide & {
71
- text-align: right;
72
- width: 120px;
73
- }
74
- }
75
-
76
- .edit-site-style-book__example-preview {
77
- width: 100%;
78
- }