forked from storybookjs/storybook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(web-components): kitchen sink dynamic source example
- Loading branch information
1 parent
b66e3b2
commit d1039bc
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
.../web-components-kitchen-sink/src/stories/addons/docs/dynamic-source.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,42 @@ | ||
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
import { html } from 'lit-html'; | ||
|
||
<Meta | ||
title="Addons / Docs / Dynamic Source" | ||
component="sb-button" | ||
argTypes={{ | ||
size: { type: 'select', options: ['large', 'small'] }, | ||
label: { type: 'string' }, | ||
primary: { type: 'boolean' }, | ||
backgroundColor: { type: 'color', presetColors: ['white', 'transparent', 'blue'] }, | ||
}} | ||
/> | ||
|
||
# Dynamic Source | ||
|
||
Stories can use Dynamic Source to display the result of changes to controls. | ||
|
||
<Canvas withSource="open"> | ||
<Story | ||
name="Button" | ||
component="sb-button" | ||
args={{ | ||
size: 'large', | ||
label: 'Button', | ||
primary: false, | ||
backgroundColor: undefined, | ||
}} | ||
> | ||
{(args) => html` | ||
<sb-button | ||
?primary="${args.primary}" | ||
.size="${args.size}" | ||
.label="${args.label}" | ||
.backgroundColor="${args.backgroundColor}" | ||
> | ||
</sb-button> | ||
`} | ||
</Story> | ||
</Canvas> | ||
|
||
<ArgsTable story="Button" /> |