Howdy, I'm pretty close to finishing a pretty neat feature that I'm using on my storybook. I'd like to wrap it up into an addon so I can reuse it on other projects. In a nutshell it:
- Lets you load
*.story.src.js files as 'stories'.
- These files just export a component that should be the story example.
- It then loads those same files using both prismjs-loader and raw-loader.
- It uses those to create syntax-highlighted code blocks showing you how the story is coded as well as parsing the original story source code for the first docblock.
- This docblock is expected to follow a convenient format that provides the info needed to call
storiesOf() with the proper category and whatnot.
- The rest of the dockblock is assume to be a markdown description of the story.
See it in action here: https://terraeclipse.github.io/react-stack/?selectedKind=Mapbox&selectedStory=Controls&full=0&down=1&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel
And the relevant code can be found here: https://github.com/TerraEclipse/react-stack/blob/master/tools/.storybook/util/loadSourceStories.js
I'm not too familiar with the addon API, so I'm not sure exactly how I'd ship this. It requires the prismjs-loader to be available. In theory then my 'addon' could just export a function you call and pass your directory to with possibly a customizable regex.
Howdy, I'm pretty close to finishing a pretty neat feature that I'm using on my storybook. I'd like to wrap it up into an addon so I can reuse it on other projects. In a nutshell it:
*.story.src.jsfiles as 'stories'.storiesOf()with the proper category and whatnot.See it in action here: https://terraeclipse.github.io/react-stack/?selectedKind=Mapbox&selectedStory=Controls&full=0&down=1&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel
And the relevant code can be found here: https://github.com/TerraEclipse/react-stack/blob/master/tools/.storybook/util/loadSourceStories.js
I'm not too familiar with the addon API, so I'm not sure exactly how I'd ship this. It requires the
prismjs-loaderto be available. In theory then my 'addon' could just export a function you call and pass your directory to with possibly a customizable regex.