Conversation
|
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. |
| justify-content: space-between; | ||
| padding: ${ ITEM_PADDING }; | ||
| font-size: ${ CONFIG.fontSize }; | ||
| line-height: 2.15rem; // TODO: Remove this in default but keep for back-compat in legacy |
There was a problem hiding this comment.
To match 28px, the line height value should have been 2.15 (without the rem unit). I felt like a more explicit calc syntax would help to understand the reason for an arbitrary number.
There was a problem hiding this comment.
It's curious where the 2.15 came from originally...
There was a problem hiding this comment.
It's the ratio of the line height (28px) to the font size (13px)
Also, since 28 / 13 = 2.15384615, another consequence of using 2.15 is that the resulting line height wouldn't be exactly 28px (as per design), but slightly less because of the lower decimal precision.
In short: I prefer to let the browser (or sass) do the calculation, and if not possible, to state the line-height directly.
There was a problem hiding this comment.
Also, since 28 / 13 = 2.15384615, another consequence of using 2.15 is that the resulting line height wouldn't be exactly 28px (as per design), but slightly less because of the lower decimal precision.
Which also makes me question if 28/13 was the intent. But yes, having a clear calc there makes things much clearer.
6ecc280 to
6235497
Compare
| line-height: 2.15rem; // TODO: Remove this in default but keep for back-compat in legacy | ||
| // Legacy line height is 28px. | ||
| // TODO: reassess for non-legacy v2 | ||
| line-height: calc( 28px / ${ CONFIG.fontSize } ); |
There was a problem hiding this comment.
Apparently this calc doesn't work 😕 ("For /, the right operand must be unitless".)
There was a problem hiding this comment.
Maybe if we wrap CONFIG.fontSize() in a stringToNumber()? I appreciate the clarity that the explicit calc adds.
There was a problem hiding this comment.
Sometimes less is more — we can also just remove the ${ CONFIG.fontSize } part, and simply state 28px — pushed in 9a5d26f
There was a problem hiding this comment.
But these 2 aren't the same, are they:
font-size: 13px;
line-height: 2.15384615
and:
font-size: 13px
line-height: 28px
because if someone overrides only the font-size, the line-height will behave differently - considering the new font-size in the first example, and ignoring it in the second one.
There was a problem hiding this comment.
To adhere more closely to legacy behavior, It's actually better to keep the hardcoded 28px as V1 does, exactly for the reason you state. For example, in the default Storybook example of CustomSelectControl each select item has a custom font-size, but the line-height is supposed to stay the same instead of scaling up/down.
There was a problem hiding this comment.
the line-height is supposed to stay the same instead of scaling up/down.
Interesting - is this always the case? What if I have font-size 56px, won't it be ugly with line-height of 28px?
There was a problem hiding this comment.
I guess we can review that when assessing what line-height to adopt for the V2 — keeping it as hardcoded 28px is probably the safest choice while swapping the V1 implementation
| &[aria-disabled='true'] { | ||
| opacity: 0.5; | ||
| } |
There was a problem hiding this comment.
I actually omitted the disabled styles on purpose, because the item styles are fully customizable and the appropriate disabled style will vary. For example, adding a disabled to the "Purple" item in the Default story doesn't result in an understandable visual.
gutenberg/packages/components/src/custom-select-control-v2/types.ts
Lines 196 to 202 in 9a331f1
What do you think?
There was a problem hiding this comment.
You raise a good point — although I also think that the component should offer some good defaults.
Testing a middle ground in 37ee79c , using cursor: not-allowed as a more un-opinionated way to apply default disabled item styles.
Let me know if you still think this is too much
| justify-content: space-between; | ||
| padding: ${ ITEM_PADDING }; | ||
| font-size: ${ CONFIG.fontSize }; | ||
| line-height: 2.15rem; // TODO: Remove this in default but keep for back-compat in legacy |
There was a problem hiding this comment.
It's curious where the 2.15 came from originally...
| line-height: 2.15rem; // TODO: Remove this in default but keep for back-compat in legacy | ||
| // Legacy line height is 28px. | ||
| // TODO: reassess for non-legacy v2 | ||
| line-height: calc( 28px / ${ CONFIG.fontSize } ); |
There was a problem hiding this comment.
Maybe if we wrap CONFIG.fontSize() in a stringToNumber()? I appreciate the clarity that the explicit calc adds.
6235497 to
37ee79c
Compare
tyxla
left a comment
There was a problem hiding this comment.
Left a minor suggestion, but other than that, this looks good to me. Thanks! ![]()
| font-size: ${ CONFIG.fontSize }; | ||
| line-height: 2.15rem; // TODO: Remove this in default but keep for back-compat in legacy | ||
| // TODO: reassess line-height for non-legacy v2 | ||
| line-height: 28px; |
There was a problem hiding this comment.
I'd prefer 2.15384615 and adding a comment about how it's calculated, because that way we'll keep the flexibility/relativity in case someone modifies only the font-size.
37ee79c to
ee95320
Compare
* Fix line height * Add disabled styles * CHANGELOG * Prevent user selection for items text * Apply more tweaks * Remove extra changelog entry * Simplify line-height styles * Less opinionated item disabled styles --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
What?
Part of #55023
Fix items (options) styles of
CustomSelectControlV2componentWhy?
How?
disabledstylesuser-select: noneto trigger button and option itemsscroll-marginto improve scroll experience when selecting items that are out of view in the popoverTesting Instructions
CustomSelectControl, make sure that the items in the select popover now render with the same line height (28px).