-
-
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.
Merge pull request #7673 from storybookjs/7101-docs-svelte-preset
Addon-docs: Svelte example
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { addParameters } from '@storybook/svelte'; | ||
|
||
addParameters({ | ||
docs: { | ||
iframeHeight: 300, | ||
}, | ||
}); |
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
74 changes: 74 additions & 0 deletions
74
examples/svelte-kitchen-sink/src/stories/addon-docs.stories.mdx
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,74 @@ | ||
import { Story, Preview, Meta } from '@storybook/addon-docs/blocks'; | ||
import ButtonView from './views/ButtonView.svelte'; | ||
|
||
# Storybook Docs for Svelte | ||
|
||
Storybook supports every major view layer: | ||
React, Vue, Angular, Ember, React Native, etc. | ||
|
||
Storybook Docs does too. | ||
|
||
<Story id="welcome--welcome" height="400px" /> | ||
|
||
Hallelujah! Svelte is working out of the box without modification. | ||
How you like them apples?! | ||
|
||
Just like in React, we first declare our component. | ||
|
||
<Meta title="Addon/Docs" /> | ||
|
||
## CSF stories | ||
|
||
Here's how we Svelte stories in pure CSF: | ||
|
||
```js | ||
export const rounded = () => ({ | ||
Component: ButtonView, | ||
props: { | ||
rounded: true, | ||
message: 'Rounded text', | ||
}, | ||
}); | ||
|
||
export const square = () => ({ | ||
Component: ButtonView, | ||
props: { | ||
rounded: false, | ||
message: 'Squared text', | ||
}, | ||
}); | ||
``` | ||
|
||
## MDX stories | ||
|
||
Amd here's how `rounded` looks in MDX: | ||
|
||
<Story name="rounded"> | ||
{{ | ||
Component: ButtonView, | ||
props: { | ||
rounded: true, | ||
message: 'Rounded text', | ||
}, | ||
}} | ||
</Story> | ||
|
||
And `square`: | ||
|
||
<Story name="square"> | ||
{{ | ||
Component: ButtonView, | ||
props: { | ||
rounded: false, | ||
message: 'Squared text', | ||
}, | ||
}} | ||
</Story> | ||
|
||
## More info | ||
|
||
For more info, check out the [Storybook Docs README](https://github.com/storybookjs/storybook/tree/next/addons/docs). | ||
|
||
We want your feedback to help make this more useful. | ||
|
||
Follow us on Twitter for more short demos & project updates! ❤️📈🛠 |
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