Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,76 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Textarea } from "~/components/ui/textarea";
|
||||
|
||||
function Field({
|
||||
label,
|
||||
hint,
|
||||
error,
|
||||
htmlFor,
|
||||
children,
|
||||
}: {
|
||||
label: string;
|
||||
hint?: string;
|
||||
error?: string;
|
||||
htmlFor: string;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<label className="flex max-w-sm flex-col gap-1.5 text-sm" htmlFor={htmlFor}>
|
||||
<span className="font-medium">{label}</span>
|
||||
{children}
|
||||
{hint && !error ? <span className="text-muted-foreground text-xs">{hint}</span> : null}
|
||||
{error ? (
|
||||
<span className="text-destructive text-xs" role="alert">
|
||||
{error}
|
||||
</span>
|
||||
) : null}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
|
||||
const meta: Meta<typeof Textarea> = {
|
||||
title: "UI / Inputs / Textarea",
|
||||
component: Textarea,
|
||||
tags: ["autodocs"],
|
||||
argTypes: {
|
||||
disabled: { control: "boolean" },
|
||||
},
|
||||
args: { placeholder: "Tell us what happened…", rows: 4 },
|
||||
};
|
||||
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj<typeof Textarea>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: (args) => (
|
||||
<Field label="Message" htmlFor="msg-default">
|
||||
<Textarea id="msg-default" {...args} />
|
||||
</Field>
|
||||
),
|
||||
};
|
||||
|
||||
export const WithCharacterHint: Story = {
|
||||
render: (args) => (
|
||||
<Field label="Bio" hint="Max 280 characters." htmlFor="bio-hint">
|
||||
<Textarea id="bio-hint" {...args} maxLength={280} />
|
||||
</Field>
|
||||
),
|
||||
};
|
||||
|
||||
export const WithError: Story = {
|
||||
render: (args) => (
|
||||
<Field label="Message" error="Message can not be empty." htmlFor="msg-error">
|
||||
<Textarea id="msg-error" {...args} aria-invalid="true" />
|
||||
</Field>
|
||||
),
|
||||
};
|
||||
|
||||
export const Disabled: Story = {
|
||||
args: { disabled: true, defaultValue: "Submission already locked — read-only." },
|
||||
render: (args) => (
|
||||
<Field label="Message" htmlFor="msg-disabled">
|
||||
<Textarea id="msg-disabled" {...args} />
|
||||
</Field>
|
||||
),
|
||||
};
|
||||
Reference in new issue
Block a user