SelectMenu icon improvements #965
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is on top of #922 and adds even more improvements. YAY :zany:
1. Introduce
.SelectMenu-icon--checkCurrently we use the
SelectMenu-iconclass specifically for the check icon to show if an item is selected or not. But there have been cases where a SelectMenu uses different icons unrelated to the selected/checked state. This PR:.SelectMenu-iconmore generic. It only cares about the size and margin and can be used for any icon..SelectMenu-icon--checkmodifier class that toggles based on thearia-checked="true"attribute.Above markup renders as:
It allows to mix check and other icons in the same list and have them aligned without fiddling with margin utilities.
Alternatives
Some alternative names instead of
SelectMenu-icon--check:.SelectMenu-icon--checkedmight be confused for adding a state.SelectMenu-icon--selectedsame.SelectMenu--showWhenCheckedcould be used for anything, not just icons. People might expect it to bedisplay: noneby default, instead ofvisibility: hidden. But that would make the text jump.2. Prevent shrinking of the icon
Happens when the text starts to wrap, see #961. A
flex-shrink-0can be used, but might be convenient to "bake that in".Was also wondering if we need some kind of
SelectMenu--truncate. Similar tocss-truncatebut without the need for overridingmax-width. Maybe in another PR as a utility./cc @muan
Closes #961