-
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
BoxControl: Add support for presets #67688
Conversation
f15066c
to
5c8d201
Compare
9f6e4f9
to
d72909d
Compare
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. |
Flaky tests detected in a0c5d29. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12294409796
|
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 looks good in general. I've left just a few small suggestions/questions. Thanks!
910b4c8
to
a0c5d29
Compare
I understand your point. However, I believe that when a preset is selected and then the user switches to the custom option, the current value should still display as 8px, even though a preset is being used. This would help users see the value that is currently applied, making it easier to make smaller adjustments. Without this visibility, I might struggle to decrease the margin slightly since I wouldn’t know the exact value set with the presets, and there is no easy way to just decrease 1px. We could differentiate the handling of values by storing a different value when 8px is chosen as a custom value versus when it is selected as a preset. Although they may appear the same, they should be stored differently to reflect user intent. I think this solution addresses your concern. We also need to decide whether switching to custom should trigger an This discussion is connected to the effort of displaying global styles values at the block level. We aim to show these values even if the block itself has no styles applied and only inherits them from global styles. This is a personal preference and not a blocker for the pull request. |
Do you think the user would understand that "touching" the field from 8px and just removing and adding the same character back switches from "preset value" to "custom value"? I think that might be more confusing. I agree though that both options have downsides, although both options are possible. I think right now in this PR, we're just adding support for "presets" to a component that is not used, so this is not going to have an impact immediately but I think we should keep this discussion open with designers as well @jasmussen @jameskoster. Especially, in my follow-up PRs where I'll be replacing the custom components with |
a0c5d29
to
90f830a
Compare
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 is working well, and @youknowriad clarified the concerns I had 👍
From my experience, the behavior Jorge describes is quite common, particularly when detaching from presets. Here's an example from Figma that I use all the time: detach.mp4Agree there are trade-offs both ways, but this approach feels a bit more standard to me. |
@jameskoster I agree that with the "detach" button, the behavior you're showing the best one. I think we can explore the detach button separately but right now it doesn't exist anywhere in the UI AFAIK |
Yes fair enough. I guess it's a question of whether the button is about detaching or setting a custom value. Personally I think detaching has it's uses–many of which Jorge outlined above–and is a precursor to setting a custom value anyway. Though I appreciate the existing UI focuses more on the latter. I'll open an issue. |
Actually @youknowriad it does exists 🙊 size.mp4Notice how toggling to set a custom value after selecting a preset font size, the size value/unit remains. |
@jameskoster you misunderstood what I'm saying, Yes, we do keep the value visible but we don't have the "unlink" button which means there's no way for the user to understand whether the value that is visible in the custom input is actually "linked" or not "linked" to the preset. So in the screenshot you shared, the value is "linked" but the user doesn't know it, the only way to "unlink" it but keep the same value is to actually type some random character in the input and remove it. |
Oh wow, I see what you mean. TIL that switching to set a custom value doesn't unlink from the preset until you also change the value. I guess it's a small detail but this behavior feels unexpected to me. |
A bit late to the conversation, but my preference would be:
The Kapture.2024-12-13.at.16.42.10.mp4In any case, whatever UX we think is the best, we should apply uniformly across all UI components |
### `presetKey` | ||
|
||
The key of the preset to apply. | ||
If you provide a list of presets, you must provide a preset key to use. |
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.
Potential improvements for Developer Experience:
- a runtime check, warning when only one of the two
presets
andpresetKey
props are defined - conditional types, specifying that
presetKey
is not optional if thepresets
prop is specified
Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Related #67625
What?
This PR implements "presets" support in the BoxControl component (borrowing the behavior from the spacing sizes with some subtle differences)
Testing Instructions
npm run storybook:dev