feat: Added ColorPicker component to Storybook (#3019)

This commit is contained in:
Vishal Tyagi
2024-08-19 12:29:10 +05:30
committed by GitHub
parent e9c5b00628
commit 5ba2959eb4

View File

@@ -0,0 +1,44 @@
import { useArgs } from "@storybook/preview-api";
import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";
import { ColorPicker } from "./index";
const meta: Meta<typeof ColorPicker> = {
title: "ui/ColorPicker",
component: ColorPicker,
tags: ["autodocs"],
parameters: {
layout: "centered",
},
decorators: [
function Component(Story, ctx) {
const [, setArgs] = useArgs<typeof ctx.args>();
const handleChange = (newColor: string) => {
ctx.args.onChange?.(newColor);
setArgs({ color: newColor });
};
return <Story args={{ ...ctx.args, onChange: handleChange }} />;
},
],
argTypes: {
color: {
control: "color",
},
},
args: {
onChange: fn(),
},
} satisfies Meta<typeof ColorPicker>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
color: "#f24768",
containerClass: "mb-20",
},
};