Skip to content

Commit

Permalink
refactor: checkbox input story component (#1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
kavandalal authored Sep 20, 2023
1 parent 5bb09fd commit faa669b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 39 deletions.
32 changes: 17 additions & 15 deletions packages/checkboxInput/stories/CheckboxInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from "react";
import { StoryFn, Meta } from "@storybook/react";
import CheckboxInput from "../components/CheckboxInput";
import CheckboxStoryHelper from "../stories/helpers/CheckboxStoryHelper";
import { InputStoryWrapper } from "../../../decorators/inputStoryWrapper";

export default {
Expand Down Expand Up @@ -35,20 +34,23 @@ export default {
}
} as Meta;

const Template: StoryFn = args => (
<CheckboxStoryHelper>
{({ changeHandler, isChecked }) => (
<CheckboxInput
id="default"
inputLabel="Default"
value="default"
checked={!!isChecked}
onChange={changeHandler}
{...args}
/>
)}
</CheckboxStoryHelper>
);
const Template: StoryFn = args => {
const [isChecked, setIsChecked] = React.useState<boolean>(false);

const changeHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
setIsChecked(event.target.checked);
};
return (
<CheckboxInput
id="default"
inputLabel="Default"
value="default"
checked={!!isChecked}
onChange={changeHandler}
{...args}
/>
);
};

export const Default = {
render: Template
Expand Down
24 changes: 0 additions & 24 deletions packages/checkboxInput/stories/helpers/CheckboxStoryHelper.tsx

This file was deleted.

0 comments on commit faa669b

Please sign in to comment.