-
-
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
Update getStorybook to return story parameters #5549
Conversation
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.
From a code perspective there's not much wrong with this, tagging @tmeasday to judge the behaviour of this as he was responsible for the tagged PR.
Codecov Report
@@ Coverage Diff @@
## next #5549 +/- ##
=====================================
Coverage 33.1% 33.1%
=====================================
Files 638 638
Lines 9264 9264
Branches 1340 1318 -22
=====================================
Hits 3067 3067
Misses 5571 5571
Partials 626 626
Continue to review full report at Codecov.
|
Hey @timhaines In v5 there's a new api for getting the stories data complete with parameters: https://github.com/storybooks/storybook/blob/next/lib/client-api/src/story_store.js#L111-L123 Long term I'd like to remove the getStorybook api. Would be happy to merge this PR though in the meantime. |
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 think returning extra data in getStorybook()
is good, but do we need to change the return value of getStories()
? That part doesn't seem as necessary?
PS We use code something like
.getStorybook()
.map(({ kind, stories }) =>
stories.map(({ name }) => {
const { parameters } = storyStore.getStoryAndParameters(kind, name);
Although I'm looking at our code and it says "Annoying to have to do this, we should support this in .getStorybook" so it looks like this change is long overdue ;)
@tmeasday to address your valid concern, I've left Note that |
@ndelangen thanks for the heads up on those two functions. I don't think they can be used as is in place of getStories, as they don't preserve the ordering in the same way getStories returns stories. It's interesting to hear you're planning on deprecating and removing the getStorybook API long-term. Is there anything documented about how you'd like to replace the functionality? |
Closing this in favor of adopting raw() over improving getStorybook(). |
Thanks tim, if were missing any functionality in either The |
Issue:
v4 of Storybook introduced story parameters, but getStorybook doesn't return them. This PR updates getStorybook so it does return parameters.
This allows in-browser consumers to access story parameters with a more supportable
window['__STORYBOOK_CLIENT_API__'].getStorybook()
instead ofwindow['__STORYBOOK_CLIENT_API__']['_storyStore']['_data']
What I did
Updated the getStorybook function to return parameters
How to test
Unit tests