-
Notifications
You must be signed in to change notification settings - Fork 204
feat(pickerbutton): migrate to s2 #4114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(pickerbutton): migrate to s2 #4114
Conversation
🦋 Changeset detectedLatest commit: 13238b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
File metricsSummaryTotal size: 1.43 MB*
File change detailsinfieldbutton
pickerbutton
* An ASCII character in UTF-8 is 8 bits or 1 byte. |
📚 Branch previewPR #4114 has been deployed to Azure Blob Storage: https://spectrumcss.z13.web.core.windows.net/pr-4114/index.html. |
f707f74
to
e4ec7ab
Compare
* These examples use custom icons. The icon on the left is a custom UI icon, and the icon on the right is a custom workflow icon. The size of the icon can also be modified by using the `--mod-icon-size` custom property. Here, `--mod-icon-size` is set to `14px`. | ||
* | ||
* By default, the picker button supports a UI icon. If using a workflow icon, please apply the `.spectrum-PickerButton--workflowicon` class to the picker button to best support the use of a workflow icon. | ||
*/ | ||
export const CustomIcon = PickerIconOptions.bind({}); | ||
CustomIcon.args = { | ||
uiIconName: "ArrowDown100", | ||
workflowIconName: "Calendar", | ||
customStyles: { | ||
"--mod-icon-size": "14px", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the best thing I could come up with to make sure that the icon size would be modifiable for both ui icons and workflow icons was to just use --mod-icon-size
.
We don't do any setting of the icon size in CSS, the template handles it. (There aren't ui icon size tokens, because UI icon size is controlled by the size number appended to the icon name, our icon template is set up so that you can pass a t-shirt size to a UI icon and it ensures that the proper size number is picked.)
c9df23c
to
fafc538
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration looks and feels good! I also like the removal of some unused args and styles in the infield button template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking good! Before I approve, I just wanted to gauge your thoughts on the UI icon comment, limiting users options to mismatch the icon size with the button size.
Nice work!
import metadata from "../dist/metadata.json"; | ||
import packageJson from "../package.json"; | ||
import { PickerGroup } from "./pickerbutton.test.js"; | ||
import { CustomIconTemplate, Template } from "./template.js"; | ||
import { PickerIconOptions, Template } from "./template.js"; | ||
|
||
/** | ||
* The picker button component is used as a dropdown trigger within other components such as [combobox](?path=/docs/components-combobox--docs). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we've already moved combobox off of picker button, should we update this description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kind of thinking it's ok to stay, because our combobox might not be using it, but SWC's is, so it's appropriate to say that it can be the dropdown trigger used within combobox, even if it isn't with ours.
Not to mention the collection of picker button passthroughs I just found in combobox that probably need removing. 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh oh oh. yeah ok, I agree then about not increasing the scope of the PR. It's starting to feel like that popover migration that could've touched like 7 other components.
.changeset/few-candles-sniff.md
Outdated
- `"--mod-picker-button-background-color-key-focus"` | ||
- `"--mod-picker-button-background-color-key-focus-quiet"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit pick, so not blocking or anything, but we don't really need both backticks and quotes here.
--- | ||
|
||
Remove unused key-focus and border mods. Also updates transition to use `background-color` instead of `border-color`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it helpful to mention that mods were removed? is that a breaking change though? If it is, would this be a "major" bump instead of a patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They were all unused, so technically they would have stopped working with the last major bump, even though they were still declared in the file. To me that's why it feels less relevant to name them, but I'm open to other arguments.
But I'm wondering if I need to be a little clearer that this isn't where key-focus and border have been removed, because upon first glance that does make it sound like a major change. I'll add something to the changeset here.
@@ -25,69 +25,58 @@ export default { | |||
options: ["ui", "workflow"], | |||
control: "inline-radio", | |||
}, | |||
iconName: { | |||
uiIconName: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious if picker button should also follow infield button's UI options. There's only 4 ui icons (of varying sizes) available, which prevents users from accidentally mismatching the button size from the UI icon size. Maybe that's not a worry if we add documentation that clearly correlates the picker button t-shirt size to an icon's size (I think clear button has a size table like that)
(this is an XL picker button with an Add75 icon, where Add75 should only be in the S picker button)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, I will add a table, I like that idea. Do you think that's sufficient? You'd still be able to set any size UI icon in Storybook but hopefully more documentation would discourage such uses in the wild.
.spectrum-PickerButton--workflowicon & { | ||
/* don't use padding tokens, rely on flexbox to center icons */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the PR for this or not, but looking ahead to the date picker, there is specific 3px padding in the date picker infield button with a workflow icon. Just wanted to call that out...I don't really know what or if there's a solution. Maybe we need a mod, and we fallback to 0? There's a flex-shrink: 0
- maybe that's got something to do with it? 🤷♀️


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that in date picker, it more or less looks as spec’d, but in the picker button storybook, the icon’s taking up too much space?
If so, this is because the size is being deliberately adjusted to fit the spec in date picker, because the spec'd icon size is 14px by 14px, which looks maybe a little tiny to me, but feels proportionally correct to the size of the infield button (which I think is 20px for the fill size?).
But the default workflow icon size is 20px for medium, which is why it fills it up in the picker button storybook. Since we don't really have guidance that says that workflow icons should always be 14px within infield button and we don't really know what they might be for other sizes (date picker only comes in M, I believe), it felt more natural to just let the workflow icon be its size by default in picker button, then adjust it to match the spec if it's used somewhere like it is in date picker.
But I'd agree that it looks bad. And the best way to control the size is with --mod-icon-size
, so not even a picker button pass through. Definitely open to other ideas on displaying this or controlling icon size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes- that was exactly what I was getting at. Sorry I was being confusing.
I still don't really have much of an answer but...I'm fine with leaving it as is.
.spectrum-PickerButton { | ||
--highcontrast-picker-button-background-color: ButtonText; | ||
--highcontrast-picker-button-icon-color: ButtonFace; | ||
forced-color-adjust: none; /* keeps button from flashing when hovered */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not this again! I think you were the one who figured out this fix, and it's saved us in several components now! 🥳
- separate ui and workflow icon args in order to allow storybook controls for each - remove the old custom icon story - still TODO: fighting with the mod icon size
- use --mod-icon-size for both ui and workflow icons instead - remove padding calculation for workflow icons; if a workflow icon is used, there is no padding but flexbox will center the icon instead - add some custom styles for picker button in datepicker template... do we like the way that works? - use custom sized icons in the custom icon story, to show they work for workflow and ui icons - update the metadata
- Remove quotes from update mods list in changeset - Update infield button changeset to clarify that no styles were harmed here :) - Update docs page to include a mention of date picker and a table for guidance on which size UI icon to use.
e3d4d98
to
13238b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Here, picker button follows in the Spectrum 2 footsteps of its sibling, infield button. This component uses the same design spec as infield button and in some cases may be able to be used interchangeably with it. A further discussion about whether deprecation is a good idea is warranted, but for now, picker button is updated for use in Spectrum 2, and therefore its updated features include:
.spectrum-PickerButton--uiicononly
,.spectrum-PickerButton--icononly
, and.spectrum-PickerButton--textuiicon
classes:.spectrum-PickerButton--uiicononly
class needs to be applied..spectrum-PickerButton--icononly
class has been renamed to.spectrum-PickerButton--workflowicon
to clarify when it should be used. Applying.spectrum-PickerButton--workflowicon
when using a workflow icon instead is recommended, but probably not required. (Reviewer: The main difference is that it removes the padding to better accommodate the workflow icon's size, which differs from the UI icon's size. Please leave feedback on this if that doesn't feel right to you.)--textuiicon
variant which is why that class has been removed..is-open
state hasn't been touched here and can continue to be used as before. (Reviewer: Infield button doesn't have this, I have no issue taking this out or leaving it/documenting further if that's something we think we should do)Picker button also has some updates to its template, storybook, and tests, to include:
There's also some additional work that happened with other components throughout the course of migrating the picker button:
isInvalid
were removed from the infield button template.border-color
, since this would not have any effect, this has been changed tobackground-color
instead.forced-color-adjust: none
, since the WHCM styles were copied from infield button, infield button had the same bug, soforced-color-adjust: none
was applied there too.CSS-771
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
Pulling down the branch locally or checking out the deploy preview, confirm the following:
forced-color-adjust: none
in WHCMRegression testing
Validate:
Screenshots
To-do list