From 33a01027f5c6937a5237dd5781de3b597f1f3df7 Mon Sep 17 00:00:00 2001 From: Jaayden Halko Date: Fri, 18 Apr 2025 11:15:05 +0000 Subject: [PATCH] feat: add textarea component --- .../components/Textarea/Textarea.stories.tsx | 99 +++++++++++++++++++ site/src/components/Textarea/Textarea.tsx | 26 +++++ 2 files changed, 125 insertions(+) create mode 100644 site/src/components/Textarea/Textarea.stories.tsx create mode 100644 site/src/components/Textarea/Textarea.tsx diff --git a/site/src/components/Textarea/Textarea.stories.tsx b/site/src/components/Textarea/Textarea.stories.tsx new file mode 100644 index 0000000000000..fff9f22770548 --- /dev/null +++ b/site/src/components/Textarea/Textarea.stories.tsx @@ -0,0 +1,99 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import { expect, userEvent, within } from "@storybook/test"; +import { useState } from "react"; +import { Textarea } from "./Textarea"; + +const meta: Meta = { + title: "components/Textarea", + component: Textarea, + args: {}, + argTypes: { + value: { + control: "text", + description: "The controlled value of the textarea", + }, + defaultValue: { + control: "text", + description: "The default value when initially rendered", + }, + disabled: { + control: "boolean", + description: + "When true, prevents the user from interacting with the textarea", + }, + placeholder: { + control: "text", + description: "Placeholder text displayed when the textarea is empty", + }, + rows: { + control: "number", + description: "The number of rows to display", + }, + }, +}; + +export default meta; +type Story = StoryObj; + +export const WithPlaceholder: Story = { + args: { + placeholder: "Enter your message here...", + }, +}; + +export const Disabled: Story = { + args: { + disabled: true, + placeholder: "Placeholder", + }, +}; + +export const WithDefaultValue: Story = { + args: { + defaultValue: "This is some default text in the textarea.", + }, +}; + +export const Large: Story = { + args: { + rows: 8, + placeholder: "Placeholder: A larger textarea with more rows", + }, +}; + +const ControlledTextarea = () => { + const [value, setValue] = useState("This is a controlled textarea."); + return ( +
+