Make inspector style transform previews consistent with toolbar transforms#75989
Make inspector style transform previews consistent with toolbar transforms#75989tellthemachines merged 2 commits intotrunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: -248 B (0%) Total Size: 6.84 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in ee9618a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22471671153
|
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import BlockStylesPreviewPanel from './preview-panel'; |
There was a problem hiding this comment.
I think this file is now no longer used and can be deleted, possibly the accompanying styles in .block-editor-block-styles__preview-panel
There was a problem hiding this comment.
Yeah this should be safe to delete because it's not exported outside of the block styles component, well spotted!
| const previewBlocks = useMemo( () => { | ||
| if ( ! hoveredStyle || ! genericPreviewBlock ) { | ||
| return null; | ||
| } | ||
| const previewClassName = replaceActiveStyle( | ||
| className, | ||
| activeStyle, | ||
| hoveredStyle | ||
| ); | ||
| return [ | ||
| { | ||
| ...genericPreviewBlock, | ||
| attributes: { | ||
| ...( genericPreviewBlock.attributes || {} ), | ||
| className: previewClassName, | ||
| }, | ||
| }, | ||
| ]; | ||
| }, [ hoveredStyle, genericPreviewBlock, className, activeStyle ] ); |
There was a problem hiding this comment.
Non-blocking comment. https://github.com/WordPress/gutenberg/blob/try/consistent-transform-previews/packages/block-editor/src/components/block-switcher/block-styles-menu.js#L29-L47 has the same code block.
Could be a candidate for extraction into a small hook
There was a problem hiding this comment.
Yeah I wondered whether it would be worth a hook or a wrapper for PreviewBlockPopover and ended up not doing so because I couldn't decide on the best approach 😄
my go-to strategy is usually extract once there are more than 2 instances, so I just left it alone
…forms (#75989) Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>



What?
Follow-up from this comment.
The style transforms in the block inspector were using
BlockStylesPreviewPanelcreated for the block inserter, that by default renders the name of the block (or variation in this case):We don't really need that for style switching, and @fcoveram suggested removing it and also removing the "preview" title from the
PreviewBlockPopoverthat the toolbar block transforms use.This PR removes the "preview" title from
PreviewBlockPopoverand adds a couple props to it so it can be reused in the inspector, instead ofBlockStylesPreviewPanel.Testing Instructions