-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Presets documentation #5333
Presets documentation #5333
Conversation
Seems great |
Codecov Report
@@ Coverage Diff @@
## next #5333 +/- ##
=======================================
Coverage 30.08% 30.08%
=======================================
Files 619 619
Lines 9001 9001
Branches 1230 1248 +18
=======================================
Hits 2708 2708
Misses 5628 5628
Partials 665 665
Continue to review full report at Codecov.
|
@shilman What's happening, are we merging this? |
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.
A very good start =)
I am missing a few words about loading presets, for example that users can pass parameters when configuring them
|
||
## Presets API | ||
|
||
A preset is a set of hooks that is called by Storybook on initialization and can override configurations for `babel`, `webpack`, `addons`, and `entries`. |
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 there any thought or plans for allowing presets to handle addDecorator
or addParameters
calls? My use case is a company with many separate apps, but all fall under the same stack, and my team is in charge of the stack. We'd really like to be able to have a single preset/config that all of our different teams can use (for consistency's sake), and then when we make updates (like when storybook-docs drops) we can update the preset/config in 1 spot, and everyone gets the wonderful changes.
I've tried putting most of my shared configuration into a file and importing it into the .storybook/config.js file, but it appears like it isn't "run" for storybook. Even passing the addDecorator
function from .storybook/config.js into the shared configuration file and calling it in there didn't work.
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.
You should file that as an issue. I'd expect it to work in Storybook. I also think that could be a cool feature to add to presets.
|
||
```js | ||
export function addons(entry = []) { | ||
return [...entry, require.resolve('@storybook/addon-storysource/register')]; |
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.
If I am using the knobs addon here in the exported addons function of the preset I am making, do I still need to use the addDecorator(withKnobs)
in my config.js file? The docs are a little unclear about that in my opinion.
To add onto that thought, should a preset that utilizes the knob addon expose the things the knob addon does? (like boolean
, text
, etc?) Otherwise the consumer of said preset will also need to install @storybook/addon-knobs to get access to them. (is that what is envisioned)
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.
IMO the addons should export their own presets. That's what I'm doing with addon-docs
. So you install the addon and then use its preset. Have not discussed this with @igor-dv regarding storysource.
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.
Okay. I'll make an issue and ask igor about what the expected usage/how to do preset of presets.
Are the packages in https://github.com/storybooks/presets just on the back-burner while more important things are worked on (like storybook-docs?) Are there things that need to occur before those few presets that exist get published to npm? I may be able to spend some time on the presets if that work would be appreciated (and if some guidance could be given for the vision there) |
@joeycozza Yeah the presets are gathering dust. However, I just updated the Typescript preset and published it. 🎉 |
Will .storybook/presets.js replace .storybook/addons.js in the long run? If yes, it should be possible to convert
to
in the future, correct? |
@rwieruch In principle you're correct. In actuality, @ndelangen is working on #4169 which will simplify presets, collapse everything into a single file, and have various performance benefits as well. |
Issue: #5301
What I did
First draft of presets documentation. I think we either need to release some presets before releasing this documentation, or we need to scale things back until we're ready to start releasing some presets.
How to test
N/A