fbredius/storybook

View on GitHub
examples/svelte-kitchen-sink/src/stories/views/ButtonView.svelte

Summary

Maintainability
Test Coverage
<script>
  /**
   * @component Button View
   * @wrapper
   */
  import Button from '../../components/Button.svelte';


  /**
   * Rounds the button
   */
  export let rounded = false;

  /**
   * Displays the count
   */
  export let count = 0;

  /**
   * Button text
   * @slot
   */
  export let text = 'You clicked';

  function handleClick(event) {
    count += 1;
  }
</script>

<h1>Button view</h1>
<Button {rounded} on:click={handleClick}>{text}: {count}</Button>
<p>A little text to show this is a view.</p>
<p>If we need to test components in a Svelte environment, for instance to test slot behaviour,</p>
<p>then wrapping the component up in a view</p>
<p>made just for the story is the simplest way to achieve this.</p>