-
-
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: Improved decorators #13785
Svelte: Improved decorators #13785
Conversation
d96f829
to
32870f0
Compare
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.
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.
Did not mean to approve this, just ask questions first.
32870f0
to
038a205
Compare
No, it works like before, at least in my tests. Most of this PR is a rewrite of the renderer to use svelte component instead of "hacking internals", and to call the story function inside a svelte context. Storyshots generates the same snapshots, and decorators implemented like in the documentation continue to work as before.
Yes, it works like before.
I am note sure to understand 😅 In svelte/storybook, without the "native svelte format" PR, it's almost always necessary to use in a story a component which is not the component defined in meta - because a story can't define a custom template like in vue or react. What I have done is to make this Component optional, and if it's not set, then I use the component defined in meta. It's not really deprecated. I can add a message if the component in a story is the same component as in meta, but I don't think it's really a deprecation warning, as it will not be removed. |
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.
Hi @j3rem1e thanks for the clarification. Merging!
Issue: None
What I did
Today, writing decorators for svelte is hard:
In a "svelte world", data is passed to child through context, and a decorator has children with a
<slot/>
This PR allow to use a syntax closest to Svelte.
A decorator component can be declared as:
And a decorator for this component is just
() => MarginDecorator
.It's possible to use Svelte context with
() => { setContext('myKey', 'myValue') }
Moreover, this PR:
parameters.component
if available #8673 : If a story doesn't define a component, then the parameters.component is usedHow to test