-
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.
Merge pull request #54 from deriv-com/aizad/storybook-input
Aizad/ Adding Storybook to Input component
- Loading branch information
Showing
4 changed files
with
187 additions
and
2 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
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,179 @@ | ||
import { StoryObj, Meta } from "@storybook/react"; | ||
import { Input } from "../../lib/main"; | ||
import { useState } from "react"; | ||
|
||
const meta = { | ||
title: "Components/Input", | ||
component: Input, | ||
parameters: { layout: "centered" }, | ||
tags: ["autodocs"], | ||
args: { | ||
label: "Enter Password", | ||
value: "", | ||
variant: "general", | ||
message: "This is a helper message", | ||
error: false, | ||
disabled: false, | ||
}, | ||
argTypes: { | ||
leftPlaceholder: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
rightPlaceholder: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
value: { | ||
control: { | ||
disable: true, | ||
}, | ||
}, | ||
variant: { | ||
options: ["general", "success", "warning", "error"], | ||
control: { | ||
type: "select", | ||
}, | ||
}, | ||
message: { | ||
control: { | ||
type: "text", | ||
}, | ||
}, | ||
error: { | ||
control: { | ||
type: "boolean", | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof Input>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
name: "Default Input", | ||
args: { | ||
label: "Enter name", | ||
value: "", | ||
message: "This is a helper message", | ||
}, | ||
render: (args) => { | ||
const [value, setValue] = useState(""); | ||
|
||
return ( | ||
<Input | ||
{...args} | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export const Disabled: Story = { | ||
name: "Disabled Input", | ||
args: { | ||
label: "Enter name", | ||
value: "", | ||
message: "This is a helper message", | ||
disabled: true, | ||
}, | ||
render: (args) => { | ||
const [value, setValue] = useState(""); | ||
|
||
return ( | ||
<Input | ||
{...args} | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export const Success: Story = { | ||
name: "Success Input", | ||
args: { | ||
label: "Enter name", | ||
value: "", | ||
message: "This is a helper message", | ||
variant: "success", | ||
}, | ||
render: (args) => { | ||
const [value, setValue] = useState(""); | ||
|
||
return ( | ||
<Input | ||
{...args} | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export const Error: Story = { | ||
name: "Error Input", | ||
args: { | ||
label: "Enter name", | ||
value: "", | ||
message: "This is a helper message", | ||
variant: "error", | ||
}, | ||
render: (args) => { | ||
const [value, setValue] = useState(""); | ||
|
||
return ( | ||
<Input | ||
{...args} | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export const Warning: Story = { | ||
name: "Error Input", | ||
args: { | ||
label: "Enter name", | ||
value: "", | ||
message: "This is a helper message", | ||
variant: "warning", | ||
}, | ||
render: (args) => { | ||
const [value, setValue] = useState(""); | ||
|
||
return ( | ||
<Input | ||
{...args} | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
/> | ||
); | ||
}, | ||
}; | ||
|
||
export const RightPlaceholder: Story = { | ||
name: "Input with Right Placeholder", | ||
args: { | ||
label: "Enter name", | ||
value: "", | ||
message: "This is a helper message", | ||
rightPlaceholder: "USD", | ||
}, | ||
render: (args) => { | ||
const [value, setValue] = useState(""); | ||
|
||
return ( | ||
<Input | ||
{...args} | ||
value={value} | ||
onChange={(e) => setValue(e.target.value)} | ||
/> | ||
); | ||
}, | ||
}; |