mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-20 20:59:27 +00:00
homework 1: components
This commit is contained in:
35
src/components/ui/checkbox/checkbox.stories.tsx
Normal file
35
src/components/ui/checkbox/checkbox.stories.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { useState } from 'react'
|
||||
|
||||
import { Meta, StoryObj } from '@storybook/react'
|
||||
|
||||
import { Checkbox } from './checkbox'
|
||||
const meta = {
|
||||
title: 'Components/Checkbox',
|
||||
component: Checkbox,
|
||||
tags: ['autodocs'],
|
||||
} satisfies Meta<typeof Checkbox>
|
||||
|
||||
export default meta
|
||||
|
||||
type Story = StoryObj<typeof meta>
|
||||
export const Uncontrolled: Story = {
|
||||
args: {
|
||||
label: 'Click here',
|
||||
disabled: false,
|
||||
},
|
||||
}
|
||||
|
||||
export const Controlled: Story = {
|
||||
render: args => {
|
||||
const [checked, setChecked] = useState(false)
|
||||
|
||||
return (
|
||||
<Checkbox
|
||||
{...args}
|
||||
label="Click here"
|
||||
checked={checked}
|
||||
onChange={() => setChecked(!checked)}
|
||||
/>
|
||||
)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user