-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add interaction stories for buttons, number field, and anchor #1919
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mollykreis I would ask Malcolm, but he's out this week, so can you please buddy for me? |
mollykreis
reviewed
Mar 13, 2024
packages/nimble-components/src/menu-button/tests/menu-button-matrix.stories.ts
Outdated
Show resolved
Hide resolved
packages/nimble-components/src/number-field/tests/number-field-matrix.stories.ts
Outdated
Show resolved
Hide resolved
packages/nimble-components/src/toggle-button/tests/toggle-button-matrix.stories.ts
Outdated
Show resolved
Hide resolved
mollykreis
reviewed
Mar 14, 2024
packages/nimble-components/src/number-field/tests/number-field-matrix.stories.ts
Outdated
Show resolved
Hide resolved
packages/nimble-components/src/number-field/tests/number-field-matrix.stories.ts
Outdated
Show resolved
Hide resolved
packages/nimble-components/src/number-field/tests/number-field-matrix.stories.ts
Outdated
Show resolved
Hide resolved
packages/nimble-components/src/menu-button/tests/menu-button-matrix.stories.ts
Outdated
Show resolved
Hide resolved
packages/nimble-components/src/toggle-button/tests/toggle-button-matrix.stories.ts
Outdated
Show resolved
Hide resolved
mollykreis
approved these changes
Mar 14, 2024
1 task
rajsite
reviewed
Mar 18, 2024
packages/nimble-components/src/menu-button/tests/menu-button-matrix.stories.ts
Outdated
Show resolved
Hide resolved
rajsite
reviewed
Mar 18, 2024
rajsite
approved these changes
Mar 27, 2024
rajsite
reviewed
Mar 27, 2024
…ub.com/ni/nimble into users/makinc/storybook-pseudo-states-2
jattasNI
approved these changes
Mar 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request
🤨 Rationale
Part of #495
👩💻 Implementation
I had to make some changes in
storybook-addon-pseudo-states
to support our styling, but now we can pull in that fixed release and add some initial visual tests.The way the addon typically works is that you set story parameters to select which component(s) should have the pseudo-state styling, e.g.
However, this does work well with our matrix story approach. The effect of these parameters is just to set certain classes on the indicated elements. So, instead, we can bypass the story parameters and directly apply the classes to our elements. For example, any element with the class
hover
orpseudo-hover-all
will be styled by the addon as if hovered.NOTE: Because we have to put the classes directly on the elements in our Story html, we can't put them on any shadow DOM elements, e.g. the inc/dec buttons of the number field. However, puting
pseudo-<state>-all
on a host element will cause all elements in its shadow DOM to be styled as if they have that state. This can create some visuals that are practically impossible (e.g. a number field and both of its inc/dec buttons all having keyboard focus at the same time), but they are still useful from a visual testing standpoint.The pseudo-states supported by the addon are:
:hover
:active
:focus-visible
:focus-within
:focus
:visited
:link
:target
It is only interesting to test states that we specifically style for, so generally, that is hover, active, and some form of focused. Because our components use both
:focus-visible
(focusVisible
from FAST) and:focus-within
, I'm not distinguishing the two, and I'm setting classes for both whenever we want to see "focused" styling. We could potentially test all combinations of these pseudo-states, but that seems unnecessary, especially considering that we want to test these states in conjunction with other appearance/config variations. So I'm limiting combination testing to just hovered+active, since that is a common use case for mouse-based interaction. To summarize, that means I'm proposing we test:Initially, I'm adding new test matrix stories for:
These seemed to be some of the more interesting components in terms of having distinct keyboard-focused and/or active states, (in addition to hover, which applies to most/all? components).
Some combinations of interaction states with control attribute values aren't interesting, e.g. a disabled control with focus or active interaction state. In order to exclude certain combinations, we had to refactor the
createMatrix
utility function and introduce a newcreateMatrixInteractionsFromStates
function.🧪 Testing
Storybook visual tests
✅ Checklist