-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support javascript in Svelte Vite docgen
- Loading branch information
Showing
11 changed files
with
146 additions
and
26 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
38 changes: 38 additions & 0 deletions
38
code/frameworks/svelte-vite/template/stories_svelte-vite-default-ts/ButtonTypeScript.svelte
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,38 @@ | ||
<script lang="ts"> | ||
/** | ||
* @component Button TypeScript | ||
* @wrapper | ||
*/ | ||
import { global as globalThis } from '@storybook/global'; | ||
// @ts-ignore | ||
const Button = globalThis.Components?.Button; | ||
/** | ||
* Rounds the button | ||
*/ | ||
export let primary: boolean = false; | ||
/** | ||
* Displays the count | ||
*/ | ||
export let count: number = 0; | ||
/** | ||
* Button text | ||
* @slot | ||
*/ | ||
export let text: string = 'You clicked'; | ||
function handleClick(_event: MouseEvent) { | ||
count += 1; | ||
} | ||
</script> | ||
|
||
<h1>Button TypeScript</h1> | ||
|
||
<Button {primary} on:click on:click={handleClick} label="{text}: {count}" /> | ||
|
||
<p>A little text to show this is a view.</p> | ||
<p>If we need to test components in a Svelte environment, for instance to test slot behaviour,</p> | ||
<p>then wrapping the component up in a view</p> | ||
<p>made just for the story is the simplest way to achieve this.</p> |
12 changes: 12 additions & 0 deletions
12
code/frameworks/svelte-vite/template/stories_svelte-vite-default-ts/ts-docs.stories.js
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,12 @@ | ||
import ButtonTypescript from './ButtonTypeScript.svelte'; | ||
|
||
export default { | ||
title: 'stories/renderers/svelte/ts-docs', | ||
component: ButtonTypescript, | ||
args: { | ||
primary: true, | ||
}, | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export const Primary = {}; |
38 changes: 38 additions & 0 deletions
38
code/frameworks/sveltekit/template/stories_svelte-kit-skeleton-ts/ButtonTypeScript.svelte
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,38 @@ | ||
<script lang="ts"> | ||
/** | ||
* @component Button TypeScript | ||
* @wrapper | ||
*/ | ||
import { global as globalThis } from '@storybook/global'; | ||
// @ts-ignore | ||
const Button = globalThis.Components?.Button; | ||
/** | ||
* Rounds the button | ||
*/ | ||
export let primary: boolean = false; | ||
/** | ||
* Displays the count | ||
*/ | ||
export let count: number = 0; | ||
/** | ||
* Button text | ||
* @slot | ||
*/ | ||
export let text: string = 'You clicked'; | ||
function handleClick(_event: MouseEvent) { | ||
count += 1; | ||
} | ||
</script> | ||
|
||
<h1>Button TypeScript</h1> | ||
|
||
<Button {primary} on:click on:click={handleClick} label="{text}: {count}" /> | ||
|
||
<p>A little text to show this is a view.</p> | ||
<p>If we need to test components in a Svelte environment, for instance to test slot behaviour,</p> | ||
<p>then wrapping the component up in a view</p> | ||
<p>made just for the story is the simplest way to achieve this.</p> |
12 changes: 12 additions & 0 deletions
12
code/frameworks/sveltekit/template/stories_svelte-kit-skeleton-ts/ts-docs.stories.js
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,12 @@ | ||
import ButtonTypescript from './ButtonTypeScript.svelte'; | ||
|
||
export default { | ||
title: 'stories/renderers/svelte/ts-docs', | ||
component: ButtonTypescript, | ||
args: { | ||
primary: true, | ||
}, | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export const Primary = {}; |
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
4 changes: 2 additions & 2 deletions
4
...s/svelte/template/stories/docs.stories.js → ...velte/template/stories/js-docs.stories.js
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
2 changes: 1 addition & 1 deletion
2
code/renderers/svelte/template/stories/slot-decorators.stories.js
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