-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Storybook Composition - loading a prebuilt storybook into yours #9210
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/storybook/monorepo/3o33u9dzy |
Hey @ndelangen, would love to add a more "convention over configuration" API. Let's discuss offline before merging. In the meantime will test out what you currently have! |
@shilman let's talk about this in the near future. |
# Conflicts: # scripts/build-storybooks.js
# Conflicts: # scripts/build-storybooks.js
# Conflicts: # examples/official-storybook/package.json # lib/channel-postmessage/package.json # lib/core/package.json
This looks really cool @ndelangen - it's a huge PR, but I get that a lot of this work wouldn't make sense in isolation. I can already see a lot of use-cases for this, from versioning through to framework mixing, and of course importing Storybooks from other sources (such as consumed libraries). @tmeasday, perhaps it's best if we get this in now, then create seperate PR(s) for authentication and UI updates? I think the sooner we get people playing with this, the better. I also feel like there will be quite a few tweaks and changes based on community feedback. |
Yeah, I'm down with that. There were a few outstanding things on the PR, I'm not sure if @ndelangen has addressed them yet? (It's such a beast it's hard to get a quick overview). In any case it's minor stuff now. |
It looked like most had been addressed when I was reviewing yesterday. Norbert walked me through it which helped. @ndelangen was there anything else? |
# Conflicts: # lib/cli/package.json
# Conflicts: # lib/cli/src/extract.js
Storybook is used by teams, and it's actually quite common for multiple teams to work on their own isolated features, possibly in their own storybook. But it's also common these teams will share components between them.
In fact a very common scenario is that you're using some open source components, maybe a component library. They are using storybook, you are using storybook. But if you want to see their components -and the documentation that come with it- you have to go to their website/storybook or write stories for components that aren't yours.
This is wasting time. Storybook should have a mechanism to deal with this.
Presenting: storybook inception!
The new
refs
lists all external (pre-build) storybooks you want storybook to load.The storybook is loaded, and the stories defined in both will appear in the navigator.
Here's one of the challenges I faced: Stories might have the same name, and thus overwrite each other.
The default way storybook now deals with this is by prefixing all stories's kind with the id of the ref that loaded it.
There's a way to tweak this behaviour, because I expect the consumers will want some control over where included stories are placed. Here's how you do it:
If you return
null
then that story will be ignored, and not shown in the navigator.The stories from 1 ref and another are completely isolated. Storybook will actually not merge them together, in fact storybook will load the actual iframes as specified in the ref, and 'juggle' multiple iframes and show the correct iframe for the currently selected story,
Currently this process isn't optimised, which means all refs are loaded from the start.
Once storybook has a way to pull the list of stories statically, we can lazy-load the iframe.
todo still