Skip to content

Commit

Permalink
feat(v2): add storybook of checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
phongit-kha committed Oct 13, 2024
1 parent f1e4f14 commit 0bc2261
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions packages/ui/src/components/checkbox/checkbox.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<script context="module" lang="ts">
import type { Meta } from '@storybook/svelte'
import { Checkbox } from './index.js'
export const meta = {
title: 'Atom/Checkbox',
component: Checkbox,
tags: ['autodocs'],
argTypes: {
checked: {
control: 'boolean',
defaultValue: false,
},
label: {
control: 'text',
defaultValue: '',
},
onClick: {
action: 'onClick',
},
},
} satisfies Meta<Checkbox>
</script>

<script lang="ts">
import { Story, Template } from '@storybook/addon-svelte-csf'
</script>

<!--👇 We create a “template” of how args map to rendering -->

<Template let:args>
<Checkbox {...args} />
</Template>

<!-- 👇 Each story then reuses that template -->
<Story name="Unchecked" args="{{ checked: false, label: 'Accept Terms' }}" />

<Story name="Checked" args="{{ checked: true, label: 'Accept Terms' }}" />

<Story name="Unchecked Without Label" args="{{ checked: false }}" />

<Story name="Checked Without Label" args="{{ checked: true }}" />

<Story
name="Disabled Checkbox"
args="{{ checked: false, label: 'Disabled Checkbox', disabled: true }}"
/>

0 comments on commit 0bc2261

Please sign in to comment.