-
-
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.
- Loading branch information
1 parent
88ec0f5
commit 0690b24
Showing
5 changed files
with
54 additions
and
8 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
19 changes: 19 additions & 0 deletions
19
examples/svelte-kitchen-sink/src/stories/addon-actions.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,19 @@ | ||
import { storiesOf } from '@storybook/svelte'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
import ButtonView from './views/ButtonView.svelte'; | ||
import Button from '../components/Button.svelte'; | ||
|
||
storiesOf('Addon|Actions', module) | ||
.add('Action on view method', () => ({ | ||
Component: ButtonView, | ||
methods: { | ||
onButtonClicked: action('I am logging in the actions tab'), | ||
}, | ||
})) | ||
.add('Action on component method', () => ({ | ||
Component: Button, | ||
methods: { | ||
onClick: action('I am logging in the actions tab too'), | ||
}, | ||
})); |
24 changes: 21 additions & 3 deletions
24
examples/svelte-kitchen-sink/src/stories/views/ButtonView.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 |
---|---|---|
@@ -1,14 +1,32 @@ | ||
<Button rounded="{true}">{message}</Button> | ||
<h1>Button view</h1> | ||
<Button rounded="{true}" on:click="onButtonClicked(event)">{message} {count}</Button> | ||
<p>A little text to show this is a view. If we need to test components in a Svelte | ||
environment, for instance to test slot behaviour, then wrapping the component up | ||
in a view made just for the story is the simplest way to achieve this.</p> | ||
|
||
<script> | ||
import Button from '../../components/Button.svelte'; | ||
export default { | ||
data() { | ||
return { | ||
message: 'Default text' | ||
count: 0, | ||
message: 'You clicked:' | ||
}; | ||
}, | ||
components: { Button } | ||
methods: { | ||
onButtonClicked(event) { | ||
let {count} = this.get(); | ||
count += 1; | ||
this.set({count}) | ||
} | ||
}, | ||
components: { | ||
Button | ||
} | ||
}; | ||
</script> |