fbredius/storybook

View on GitHub
docs/snippets/svelte/button-story-default-docs-code.mdx.mdx

Summary

Maintainability
Test Coverage
```md
<!-- Button.stories.mdx -->

import { Meta, Story } from '@storybook/addon-docs';

import Button from './Button.svelte';

<!-- 👇 Creates specific argTypes -->
<Meta
  title="Button"
  component={Button}
  argTypes={{
    backgroundColor: {
      control: 'color',
    },
  }}
/>

<!-- 👇 Some function to demonstrate the behavior -->
export const someFunction = (someValue) => {
  return `i am a ${someValue}`;
};


<!-- 👇 Destructure the label from the args object and assigns the function result to a variable and pass it as a prop into the component -->
<Story
  name="ExampleStory"
  args={{
    primary: true,
    size: 'small',
    label: "button",
  }}>
  {(args) => {
    const { label } = args;
    const functionResult = someFunction(label);
    return {
      Component: Button,
      props: {
        ...args,
        label: functionResult,
      },
    };
  }}
</Story>
```