-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Don't apply the background and text colors to typography previews #61898
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: +43 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
Flaky tests detected in f4dea19. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9207677221
|
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 tests out very well!
@@ -109,6 +110,15 @@ export default function PreviewIframe( { | |||
}, [ styles ] ); | |||
const isReady = !! width; | |||
|
|||
const calculatedStyles = { |
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.
Since this is not a calculation of this vector but a computation of its values (we have if conditions hence steps) maybe:
const calculatedStyles = { | |
const computedStyles = { |
@@ -38,6 +38,7 @@ export default function PreviewIframe( { | |||
label, | |||
isFocused, | |||
withHoverView, | |||
previewStyles, |
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.
At first I thought it was odd that a component named PreviewIframe
didn't already receive previewStyles
before this PR. Then I noticed that this is used to imperatively set CSS on the iframe. I am not a fan of this, although it works.
Why not tell the component what we're previewing and let it internally decide how to style itself? This way we also avoid magic values coming from other components.
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.
That's the approach in #61280
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 agree with @draganescu, and I don't like the boolean addGlobalStyles
prop from #61280.
We have a useGlobalStylesOutputWithConfig
function that allows you to pass exactly what is needed for styles. Or you could move the change up to the Variation
component which provides the GlobalStylesContext
.
It seems like a simpler solution to just change the source of the styles rather than overriding them with a new prop at this level.
f4dea19
to
b1267b3
Compare
Closing in favour of #62578 |
What?
This overrides the site text and background colors on typography previews. Fixes #61217
Why?
It's easier to preview the typography without the additional color information.
How?
Pass styles to the Iframe Preview component.
Testing Instructions
Screenshots or screencast