Storybook: Example of how global parameters can be set by a preset

Created on 11 Apr 2020  路  2Comments  路  Source: storybookjs/storybook

Is your feature request related to a problem? Please describe.
I'm currently developing my own preset, and I'd like to override the default addon-docs docs.page parameter with a custom component defined by my preset. I'm currently unsure if this is even possible for a preset to do. I've been able to successfully register a managerEntry and have that effect the global config (https://github.com/newhighsco/storybook-preset/blob/master/src/manager.js), but when I try to do the same for the preview using addParameters seems to have no effect

Describe the solution you'd like
Pointing in the direction of a working example, or alternative solution so that I can preset parameters when I'm installing my custom preset on all Storybook instances in the future

Describe alternatives you've considered
I'm currently using .storybook/preview.js (https://github.com/newhighsco/storybook-preset/blob/master/.storybook/preview.js) to set these parameters, but it would be great to be able to share these common settings between future projects

Are you able to assist bring the feature to reality?
yes, I'd be happy to assist if any changes to code, or documentation, as needed

Additional context
I'm looking at the docs for the current stable version, but if there is anything new in 6.0 that would help me I'd be willing to jump up to the beta and use that

docs presets question / support

Most helpful comment

Awesome, that worked perfectly

All 2 comments

You can look at the addon-knobs preset for an example:

https://github.com/storybookjs/storybook/blob/master/addons/knobs/src/preset/index.ts

It contains two files: preset.ts and addDecorator.ts. The former is the preset itself, which gets added to your main.js, and the latter is code injected by the config preset field.

If you replace addDecorator with a file that calls addParameters and make sure your preset is run AFTER the addon-docs preset, I would expect this to do what you want.

Awesome, that worked perfectly

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moimikey picture moimikey  路  67Comments

ilias-t picture ilias-t  路  73Comments

Gongreg picture Gongreg  路  58Comments

bpeab picture bpeab  路  70Comments

43081j picture 43081j  路  61Comments