-
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
Expose layout values from theme.json as css-variables #30081
Closed
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
be55bd1
Expose layout values from theme.json as css-variables
aristath ccb1c46
do it in the container itself instead of globally
aristath 45b732c
No reason for the fallbacks to be formatted as css-vars
aristath 2f299e2
apply changes to LayoutProvider
aristath c4a6c62
Merge branch 'trunk' into add/layout-vars
aristath 643b1cc
Merge branch 'trunk' into add/layout-vars
aristath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
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.
Last remark I have is about the naming. I don't have any opinion on that, but I just want to make sure this does make sense and is consistent with what we do elsewhere cc @nosolosw
The other thing I wanted to mention is that "content size" and "wide size" are only defined and useful if the layout is "default" (which is the only layout we support right now, but I'm thinking about flex, absolute, grid layouts later. These have different kind of configs and styles). I guess this last point diminishes the need for these CSS variables because there's no guarantee that they exist.
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.
As far as naming goes, what we have is:
--wp--preset--<preset-category>--<preset-slug>
--wp--custom--<variable-name>
--wp--style--color--link
I'm fine with whatever is consistent and clear for folks, but perhaps a suggestion would be to follow the styles naming
--wp--style--layout-*
.These styles aren't generated by the theme.json engine, though, but by the block ― so I'm not sure if it's worth making that difference clear or aligning names. One thing I've noticed is that if we do this, they become public API, which so far we've tried to avoid. I haven't been able to follow the layout work closely but by skimming quickly at this code it looks like we attach this code only if a block supports the layout and has the
layout
attribute. I suppose then that there may be situations in which these aren't present (the user didn't select any layout).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'm personally still hesitant about this PR specially because the layout config can change depending on the "type" of the layout, while right now we do support just one type, I expect we'll introduce others pretty soon (horizontal flex, grid, absolute...) and in all of these these two sizes don't make sense.