diff --git a/packages/edit-site/src/components/style-book/index.js b/packages/edit-site/src/components/style-book/index.js index b6931b8e65665..19508f0a59f8e 100644 --- a/packages/edit-site/src/components/style-book/index.js +++ b/packages/edit-site/src/components/style-book/index.js @@ -7,13 +7,10 @@ import classnames from 'classnames'; * WordPress dependencies */ import { - __unstableComposite as Composite, - __unstableUseCompositeState as useCompositeState, - __unstableCompositeItem as CompositeItem, Disabled, TabPanel, + privateApis as componentsPrivateApis, } from '@wordpress/components'; - import { __, sprintf } from '@wordpress/i18n'; import { getCategories, @@ -43,6 +40,12 @@ const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock( blockEditorPrivateApis ); +const { + CompositeV2: Composite, + CompositeItemV2: CompositeItem, + useCompositeStoreV2: useCompositeStore, +} = unlock( componentsPrivateApis ); + // The content area of the Style Book is rendered within an iframe so that global styles // are applied to elements within the entire content area. To support elements that are // not part of the block previews, such as headings and layout for the block previews, @@ -66,6 +69,8 @@ const STYLE_BOOK_IFRAME_STYLES = ` padding: 16px; width: 100%; box-sizing: border-box; + scroll-margin-top: 32px; + scroll-margin-bottom: 32px; } .edit-site-style-book__example.is-selected { @@ -332,6 +337,7 @@ const StyleBookBody = ( { } isSelected={ isSelected } onSelect={ onSelect } + key={ category } /> ); @@ -339,12 +345,14 @@ const StyleBookBody = ( { const Examples = memo( ( { className, examples, category, label, isSelected, onSelect } ) => { - const composite = useCompositeState( { orientation: 'vertical' } ); + const compositeStore = useCompositeStore( { orientation: 'vertical' } ); + return ( { examples .filter( ( example ) => @@ -354,7 +362,6 @@ const Examples = memo( { +const Example = ( { id, title, blocks, isSelected, onClick } ) => { const originalSettings = useSelect( ( select ) => select( blockEditorStore ).getSettings(), [] @@ -385,35 +392,41 @@ const Example = ( { composite, id, title, blocks, isSelected, onClick } ) => { ); return ( - - - { title } - -
- - +
+ } + role="button" + onClick={ onClick } + > + + { title } + +
- - - + + + + + +
+
- +
); };