feat: simplify fallback of ui icon size numbers#3571
Conversation
File metricsSummaryTotal size: 1.38 MB* 🎉 No changes detected in any packages * Size is the sum of all main files for packages in the library.* An ASCII character in UTF-8 is 8 bits or 1 byte. |
|
🚀 Deployed on https://pr-3571--spectrum-css.netlify.app |
31dd289 to
ece7e0d
Compare
ece7e0d to
fb0eeb6
Compare
|
d5e72d4 to
0f14273
Compare
fb0eeb6 to
7d26ca1
Compare
3499231 to
ad861d0
Compare
7f7e721 to
a7ad08f
Compare
rise-erpelding
left a comment
There was a problem hiding this comment.
Thank you for all the work you do making icons better! Mostly I have some questions that I'm leaving in the comments that may or may not need addressing.
There was a problem hiding this comment.
I happened across those as well. They are related to the context needing to be passed through to the templates used in Menu (non-ref SVG markup comes from the global loader and its data is in context). I went ahead and just added a commit to fix that.
There was a problem hiding this comment.
Hmmm, I don't see a spot where we're failing to add context, but I'm still getting those warnings locally and in the preview for checkmark and chevron, which seems weird... Accordion uses chevron and it's not having that issue, so it feels like it's more specific to menu and less to icons, what do you think?
There was a problem hiding this comment.
I isolated it to just SubmenuInPopover. It was related to context not actually being passed in to the content array arg of Popover, because of how it was trying to do it as a function (eventually reaching renderContent in the Popover template which then doesn't pass in any args or context). I just updated the existing commit, so those particular warnings should be gone now on the Menu Docs page.
rise-erpelding
left a comment
There was a problem hiding this comment.
Aside from menu still not being able to find the svg markup for chevron and checkmark, I think this is good to go--I'll leave it to you to decide whether this is something that can/needs to be addressed here or can be done separately.
There was a problem hiding this comment.
Hmmm, I don't see a spot where we're failing to add context, but I'm still getting those warnings locally and in the preview for checkmark and chevron, which seems weird... Accordion uses chevron and it's not having that issue, so it feels like it's more specific to menu and less to icons, what do you think?
1887acd to
a39c477
Compare
cdransf
left a comment
There was a problem hiding this comment.
Ran through the validation steps and everything looks good! ✨
If a UI icon was not provided with its full name including sizing number (e.g. Dash100), the template would try and guess at a sizing number based on t-shirt size. This has been extracted out to a utility function and simplified, as this had gotten too complex, with too many exceptions. It no longer strips out any sizing numbers that were specifically provided. docs(icon): log error when icon is not in the icon set Update icon Storybook template with a guard clause so that it logs a warning and returns when the icon is not in the icon set. Previously there was no indication except for not seeing the icon visually. Also renames "idKey" variable to better explain what it is.
- The Arrow icon is now only available in 100 and 400; adjusts which arrow number size is displayed for each component t-shirt size. - The iconWithScale function was only the mapping for the arrow and was incorrectly used for the other icons like chevron and checkmark.
The previously referenced UI icon no longer exists in the UI icons package. Replaces with the largest UI icon available.
Use the correct size number for the "Dash" ui icon per t-shirt size of the swatch, according to its S2 design spec.
Make sure the iconset arg is set in a few components that are using the Icon template, otherwise it was passed through as undefined. Also set a default icon set in the templates used.
We have to define specific sizing for the UI icon corner triangle, becauses there is no size 50 for extra small. Fixes XS action button not showing the corner triangle icon.
Display the design recommended "Circle" icon as a placeholder icon when the workflow icon cannot be found. This helps with identifying missing icons in VRTs, so the icon continues to take up the space it should, rather than disappearing entirely in some cases.
Add context that was missing from some menu storybook templates, which was causing a warning within Icon.
a39c477 to
d8a1ef7
Compare

Description
docs(icon): simplify fallback of ui icon size numbers
If a UI icon was not provided with its full name including sizing number (e.g. Dash100), the template would try and guess at a sizing number based on t-shirt size. This has been extracted out to a utility function and simplified, as this had gotten too complex, with too many exceptions. In some cases this was causing the wrong icon to be shown. This function no longer strips out any sizing numbers that were specifically provided.
docs(icon): log error when icon is not in the icon set
Update icon Storybook template with a guard clause so that it logs a warning when the icon is not in the icon set. Previously there was no indication except for not seeing the icon visually. This also renames the "idKey" variable to better explain what it is.
feat(icon): display placeholder icon when workflow icon is missing
Display the design recommended "Circle" icon as a placeholder icon when the workflow icon cannot be found:

This helps with identifying missing icons in VRTs, so the icon continues to take up the space it should, rather than disappearing entirely in some cases. This will help in the transition to the new S2 icons.
This change also updates the templates of a few components to make sure they are rendering the correct UI icon. This focused on components that use the icons whose sizing numbers are outside the normal / default mapping (arrow, asterisk, dash).
As part of this work, I manually ran a chromatic build on this branch and compared it against
spectrum-twoto assist with finding a few of these needed updates.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:
To-do list