Skip to content

Commit

Permalink
refactor(docs): textarea dx
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed Nov 15, 2024
1 parent 2debe54 commit d74428f
Show file tree
Hide file tree
Showing 20 changed files with 152 additions and 159 deletions.
11 changes: 11 additions & 0 deletions apps/docs/content/components/textarea/autosize.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
return (
<div className="flex w-full flex-wrap md:flex-nowrap mb-6 md:mb-0 gap-4">
<Textarea label="Description" placeholder="Enter your description (Default autosize)" />
<Textarea label="Description" minRows={2} placeholder="Enter your description (Min rows 2)" />
<Textarea label="Description" maxRows={3} placeholder="Enter your description (Max rows 3)" />
</div>
);
}
23 changes: 1 addition & 22 deletions apps/docs/content/components/textarea/autosize.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
return (
<div className="flex w-full flex-wrap md:flex-nowrap mb-6 md:mb-0 gap-4">
<Textarea
label="Description"
placeholder="Enter your description (Default autosize)"
/>
<Textarea
minRows={2}
label="Description"
placeholder="Enter your description (Min rows 2)"
/>
<Textarea
maxRows={3}
label="Description"
placeholder="Enter your description (Max rows 3)"
/>
</div>
);
}`;
import App from "./autosize.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
19 changes: 19 additions & 0 deletions apps/docs/content/components/textarea/controlled.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
const [value, setValue] = React.useState("");

return (
<div className="w-full flex flex-col gap-2 max-w-[240px]">
<Textarea
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
value={value}
variant="underlined"
onValueChange={setValue}
/>
<p className="text-default-500 text-small">Textarea value: {value}</p>
</div>
);
}
20 changes: 1 addition & 19 deletions apps/docs/content/components/textarea/controlled.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
const [value, setValue] = React.useState("");
return (
<div className="w-full flex flex-col gap-2 max-w-[240px]">
<Textarea
variant="underlined"
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
value={value}
onValueChange={setValue}
/>
<p className="text-default-500 text-small">Textarea value: {value}</p>
</div>
);
}`;
import App from "./controlled.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
13 changes: 13 additions & 0 deletions apps/docs/content/components/textarea/description.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
return (
<Textarea
className="max-w-xs"
description="Enter a concise description of your project."
label="Description"
placeholder="Enter your description"
variant="faded"
/>
);
}
14 changes: 1 addition & 13 deletions apps/docs/content/components/textarea/description.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
return (
<Textarea
variant="faded"
label="Description"
placeholder="Enter your description"
description="Enter a concise description of your project."
className="max-w-xs"
/>
);
}`;
import App from "./description.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
17 changes: 17 additions & 0 deletions apps/docs/content/components/textarea/disable-autosize.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
return (
<Textarea
disableAnimation
disableAutosize
classNames={{
base: "max-w-xs",
input: "resize-y min-h-[40px]",
}}
label="Description"
placeholder="Enter your description"
variant="bordered"
/>
);
}
18 changes: 1 addition & 17 deletions apps/docs/content/components/textarea/disable-autosize.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
return (
<Textarea
label="Description"
variant="bordered"
placeholder="Enter your description"
disableAnimation
disableAutosize
classNames={{
base: "max-w-xs",
input: "resize-y min-h-[40px]",
}}
/>
);
}`;
import App from "./disable-autosize.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
14 changes: 14 additions & 0 deletions apps/docs/content/components/textarea/disabled.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
return (
<Textarea
isDisabled
className="max-w-xs"
defaultValue="NextUI is a React UI library that provides a set of accessible, reusable, and beautiful components."
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
/>
);
}
15 changes: 1 addition & 14 deletions apps/docs/content/components/textarea/disabled.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
return (
<Textarea
isDisabled
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
defaultValue="NextUI is a React UI library that provides a set of accessible, reusable, and beautiful components."
className="max-w-xs"
/>
);
}`;
import App from "./disabled.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
15 changes: 15 additions & 0 deletions apps/docs/content/components/textarea/error-message.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
return (
<Textarea
className="max-w-xs"
defaultValue="NextUI is a React UI library with..."
errorMessage="The description should be at least 255 characters long."
isInvalid={true}
label="Description"
placeholder="Enter your description"
variant="bordered"
/>
);
}
16 changes: 1 addition & 15 deletions apps/docs/content/components/textarea/error-message.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
return (
<Textarea
isInvalid={true}
variant="bordered"
label="Description"
placeholder="Enter your description"
defaultValue="NextUI is a React UI library with..."
errorMessage="The description should be at least 255 characters long."
className="max-w-xs"
/>
);
}`;
import App from "./error-message.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
15 changes: 15 additions & 0 deletions apps/docs/content/components/textarea/readonly.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
return (
<Textarea
isReadOnly
className="max-w-xs"
defaultValue="NextUI is a React UI library that provides a set of accessible, reusable, and beautiful components."
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
variant="bordered"
/>
);
}
16 changes: 1 addition & 15 deletions apps/docs/content/components/textarea/readonly.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
return (
<Textarea
isReadOnly
label="Description"
variant="bordered"
labelPlacement="outside"
placeholder="Enter your description"
defaultValue="NextUI is a React UI library that provides a set of accessible, reusable, and beautiful components."
className="max-w-xs"
/>
);
}`;
import App from "./readonly.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
13 changes: 13 additions & 0 deletions apps/docs/content/components/textarea/required.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
return (
<Textarea
isRequired
className="max-w-xs"
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
/>
);
}
14 changes: 1 addition & 13 deletions apps/docs/content/components/textarea/required.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
return (
<Textarea
isRequired
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
className="max-w-xs"
/>
);
}`;
import App from "./required.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
5 changes: 5 additions & 0 deletions apps/docs/content/components/textarea/usage.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
return <Textarea className="max-w-xs" label="Description" placeholder="Enter your description" />;
}
12 changes: 1 addition & 11 deletions apps/docs/content/components/textarea/usage.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
return (
<Textarea
label="Description"
placeholder="Enter your description"
className="max-w-xs"
/>
);
}`;
import App from "./usage.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down
20 changes: 20 additions & 0 deletions apps/docs/content/components/textarea/variants.raw.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Textarea} from "@nextui-org/react";

export default function App() {
const variants = ["flat", "faded", "bordered", "underlined"];

return (
<div className="w-full grid grid-cols-12 gap-4">
{variants.map((variant) => (
<Textarea
key={variant}
className="col-span-12 md:col-span-6 mb-6 md:mb-0"
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
variant={variant}
/>
))}
</div>
);
}
21 changes: 1 addition & 20 deletions apps/docs/content/components/textarea/variants.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
const App = `import {Textarea} from "@nextui-org/react";
export default function App() {
const variants = ["flat", "faded", "bordered", "underlined"];
return (
<div className="w-full grid grid-cols-12 gap-4">
{variants.map((variant) => (
<Textarea
key={variant}
variant={variant}
label="Description"
labelPlacement="outside"
placeholder="Enter your description"
className="col-span-12 md:col-span-6 mb-6 md:mb-0"
/>
))}
</div>
);
}`;
import App from "./variants.raw.jsx?raw";

const react = {
"/App.jsx": App,
Expand Down

0 comments on commit d74428f

Please sign in to comment.