feat(checkbox, radio, toggle, range): stacked labels for form controls#28075
feat(checkbox, radio, toggle, range): stacked labels for form controls#28075thetaPC merged 14 commits intofeature-7.4from
Conversation
|
|
f60b9ea to
6a4dc5f
Compare
1d5c847 to
25f0229
Compare
liamdebeasi
left a comment
There was a problem hiding this comment.
The implementation of this is really good! We'll need to choose a different property name than align since it conflicts with a global deprecated attribute.
Feel free to add me for another review, but once my comments are addressed I think this is good to go.
| * `"start"`: The label and control will appear at the top of the container. | ||
| * `"center"`: The label and control will appear at the center of the container. | ||
| */ | ||
| @Prop() align: 'start' | 'center' = 'center'; |
There was a problem hiding this comment.
We're going to need to name this something other than align because it collides with the global deprecated align attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes. The align attribute is going to cause the text inside of the label container to be centered.
Maybe we can call this alignment? Open to other ideas from the team.
There was a problem hiding this comment.
You'll also notice that long labels are no longer centered within their container. We're currently discussing the best path forward for this on Slack.
There was a problem hiding this comment.
alignment works for me. And based on the Slack thread, no changes will be needed for centering.
| @Prop() justify: 'start' | 'end' | 'space-between' = 'space-between'; | ||
|
|
||
| /** | ||
| * How to pack the label and control along the cross axis. |
There was a problem hiding this comment.
Can we update this comment (and ditto for other components) that this only applies when the label and control are on separate lines such as when using labelPlacement="stacked"?
| * `"start"`: The label will appear to the left of the toggle in LTR and to the right in RTL. | ||
| * `"end"`: The label will appear to the right of the toggle in LTR and to the left in RTL. | ||
| * `"fixed"`: The label has the same behavior as `"start"` except it also has a fixed width. Long text will be truncated with ellipses ("..."). | ||
| * `"stacked"`: The label will appear above the toggle regardless of the direction. The alignment of the label can be controlled with the `align` property. |
There was a problem hiding this comment.
Don't forget to update this to reference "alignment" instead of "align" (or whatever name we decide on). Same thing for other components too
averyjohnston
left a comment
There was a problem hiding this comment.
LGTM once my comment is addressed 👍
|
|
||
| /** | ||
| * How to control the alignment of the checkbox and label on the cross axis. | ||
| * `"start"`: The label and control will appear at the top of the container. |
There was a problem hiding this comment.
"Top of the container" is a little misleading since it's only true for non-stacked label placements. Maybe something like "start of the cross axis"? Or "left side of the cross axis on LTR, or right side on RTL"? (Ditto for the other components.)
| /** | ||
| * Label is on top of the checkbox. | ||
| */ | ||
| :host(.checkbox-label-placement-stacked) .checkbox-wrapper { |
There was a problem hiding this comment.
White space looks strange here (for both the style and the comment block).
There was a problem hiding this comment.
Thanks! Lint doesn't seem to catch it.
core/src/components/range/range.scss
Outdated
| :host(.range-label-placement-stacked) .range-wrapper { | ||
| flex-direction: column; | ||
|
|
||
| align-items: normal; |
There was a problem hiding this comment.
Any reason we used align-items: normal vs. align-items: stretch here?
Functionally they are the same, but normal is harder to descern as it changes the value based on the layout mode.
There was a problem hiding this comment.
I went with normal because it's the default value for align-items. I'll switch it over to prevent any changes based on layout mode.
Issue number: resolves #27229
What is the current behavior?
Checkbox, radio, toggle, and range do not allow labels to be stacked.
What is the new behavior?
alignwas added withcenteras the default1label-placementvalue was addedalignwas added withcenteras the default1label-placementvalue was addedalignwas added withcenteras the default1label-placementvalue was addedlabel-placementvalue was addedDoes this introduce a breaking change?
Other information
Original PR
ion-docsFootnotes
centeris being used becausealign-items="center"was the original style prior to the implementation. Otherwise, the label will not line up correctly on default. For example, the checkbox for iOS will shift the label to the top left corner whenaligndefaulted tostart.2 This shift happens because the input is larger than the label, making the alignment obvious. But this is not correct, the label must be centered vertically as the default to prevent breaking changes to the current visualizations. ↩ ↩2 ↩3