-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added storybook for checbox component
- Loading branch information
1 parent
8a79474
commit 1b97fca
Showing
2 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { StoryObj, Meta } from "@storybook/react"; | ||
import { Checkbox } from "../../lib/main"; | ||
import { useState } from "react"; | ||
|
||
const meta = { | ||
title: "Components/Checkbox", | ||
component: Checkbox, | ||
parameters: { layout: "centered" }, | ||
tags: ["autodocs"], | ||
args: { | ||
checked: false, | ||
className: "", | ||
label: "Get updates about Deriv products, services and events.", | ||
onChange: () => {}, | ||
wrapperClassName: "", | ||
}, | ||
argTypes: { | ||
wrapperClassName: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
className: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
checked: { | ||
control: { | ||
type: "boolean", | ||
}, | ||
}, | ||
onChange: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
label: { | ||
control: { | ||
type: "text", | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof Checkbox>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
name: "Default Checkbox Input", | ||
args: { | ||
checked: false, | ||
onChange: () => {}, | ||
label: "Get updates about Deriv products, services and events.", | ||
}, | ||
render: (args) => { | ||
const [checked, setChecked] = useState(false); | ||
|
||
return ( | ||
<Checkbox | ||
{...args} | ||
checked={checked} | ||
onChange={() => setChecked(!checked)} | ||
/> | ||
); | ||
}, | ||
}; |