-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Zoom out: Invoke zoom out mode when opening the patterns tab, and move the code to do so to a shared hook #59775
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: +3.97 kB (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good change IMO let's also address the nits?
Co-authored-by: Andrei Draganescu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. One follow-up question though.
Should this be reserved behind the zoom-out experiment flag? Where it only zooms-out if the experiment is enabled?
Why? The zoomed out editor is already public in global styles, what is wrong with trying it directly as it's here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a bug which may be what is causing the tests to fail: the tests can't find a category in the patterns tab but as you can see below once a pattern id added there is some issue which prevents the patterns tab from showing up:
no-more-patterns-tab.mp4
It's much more front-and-center than the styles view, and it'd give us more time to "compile" the zoom out issues more cohesively. |
An alternative would be to engage zoom out when a pattern category is selected. It may feel a bit better having it engage with patterns you can add visible—rather than having to click a category before you add patterns anyhow. And it may also resolve @draganescu's comment. |
moving the hook seems to have solved the probem in my testing
…e the code to do so to a shared hook (WordPress#59775) * Invoke zoomed out when using the patterns tab, and create a hook * Update packages/block-editor/README.md Co-authored-by: Andrei Draganescu <[email protected]> * update docs * enter zoom out on category select --------- Co-authored-by: Andrei Draganescu <[email protected]> Co-authored-by: Andrei Draganescu <[email protected]>
@@ -49,6 +50,10 @@ export function PatternCategoryPreviews( { | |||
const [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' ); | |||
const [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' ); | |||
|
|||
// Move to zoom out mode when this component is mounted | |||
// and back to the previous mode when unmounted. | |||
useZoomOut(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd much rather this not be a useEffect
. If you refactor it to call the action in the same onClick
(or whatever trigger is used) for switching to the pattern category previews would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I too dislike this hook 😁
### useZoomOut | ||
|
||
A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have been exported as a privateAPI
instead of being public.
What?
This invokes the zoom out mode when opening the patterns tab, and then restores the previous mode when the patterns tab is unmounted. Closes #44585.
Why?
When inserting patterns its useful to see more of your site.
How?
This already happens when opening the "browse styles" section of global styles. I moved this code to a hook that can be shared by both components.
Question
Should we use the same zoom out mode that is used for Global Styles, or a different one so that we can continue to iterate on zoom out mode without impacting production.
Testing Instructions
Screenshots or screencast
Mar-12-2024.10-29-16.mp4