-
Notifications
You must be signed in to change notification settings - Fork 32
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
refactor!: Story children
becomes static & add template
prop
#228
base: next
Are you sure you want to change the base?
Conversation
fix type errors & add `TemplateSnippet` & document
@JReinhold I need a second eye. I'm not sure if I have overlooked anything. The only thing I didn't try to achieve in this PR is allowing passing a string to |
{#if children} | ||
{@render children(renderer.args, renderer.storyContext)} | ||
{:else if template} | ||
{#if template && isSnippet(template)} |
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.
we have 3 different props relevant here
template, children and component (via renderer.storyContext)
My understanding would be
- if template exists, render it and pass children along
- if component exists, render it and pass children along
- if children exists, render it
now this favors the component over a static story, the case where you have both component and children set is a bit of a conflict of interest, you have to take a guess if the user wants to render a static story overriding the default component or wants to pass the children prop into the default component.
Maybe this needs a <Story static>
or <Story forwardChildren>
prop to make it explicit/configurable?
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.
Let me see if I understand what you're proposing.
With the following case:
<script module>
import { defineMeta } from "@storybook/addon-svelte-csf";
import Button from "./Button.svelte";
<!-- 👆 default component 👇 for the stories file -->
const { Story } = defineMeta({ component: Button });
</script>
<Story name="Default">
Click me
</Story>
The following piece:
<Story name="Default">
<span>Click me</span>
</Story>
Will produce:
<Button>
<span>Click me</span>
</Button>
Now, with the suggestion of adding a new static
boolean flag prop to Story
like this:
<Story name="Default" static>
<span>Click me</span>
</Story>
Will produce:
<span>Click me</span>
Did I get this right?
Note
Concluded by feedback discussion thread on Discord
TODO
examples/
📦 Published PR as canary version:
5.0.0--canary.228.a0b0a96.0
✨ Test out this PR locally via: