-
Notifications
You must be signed in to change notification settings - Fork 196
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(storybook): custom decorators for chromatic coverage #2379
Conversation
🚀 Deployed on https://pr-2379--spectrum-css.netlify.app |
File metricsSummaryTotal size: 3.97 MB* 🎉 No changes detected in any packages * Size determined by adding together the size of the main file for all packages in the library.* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got through BG colors and text direction, will plan to continue tomorrow.
Really excited for this! I think it will help a lot to have this coverage.
|
||
if (showBothScales) { | ||
return html` | ||
<div style="margin-bottom: 1rem" class=${mediumClass}> |
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.
// prep the display areas with the correct classes | ||
const isExpress = args.express; | ||
|
||
const backgroundColorClassNames = ['spectrum--light', 'spectrum--dark', 'spectrum--darkest']; |
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.
will including darkest cause issues when we move to s2 and no longer support darkest?
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.
Good callout! I can probably make this dynamic.
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.
With everything on, ltr + rtl, stacked, and medium + large, I was surprised how well everything displayed.
The popover/modal/is-open components consistently do not display well with any of the multiple or both.
(Alert Dialog, Alert Banner, CoachMark, Color Loupe, ComboBox, Contextual help, Datepicker, Dialog, Menu: tray submenu, Modal, Picker, Popover, Search within, Tray, Underlay)
const DIRECTIONS = { | ||
left: 'ltr', | ||
right: 'rtl', | ||
both: 'both', |
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.
displaying both directions does cause issues with modal components, (modal, dialog, or alert dialog). For alert dialog I observed it displaying both buttons, but only the rtl modal would appear regardless of the button used.
Are we okay with this being a known issue?
Is there a way to disable buttons for certain components?
const SCALES = { | ||
medium: 'medium', | ||
large: 'large', | ||
both: 'both', |
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.
similar both issue here as commented in text direction, modal component display on top of each out.
I am also seeing some issues with text colors not adjusting for color theme when displaying multiple background colors. Well: if you toggle the individual background layers in controls the font adjusts correctly but if you display all 3 the font is displaying incorrectly on dark and darkest. Same thing with:
|
Good catch. I've been researching and trying different things to fix this. Here's what I'm finding:
So I'm about to push up a bandaid fix with logic that says if the component is a popover/fullscreen component, instead of rendering the component, we render an error that the feature is unavailable for that component. Not my favorite... Jenn and I also chatted a bit about how if popovers were static, the issues around them in this context would be more manageable. But making them static means losing the example of interaction and animation that are CSS based. It's almost like we need an extra story for each popover instance that shows it statically to be able to show a bunch of them on a single page for Chromatic. Which makes me wonder more about a Chromatic-only Storybook instance like react-spectrum has. Our hope, or at least my hope, with using custom decorators was that it wouldn't be much to manage moving forward compared to a separate Storybook instance for Chromatic, but the way things are heading I wonder if the management level might be more similar than initially expected. |
Overall, this work will increase our Chromatic coverage without increasing our number of snapshots by showing LTR and RTL, all three background colors, both platform sizes, and every available size of component to Chromatic by default. - Implement custom decorators for background color, platform scale, and text direction - Turn off controls when custom decorators are in use in the toolbar - Turn on size decorator so Chromatic tests components at each size in one snapshot
…r settings Kind of a bandaid fix. See comment #2379 (comment). - Add utilities for finding component IDs for fullscreen and popover components - Don't render fullscreen and popover components when multiple/both option from toolbar is selected - Instead, render an error message instructing user to choose a single-setting toolbar option
c650a7c
to
3843556
Compare
This is some really fantastic work! I'm sorry I didn't realize it was going on. One thing I wanted to note is that in the rework of the build systems and architecture that I've been doing, they each include pulling out decorators into distinct files to make maintaining them easier (it also gives us a chance to publish them separately at some point for the greater Storybook community to leverage). See this PR for an example: #2398 One thing I've done in that PR is tried to create a utility for styling the wrapper element to facilitate groupings for Chromatic - I did this by setting flex box layout on the storybook wrappers but allowing components to opt-out or alter it using a |
Here's some more readable documentation on the wrapper styles approach I mentioned above: https://github.com/adobe/spectrum-css/pull/2398/files?short_path=de90dbe#diff-de90dbe4186cda8c8dfb22049ae90250d47d1d38c8b61f151d9787cf49186b6b |
Description
Overall, this work will increase our Chromatic coverage without increasing our number of snapshots by showing LTR and RTL, all three background colors, both platform sizes, and every available size of component to Chromatic by default.
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
Text direction @jenndiaz
ltr
is active (the default), the component has the ltr directionrtl
is active, the component have the rtl directionltr + rtl
is active, there are two components showing, one is ltr and the other is rtlBackground color @jenndiaz
default bg color
is active, the background is Lightdefault bg color
is active, the background color can be changed in the control panelstacked bg colors
is active, the background color cannot be changed in the control panel (it shouldn't even show as a control)stacked bg colors
is active, the component shows three times with our three different background colors, stacked one on top of the otherside-by-side bg colors
is active, the background color cannot be changed in the control panel (it shouldn't even show as a control)side-by-side bg colors
is active, the component shows three times with our three different background colors, side by sidedefault bg color
, the control should show back up in the control panel. If you adjust it, the component adjusts accordingly.Platform sizes @jenndiaz
medium - desktop
is active, the component shows at the medium platform sizemedium - desktop
is active, the platform size can be changed in the control panellarge - mobile
is active, the component shows at the large platform size (usually a bit bigger visually)large - mobile
is active, the platform size cannot be changed in the control panel (it shouldn't even show as a control)medium + large
is active, two components show, with a heading of "Platform Size: Size", and one is medium and the other is large (in alignment with their heading)medium + large
is active, the platform size cannot be changed in the control panel (it shouldn't even show as a control)medium - desktop
, the control should show back up in the control panel. If you adjust it, the component adjusts accordingly.Testing together!
Try some combinations of the controls:
ltr + rtl
,side-by-side bg colors
, andmedium + large
to see what Chromatic will seeRegression testing
Validate:
To-do list