Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance: Improve StyleBook resize responsiveness for Classic Theme #68980

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions packages/edit-site/src/components/style-book/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
} from '@wordpress/block-editor';
import { privateApis as editorPrivateApis } from '@wordpress/editor';
import { useSelect, dispatch } from '@wordpress/data';
import { useResizeObserver } from '@wordpress/compose';
import {
useMemo,
useState,
Expand Down Expand Up @@ -227,7 +226,6 @@ function StyleBook( {
userConfig = {},
path = '',
} ) {
const [ resizeObserver, sizes ] = useResizeObserver();
const [ textColor ] = useGlobalStyle( 'color.text' );
const [ backgroundColor ] = useGlobalStyle( 'color.background' );
const colors = useMultiOriginPalettes();
Expand Down Expand Up @@ -282,15 +280,13 @@ function StyleBook( {
>
<div
className={ clsx( 'edit-site-style-book', {
'is-wide': sizes.width > 600,
'is-button': !! onClick,
} ) }
style={ {
color: textColor,
background: backgroundColor,
} }
>
{ resizeObserver }
{ showTabs ? (
<Tabs>
<div className="edit-site-style-book__tablist-container">
Expand Down Expand Up @@ -331,7 +327,6 @@ function StyleBook( {
isSelected={ isSelected }
onSelect={ onSelect }
settings={ settings }
sizes={ sizes }
title={ tab.title }
goTo={ goTo }
/>
Expand All @@ -346,7 +341,6 @@ function StyleBook( {
onClick={ onClick }
onSelect={ onSelect }
settings={ settings }
sizes={ sizes }
goTo={ goTo }
/>
) }
Expand Down Expand Up @@ -420,7 +414,6 @@ export const StyleBookPreview = ( { userConfig = {}, isStatic = false } ) => {
onChangeSection( `/blocks/${ encodeURIComponent( blockName ) }` );
};

const [ resizeObserver, sizes ] = useResizeObserver();
const colors = useMultiOriginPalettes();
const examples = getExamples( colors );
const examplesForSinglePageUse = getExamplesForSinglePageUse( examples );
Expand Down Expand Up @@ -489,14 +482,12 @@ export const StyleBookPreview = ( { userConfig = {}, isStatic = false } ) => {

return (
<div className="edit-site-style-book">
{ resizeObserver }
<BlockEditorProvider settings={ settings }>
<GlobalStylesRenderer disableRootPadding />
<StyleBookBody
examples={ displayedExamples }
settings={ settings }
goTo={ goTo }
sizes={ sizes }
isSelected={ ! isStatic ? isSelected : null }
onSelect={ ! isStatic ? onSelect : null }
/>
Expand All @@ -511,7 +502,6 @@ export const StyleBookBody = ( {
onClick,
onSelect,
settings,
sizes,
title,
goTo,
} ) => {
Expand Down Expand Up @@ -574,9 +564,7 @@ export const StyleBookBody = ( {
'body { cursor: pointer; } body * { pointer-events: none; }' }
</style>
<Examples
className={ clsx( 'edit-site-style-book__examples', {
'is-wide': sizes.width > 600,
} ) }
className="edit-site-style-book__examples"
filteredExamples={ examples }
label={
title
Expand Down
Loading