feat(button): add label text wrap option#3086
Conversation
🦋 Changeset detectedLatest commit: 1308f38 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
🚀 Deployed on https://pr-3086--spectrum-css.netlify.app |
File metricsSummaryTotal size: 4.11 MB* Table reports on changes to a package's main file. Other changes can be found in the collapsed Details section below.
Detailsbutton
* Results are not gzipped or minified. * An ASCII character in UTF-8 is 8 bits or 1 byte. |
There was a problem hiding this comment.
I think the nowrap CSS should work here. This and the added control look good!
Could you make sure that we have this included in the VRTs, by adding a noWrap: true test in the button.test.js file? It will need either a set width on the wrapperStyles, or a min-inline-size like the text overflow examples in order for wrapping to happen. When added it'll be viewable on the Default story with "Show testing preview" turned on.
|
|
||
| /* Disable button label wrap */ | ||
| .spectrum-Button--noWrap { | ||
| justify-content: flex-start; |
There was a problem hiding this comment.
@jawinn When the max-inline-size is set all the button content gets cut off from left and right edges of the container. I was thinking of doing a flex-start and overflow additions it'll show the dev the text is too long and they need to make an adjustment character wise.
After some thought, I'm going to remove this because it's not a design specification and I don't want teams to get mislead in anyway.
There was a problem hiding this comment.
I do think what you had, .spectrum-Button-label { overflow: hidden; text-overflow: ellipsis; } is a good idea. I think we should handle the text overflow for cases where the button's width is constrained, as it gets a bit broken as seen in the Chromatic testing view right now. Does it work okay with just those two properties?
There was a problem hiding this comment.
@jawinn Yes, they work with just these two properties.
| staticColor, | ||
| noWrap: { | ||
| name: "Disable label wrap", | ||
| description: "Used only to keep the button label text in one line. It is intended to have the label wrap as it is part of design specifications.", |
There was a problem hiding this comment.
| description: "Used only to keep the button label text in one line. It is intended to have the label wrap as it is part of design specifications.", | |
| description: "Used to keep the button label text on one line. Note that this option is not a part of the design specifications which intend for the label to wrap. Use with care and consideration of this option's overflow behavior and the readability of the button's content.", |
| Adds the ability to disable text wrapping within the button component's label by applying the class `.spectrum-Button--noWrap` to `.spectrum-Button`. | ||
|
|
||
| If the text is longer than the button container an ellipsis `...` indicator will show. Please adjust text length and `max-inline-size` of the button container. |
There was a problem hiding this comment.
| Adds the ability to disable text wrapping within the button component's label by applying the class `.spectrum-Button--noWrap` to `.spectrum-Button`. | |
| If the text is longer than the button container an ellipsis `...` indicator will show. Please adjust text length and `max-inline-size` of the button container. | |
| Adds the ability to disable text wrapping within the button component's label by applying the class `.spectrum-Button--noWrap` to `.spectrum-Button`. If the text overflows the maximum allowed width of the button, an ellipsis `...` indicator will show. Please note that this option is not a part of the design specification and should be used carefully, with consideration of this overflow behavior and the readability of the button's content. |
I was unclear about what the last "Please..." sentence was suggesting the user should do. I took a shot at rewording a bit, with a bit more warning.
| @@ -0,0 +1,5 @@ | |||
| --- | |||
There was a problem hiding this comment.
Oh interesting that two of these got generated. I think we could delete one of them, as they're signifying the same changes. Maybe remove this one.





Description
How and where has this been tested?
Please tag yourself on the tests you've marked complete to confirm the tests have been run by someone other than the author.
Validation steps
Regression testing
Validate:
Screenshots
To-do list