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

Inline block preview: add preview block in nested global style panels #46401

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

madhusudhand
Copy link
Member

What?

This is a followup for #45719
It adds the inline preview block under nested style panels typography, colors, border and layout.

Why?

This allows to preview the block while editing the styles without having to navigate to main panel.

How?

Moved spacer into the BlockPreviewPanel component and included the component in all the respective panels.

Testing Instructions

  1. Open global styles
  2. Open blocks -> [block-name] -> typography (or colors, layout, border)
  3. Observe that preview is included.

Testing Instructions for Keyboard

Screenshots or screencast

block-preview-2

blocks={ getBlockFromExample( name, blockExample ) }
/>
</div>
<BlockPreview
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BlockPreview uses memo, I was hoping the preview to not re-render on forward and back navigation.
However, it still renders.
Also tried wrapping BlockPreviewPanel component with memo, yet it re-renders.
Please suggest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. is it re-rendering because the clientId of the elements is changing? I guess memo should stop this happening, but it still re-renders?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't avoid re-renders unless you're using the same component instance. So you'd need the same <BlockPreview /> call for all the previews.

@madhusudhand madhusudhand self-assigned this Dec 8, 2022
@ntsekouras ntsekouras added Needs Design Feedback Needs general design feedback. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Dec 9, 2022
@jasmussen
Copy link
Contributor

This seems valuable. The only challenge here is that it animates with the sliding panel, and of course it would. I suppose it could be an argument for showing this preview only in the drilldown panels, i.e. not on Blocks > Button, but on Blocks > Button > Typography, etc.

But for now, seems good to move forward with this and explore further.

@madhusudhand
Copy link
Member Author

The only challenge here is that it animates with the sliding panel, and of course it would. I suppose it could be an argument for showing this preview only in the drilldown panels, i.e. not on Blocks > Button, but on Blocks > Button > Typography, etc.

I tried, but failed to avoid re-render on drilldown panels so that the transition is smooth.
I think we can land this and iterate for a smoother transition.

Also, there is an idea of hiding the preview at all levels when style book is open. Share your thoughts here #46394

Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Can you please rebase in order to trigger the CI? With 🟢 let's ship.

@ntsekouras ntsekouras merged commit a556b69 into WordPress:trunk Dec 19, 2022
@github-actions github-actions bot added this to the Gutenberg 14.9 milestone Dec 19, 2022
@madhusudhand madhusudhand deleted the inline-preview-2 branch December 19, 2022 08:43
@femkreations femkreations added the Needs User Documentation Needs new user documentation label Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Design Feedback Needs general design feedback. Needs User Documentation Needs new user documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants