-
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
Background image: display default background size value in global styles #60490
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. |
@@ -8,6 +8,11 @@ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor'; | |||
*/ | |||
import { unlock } from '../../lock-unlock'; | |||
|
|||
// Initial control values where no block style is set. | |||
const BACKGROUND_DEFAULT_VALUES = { | |||
backgroundSize: 'auto', |
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 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. 🙇🏻 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's working nicely for me!
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's working nicely for me!
Thanks again for testing @andrewserong! |
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.
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 <[email protected]> Co-authored-by: andrewserong <[email protected]> Co-authored-by: jameskoster <[email protected]>
What?
Part of:
Follow up to:
This PR:
BACKGROUND_DEFAULT_VALUES
Why?
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