Description
Provide a general summary of the feature here
When creating component documentation, e.g. using storybook,
I want to create a story that show the component in various states.
For example, creating a story for a button, and showing how it looks like normally, when pressed, when hover, when focused, etc.
I couldn't do that write now because using css selector doesn't change the state
object in:
<Button className={(state) => ...}/>
And the ButtonContext
doesn't seem to work with UI states:
<ButtonContext.Provider value={{ isPressed: true, isDisabled: true }}>
<Button
className={(state) => {
console.log('state', state)
return ''
}}
>
Click me
</Button>
</ButtonContext.Provider>
It prints isDisabled: true
but isPressed: false
. Also it does not have other states (like isFocusVisible
).
I can do it if I break it down to one story per component per state, and use user.event()
to cause the state change.
But the number of stories will explode and it is very hard to navigate.
🤔 Expected Behavior?
Have a way to do that.
😯 Current Behavior
No good way to do that statically.
💁 Possible Solution
Maybe provide a <UIStateContext.Provider/>
🔦 Context
Creating a nice documentation
💻 Examples
No response
🧢 Your Company/Team
Palo Alto Networks
🕷 Tracking Issue
No response