generated from storybookjs/addon-kit
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide usage test & fix runtime issues
- Loading branch information
Showing
9 changed files
with
126 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,15 @@ | ||
<script lang="ts"> | ||
import type { Snippet } from 'svelte'; | ||
/** | ||
* This is a legacy template, this functionality is just a "mock". | ||
* To allow user still have typing experience | ||
* Vite pre-transform hook does codemod where this component gets transformed into Svelte v5 SnippetBlock. | ||
*/ | ||
import { useStoryRenderer, type StoryRendererContext } from './contexts/renderer.svelte'; | ||
import { type StoryRendererContext } from './contexts/renderer.svelte'; | ||
interface Props { | ||
/** | ||
* The content of template to be rendered inside the `<Story />` | ||
*/ | ||
children: Snippet< | ||
[ | ||
// | ||
StoryRendererContext['args'], | ||
StoryRendererContext['storyContext'], | ||
] | ||
>; | ||
/** | ||
* Unique id of template - to be used in `<Story templateId={id} />` | ||
* @default id | ||
*/ | ||
id?: string; | ||
} | ||
const renderer = useStoryRenderer(); | ||
let { children, id = 'default' }: Props = $props(); | ||
let id: string = 'default'; | ||
let args: StoryRendererContext['storyContext']; | ||
let context: StoryRendererContext['args']; | ||
</script> | ||
|
||
{@render children(renderer.args, renderer.storyContext)} | ||
<slot {context} {args} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<script context="module" lang="ts"> | ||
import { Template, defineMeta } from '@storybook/addon-svelte-csf'; | ||
import LegacyTemplate from './LegacyTemplate.svelte'; | ||
/** | ||
* Description set explicitly in the comment above `defineMeta`. | ||
* | ||
* Multiline supported. And also Markdown syntax: | ||
* | ||
* * **Bold**, | ||
* * _Italic_, | ||
* * `Code`. | ||
*/ | ||
const { Story } = defineMeta({ | ||
title: 'LegacyTemplate', | ||
component: LegacyTemplate, | ||
tags: ['autodocs'], | ||
}); | ||
</script> | ||
|
||
<script lang="ts"> | ||
let count = $state(0); | ||
function handleClick() { | ||
count += 1; | ||
} | ||
</script> | ||
|
||
<Template let:args let:context> | ||
<p>Using default template</p> | ||
<LegacyTemplate {...args} onclick={handleClick} /> | ||
</Template> | ||
|
||
<Template id="rounded" let:args> | ||
<p>Using rounded template</p> | ||
<LegacyTemplate {...args} onclick={handleClick} rounded /> | ||
</Template> | ||
|
||
<!-- TODO: Need to restore legacy Story first --> | ||
<Story name="Default" {children} /> | ||
|
||
<!-- TODO: Need to restore legacy Story first --> | ||
<Story name="Rounded" children={rounded} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script lang="ts"> | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
interface Props extends HTMLAttributes<HTMLButtonElement> { | ||
rounded?: boolean; | ||
} | ||
let { rounded = false, ...restProps }: Props = $props(); | ||
</script> | ||
|
||
<button class="button" class:rounded {...restProps}> | ||
<strong>{rounded ? 'Round' : 'Square'} corners</strong> | ||
<hr /> | ||
</button> | ||
|
||
<style> | ||
.rounded { | ||
border-radius: 35px; | ||
} | ||
.button { | ||
border: 3px solid; | ||
padding: 10px 20px; | ||
background-color: white; | ||
outline: none; | ||
} | ||
</style> |