-
-
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
Source-loader: Overhaul to remove decorators, support user-configurable source #9547
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/storybook/monorepo/9i4evbn98 |
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.
THIS IS AWESOME!!!
I think we can make a few more tweaks (see comments), but it's a HUGE improvement 😍
} | ||
export const StoryPanel: React.FC<StoryPanelProps> = ({ api }) => { | ||
const [state, setState] = React.useState<SourceParams & { currentLocation?: SourceBlock }>({ | ||
source: 'loading source...', |
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 way to detect when the source-loader failed and show an error message?
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.
maybe if no source code is found at all in the storySourc parameter?
kind?: string; | ||
parameters?: { | ||
storySource?: SourceParams; | ||
mdxSource?: string; |
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.
while we're cleaning this up, maybe we can get rid of mdxSource
? i think now you support an empty locationsMap, so we can put the MDX source in storySource.source
and it's a lot cleaner.
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.
it might break some code, no?
I saw examples in the code like:
two.story.parameters = { mdxSource: '<Button>Two</Button>' };
@shilman - checked in the updated code, without the removal of |
For
|
@atanasster Removing |
@shilman - yes, makes sense. Would you like to first merge this PR, its gotten quite large already and remove mdxSource in another PR? |
@atanasster sounds good. will do! |
Amazing job on this! Didn't mean to close the PR at all. Really appreciate the source-loader getting an improvement like this! |
Cool, its not an improvement, its a re-design and a rewrite and i would really appreciate this getting merged in the alphas to get some testing. Its a lot of work, including the full typescript rewrite of the source addon. |
And just in case its missed - the source-loader was doing ungodly things manipulating the source code, probably useful at the time, but now affecting both for performance and usability and a rewrite was a bit overdue. |
@atanasster Thanks for your patience on this. I'm merging this with the understanding that this is the start of an iterative process, but that merging & releasing will get the ball rolling. We need to figure out a good process for experimenting with new code. You suggested an "experimental" branch, but it's already cumbersome enough to patch changes back and forth between In this case, the follow-up work probably includes:
There's probably more, but I trust that we can figure it all out over the coming weeks. |
🎉 |
Thanks a bunch @shilman as we discussed this was blocking me from testing the default ‘knobs-2’ passing props as the first parameter to storyFn I am a happy camper again, sorry for venting my frustration. |
Issue:
What I did
parameters: { storySource: { source, locationsMap } }
are usedHow to test
Hopefully all should work as before, just less code generated and less possible sources of issues.
I am not that familiar with older formats - if you have stories using storiesOf or any third-party addons using source-loader would be great help.