-
-
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
Svelte: Svelte syntax Component Story Format #7682
Conversation
This pull request is automatically deployed with Now. Latest deployment for this branch: https://monorepo-git-fork-rixo-svelte-csf.storybook.now.sh |
cc @cam-stitt @plumpNation reviews welcome!! 👋 |
Here's my findings & interrogations following my work to configure Babel for Svelte (to fix tests, linting, and address the question of browser support). I've also got an open question about what should be the proper result of a Svelte BabelHere are the requirements that need to be considered regarding Svelte support:
There's another requirement specific to the
In my last commits, I have adapted framework presets to address these requirements, as well as the jest transform and config to fix tests in I'm no Webpack / Babel ninja, so maybe someone who's more familiar with general handling of Babel in SB should take a second look... What should be returned by
|
@rixo Have you dropped this in favour of https://github.com/rixo/svench? |
Looks like it is. |
@rixo so no storybook svelte? we can use Svelte Components inside storybook now, but the controls addon doesn't yet auto-generate arguments :(
@shilman is there a way i can submit a PR to add Svelte support for Controls argument autodetection? where is the autodetection implementation for React/Angular/Vue? i could try to trace from those. |
@BlackFenix2 jump on our discord. I'd love to walk you through it. |
@shilman funny you should mention, i joined the discord server 5 minutes ago. just gotta wait 5 more min... |
@shilman if I haven't driven everyone crazy yet, I could try a shot at finishing this PR after I finish adding autogenerating controls for svelte. This is to write stories in .svelte files? |
i re-uploaded the PR to use a storybook branch here: #12367 i don't see the original author re-engaging with us. |
Thanks @BlackFenix2. Closing this! |
This work lives on here: storybookjs/addon-svelte-csf#1 🚀 |
Issue: #6653
Add support for authoring stories in Svelte format, mirroring MDX story syntax, and exporting result that conforms to CSF. CSF can be imported directly from the
*.stories.svelte
files thanks to a webpack loader.Changes have been applied over existing
app/svelte
andexamples/svelte-kitchen-sink
to preserve support for legacy format and have everything under a single@storybook/svelte
package.What I did
Add a webpack loader that transforms
*.stories.svelte
to CSFAdd
Meta
andStory
svelte components to@storybook/svelte
Change presets to include the svelte CSF loader
Move existing examples using
storiesOf
under legacy (still in the samesvelte-kitchen-sink
example)Add examples using Svelte component syntax
How to test
cd examples/svelte-kitchen-sink yarn storybook
Details
Following discussion in the issue and my first PR #7023, I have adapted the syntax to mirror that of MDX with
Meta
andStory
components.Integrating with CSF removed the need for any extra boilerplate (the new architecture also made the integration effort much simpler on my part since all the tricky things that are not framework specific are now handled directly by the core).
Here's an example of the resulting syntax that this gives us:
With direct import, we get access to a Svelte component that is a preconfigured preview of the target story:
Next steps
The most pressing issue that remains to be addressed (IMO) is babel transpilation. Currently, Svelte components are not transpiled down to ES5; we're using the ES2015 output of Svelte compiler directly. Since those components (e.g. Story, Meta) are used in the browser, that imposes a hard limit on the browsers we can support. And, internally, it also causes interop issues between transpiled code and ES2015 code (transpiled classes cannot extend ES classes).
And then testing, interop with addons (source, docs...), MDX support... The babel issue is probably a blocker for some of these too.