Theme Previews: Style card: Add support for themes that don't set colors in theme.json#391
Closed
ryelle wants to merge 1 commit intoWordPress:trunkfrom
Closed
Theme Previews: Style card: Add support for themes that don't set colors in theme.json#391ryelle wants to merge 1 commit intoWordPress:trunkfrom
ryelle wants to merge 1 commit intoWordPress:trunkfrom
Conversation
…ors in theme.json
StevenDufresne
pushed a commit
to StevenDufresne/wordpress.org
that referenced
this pull request
Nov 14, 2024
…ors in theme.json Some block themes set the page background color not by setting the styles.color.background property, but instead by adding a top-level wrapper block. When done this way, the background is not picked up by the style variation card view. This PR attempts to pull out any relevant classes from the first wrapper element it sees, and applies those to the style card container Fixes WordPress/wporg-theme-directory#154. Closes WordPress#391. git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14151 74240141-8908-4e6f-9713-ba540dce6ec7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See WordPress/wporg-theme-directory#154 — Some block themes set the page background color not by setting the
styles.color.backgroundproperty, but instead by adding a top-level wrapper block. When done this way, the background is not picked up by the style variation card view. This PR attempts to pull out any relevant classes from the first wrapper element it sees, and applies those to the style card container.I think these themes are technically doing it wrong— the colors and other base styles should be set in theme.json, not as settings on blocks— but providing this workaround will at least display slightly better. It's not perfect though, you can see in the screenshots below that the font color for Danva is still incorrect (which leads to the all-black image). This is, again, because the text color is set on each individual element, not the body tag. The fonts are also not correct, same reason.
Screenshots
To test:
themes-preview/wp-content/themes/on your sandboxTry with different themes than I did, for example Topwork or hardlight