diff --git a/src/components/__snapshots__/input.spec.tsx.snap b/src/components/__snapshots__/input.spec.tsx.snap new file mode 100644 index 0000000..f5a26fb --- /dev/null +++ b/src/components/__snapshots__/input.spec.tsx.snap @@ -0,0 +1,10 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Input component > renders correctly 1`] = ` +
+ +
+`; diff --git a/src/components/input.spec.tsx b/src/components/input.spec.tsx new file mode 100644 index 0000000..d3018c9 --- /dev/null +++ b/src/components/input.spec.tsx @@ -0,0 +1,10 @@ +import { render } from "@testing-library/react"; +import { describe, expect, it } from "vitest"; +import { Input } from "./input"; + +describe("Input component", () => { + it("renders correctly", () => { + const { container } = render(); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/src/components/input.stories.tsx b/src/components/input.stories.tsx new file mode 100644 index 0000000..64afa0e --- /dev/null +++ b/src/components/input.stories.tsx @@ -0,0 +1,50 @@ +import type { Meta, StoryObj } from "@storybook/react"; + +import { Button } from "./button"; +import { Input } from "./input"; + +const meta = { + title: "Input", + component: Input, + parameters: { + layout: "centered", + }, + argTypes: { + disabled: { + control: "boolean", + }, + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + placeholder: "Email", + }, +}; + +export const File: Story = { + args: { + type: "file", + }, +}; + +export const Disabled: Story = { + args: { + placeholder: "Email", + disabled: true, + }, +}; + +export const WithButton: Story = { + render() { + return ( +
+ + +
+ ); + }, +}; diff --git a/src/components/input.tsx b/src/components/input.tsx new file mode 100644 index 0000000..b826377 --- /dev/null +++ b/src/components/input.tsx @@ -0,0 +1,26 @@ +import type { InputHTMLAttributes } from "react"; +import * as React from "react"; + +import { cn } from "@/lib/utils"; + +export type InputProps = InputHTMLAttributes; + +const Input = React.forwardRef( + ({ className, type, ...props }, ref) => { + return ( + + ); + } +); + +Input.displayName = "Input"; + +export { Input };