-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtext-inputs.tsx
More file actions
55 lines (51 loc) · 1.29 KB
/
text-inputs.tsx
File metadata and controls
55 lines (51 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React from "react";
import { Input } from "../ui/input";
import { Label } from "../ui/label";
import { Textarea } from "../ui/textarea";
import { TEXT_MAX_LENGTH } from "@/config";
import { cn } from "@/lib/utils";
interface TextInputsProps {
text: string;
name: string;
updateName: (payload: string) => void;
updateText: (payload: string) => void;
}
const TextInputs = ({
name,
text,
updateName,
updateText,
}: TextInputsProps) => {
const length = text.length;
return (
<div className="w-full">
<Label htmlFor="name">Post friendly name</Label>
<Input
id="name"
value={name}
type="text"
onChange={(e) => updateName(e.target.value)}
placeholder="friendly name..."
className="mb-4"
maxLength={40}
/>
<Label htmlFor="text">Post text</Label>
<Textarea
id="text"
placeholder="text here..."
value={text}
onChange={(e) => updateText(e.target.value)}
maxLength={TEXT_MAX_LENGTH}
className="mb-2 h-[250px]"
/>
<p
className={cn("text-end text-sm text-muted-foreground", {
"text-red-500": length === TEXT_MAX_LENGTH,
})}
>
{length + "/" + TEXT_MAX_LENGTH}
</p>
</div>
);
};
export default TextInputs;