-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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: Ability to combine presets into another preset #6828
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/storybook/monorepo/85f3yi05n |
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.
Pretty nice -- great work! 👍
Let's merge this later for 5.2
@igor-dv Let's say I'm making a preset-foo that uses preset-typescript and preset-knobs under the hood. Now app Bar is using my preset-foo in their .storybook/presets.js file. Question 1) Does the Bar app still need to do the following? If not, what is the mechanism to use addDecorator within a preset? //Inside the Bar app's .storybook/config.js file
import { addParameters, addDecorator } from '@storybook/react'
import { withKnobs } from '@storybook/addon-knobs'
addDecorator(withKnobs) Question 2) The Bar app will want to utilize knobs like Thanks for your help and clarification! |
@joeycozza , sorry for the delay.
// this will customise the preview entry point
export function config(entry = []) {
return [
require.resolve('./path/to/knobs-config.js'),
// "entry" here will contain a config.js from the .storybook dir,
// so you need to configure before or somehow skip it.
// maybe we need to have a preset for that =)
...entry,
]
}
// this is an alternative for "addons.js"
export function addons(entry = []) {
return [
...entry,
require.resolve('@storybook/addon-knobs/register')
];
} where the import { addDecorator } from '@storybook/react'
import { withKnobs } from '@storybook/addon-knobs'
addDecorator(withKnobs)
Does it answer your question ? |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
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.
👍
I'm working on this to be aligned with #8597 |
presets can now export presets like this: // preset.js
module.exports = ['preset1', 'preset2']; but also like so: // preset.js
module.exports = {
presets: ['preset1', 'preset2'],
otherValue: true,
}; |
Issue: We want to be able to combine presets into another custom preset file, so it will be easier to customise them.
What I did
Currently we support preset file to be something like this:
or
In both options an object is exported from the module.
Now, we can export an array, which means we are exporting a set of presets out of preset (yo dawg)