We have only just begun to use Storybook, so I'm honestly not even sure the feasibility of what I'm about to ask.. 🙃
Is your feature request related to a problem? Please describe.
We would like to offer a storybook view that shows a grid of our buttons with various themes and states. Something like this:
Describe the solution you'd like
I would like to pass an array of selectors rather than just one.
export const simpleButton = () => ({
component: TsButtonComponent,
template: `
<ts-button id="btn1">My Button</ts-button>
<ts-button id="btn2" theme="secondary">My Button</ts-button>
<ts-button id="btn3" theme="warning">My Button</ts-button>
`,
parameters: {
withPseudo: {
selector: ['#btn1', '#btn2', '#btn3'],
},
},
}
Describe alternatives you've considered
We've seen suggestions from Chromatic that include generating classes for pseudo states (https://www.chromatic.com/docs/hoverfocus#css-class-name) but a) this requires us to ship storybook specific CSS to consumers, and b) it only works if the top level wrapper is the one that needs pseudo states.
For us, the top level DOM element rarely is the one getting user interaction. So it is not as simple as:
ts-button {
button {
&.storybook-hover,
&:hover {
color: red;
}
}
}
<ts-button id="one" class="storybook-hover">My Button</ts-button>
We would need to either
a) add @Input
s to all the components that adds these custom classes to the wrapper element,
or
b) duplicate the pseudo styles separately for the top level:
ts-button {
&.storybook-hover {
button {
color: red;
}
}
button {
&:hover {
color: red;
}
}
}
Again, really digging this addon. I'm honestly surprised this addon hasn't been rolled back into core. It seems like such a useful feature for everyone!