Replies: 2 comments
-
May I ask what did you mean in your mind with "component functions" and "Storybook functions"? I admit the example from documentation is... confusing. I haven't used Svelte I don't remember why it was this way, but I hope @JReinhold does. Did you also had a chance to take a look at "example" stories file?
I'm spitballing now, but see if:
|
Beta Was this translation helpful? Give feedback.
-
With the example component you're giving here, the button element only ever calls the This is slightly different from the example button in the addon, that also dispatches the If you were to write a story for your component above, I'd do it like this: <script context="module">
import Button from './Button.svelte';
export const meta = {
title: "Button2",
component: Button
}
</script>
<script>
import { Story, Template } from '@storybook/addon-svelte-csf';
import { fn } from '@storybook/test';
const onClickSpy = fn().mockName('onClick');
let count = 0;
function onClick(event) {
count += 1;
onClickSpy(event);
}
</script>
<Template let:args>
<Button {...args}
onClick={onClick}>
You clicked: {count}
</Button>
</Template>
<Story name="Default" /> The |
Beta Was this translation helpful? Give feedback.
-
Hello
I'm wondering if I'm making a mistake or misunderstanding how Storybook should work.
With the following:
And the following story:
Question
I can see Storybook captures the click event. But the counter never increases, and
onClick()
in the story or component never seems to get called.Is this the expected behavior?
Is it possible to have component functions, or storybook functions, called?
Beta Was this translation helpful? Give feedback.
All reactions