-
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
Global Styles: Create a style preview component #59498
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. |
const noop = () => {}; | ||
|
||
const PreviewWrapper = ( { | ||
firstFrame = noop, |
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.
The main consideration here IMO is whether it makes sense to pass three different components as three different props.
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.
Could it be an array of frames? e.g., frames={ [ ... ] }
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.
Or child components?
<PreviewWrapper>
<>
<FirstFrame />
<SecondFrame />
<>
</PreviewWrapper>
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 did it with child components
Size Change: -996 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
e104269
to
3ed9264
Compare
blockEditorPrivateApis | ||
); | ||
|
||
const firstFrameVariants = { |
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.
If the props were changed from firstFrame, etc..
to an array, or they're rendered as children
, do you think it's reasonable for these variants to be passed as part of the frame components?
Might make it neater in the render block below (inside <motion.div initial="start" ... />
)?
Then it would be able to accommodate one or more frames. 🤷🏻
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 PR is working in the site editor as described. Thank you!
I think maybe it might abstract things further to have PreviewWrapper accept children or an array of frames. It might result in a bit of duplicate code, e.g., the frame variants, but would be more flexible for other uses?
packages/edit-site/src/components/global-styles/preview-wrapper.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/global-styles/preview-highlighted-colors.js
Outdated
Show resolved
Hide resolved
rafctor to three frames
3ed9264
to
621088c
Compare
f127af7
to
abdb873
Compare
Thanks for the review, I think this is ready for another look. |
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.
Looks pretty good to me
- styles variations work as expected (site editor view sidebar and global styles)
- typography and color variations work as they do on trunk
Thanks!
packages/edit-site/src/components/global-styles/highlighted-colors.js
Outdated
Show resolved
Hide resolved
…lors.js Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
What?
This is a followup to #56622, which tries to refactor some of the duplicate code to be shared between components.
Why?
Sharing code between different components helps us to keep behaviours consistent across the product.
How?
PreviewWrapper has 3 frames but they don't all need to be implemented.
The next step here would be to explore using the PreviewWrapper component to display Typography previews too, but I didn't want to go too far in one PR.
Testing Instructions
Screenshots or screencast