Background image: display default background size value in global styles#60490
Conversation
ensure that the default background size is displayed in the control
|
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. |
|
|
||
| // Initial control values where no block style is set. | ||
| const BACKGROUND_DEFAULT_VALUES = { | ||
| backgroundSize: 'auto', |
There was a problem hiding this comment.
This PR is useful regardless of the defaults we choose.
See:
We want to display the default value in the control.
background-size is technically not set at all, but the effect is the same as "Fixed" which is the label for "background-size: auto"
|
Size Change: -24 B (0%) Total Size: 1.73 MB
ℹ️ View Unchanged
|
|
Following up on our conversation from This PR is a small one to display the current default value of top-level background image sizes, mentioned in #60264 (comment) Something like this will be required no matter the default value. There's an exploratory PR in the works to standardize all default values here (background size to "cover" / background position to "center" if background size is "contain"): I was chatting with @andrewserong and, no matter which one we go with and when, it's something that can be changed later. Assume 18.1 (next week, April 10) goes out and the site background size is valueless, which is the current state of trunk. This is what users will have if they upload an image and do nothing else. If it's decided that we merge #60405 or some other PR that changes that default value later, we can ensure that these default values are set at the time the image is uploaded/selected. This means that users who have already used the feature and not set any values won't experience any regressions. Thanks for the continued guidance on this. 🙇🏻 |
Oh dang, then yes we do 😄 Thanks for pointing that out |
…e to determine if the size control should be displayed
| { sizeValue !== undefined && | ||
| sizeValue !== 'cover' && | ||
| sizeValue !== 'contain' ? ( | ||
| { currentValueForToggle !== undefined && |
There was a problem hiding this comment.
Testing if currentValueForToggle is a good substitute for sizeValue to determine if the size control should be displayed
There was a problem hiding this comment.
That's working nicely for me!
andrewserong
left a comment
There was a problem hiding this comment.
Just took this for another spin, and it's all testing well for me. Let's see what the designers think!
| { sizeValue !== undefined && | ||
| sizeValue !== 'cover' && | ||
| sizeValue !== 'contain' ? ( | ||
| { currentValueForToggle !== undefined && |
There was a problem hiding this comment.
That's working nicely for me!
Thanks again for testing @andrewserong! |
andrewserong
left a comment
There was a problem hiding this comment.
Code looks good to me! ✨
…les (WordPress#60490) * rename constant to BACKGROUND_DEFAULT_VALUES ensure that the default background size is displayed in the control * Tesating if `currentValueForToggle` is a good substitute for sizeValue to determine if the size control should be displayed Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org>


What?
Part of:
Follow up to:
This PR:
BACKGROUND_DEFAULT_VALUESWhy?
The default background size is not displayed on the control.
How?
Passing the default background size.
Testing Instructions
Using a block theme like 2024, head over to the site editor.
Select "Background" in global styles.
Ensure that "Fixed" is selected in the background size toggle control.
Screenshots or screencast