From 4d271ec4214d0e91cf1c6ca90b486330c51451f0 Mon Sep 17 00:00:00 2001 From: Juan Di Toro Date: Mon, 25 Mar 2024 08:59:35 +0100 Subject: [PATCH] fix: textarea for pinning modal. small refactor to the api exposed by the hook --- app/components/forms.tsx | 31 ++++++++++++++ app/components/pinning-network-banner.tsx | 7 +--- app/components/ui/textarea.tsx | 24 +++++++++++ app/hooks/usePinning.ts | 18 +++++--- app/routes/file-manager/index.tsx | 50 +++++++++++++++-------- 5 files changed, 103 insertions(+), 27 deletions(-) create mode 100644 app/components/ui/textarea.tsx diff --git a/app/components/forms.tsx b/app/components/forms.tsx index ea1d989..b8c99b4 100644 --- a/app/components/forms.tsx +++ b/app/components/forms.tsx @@ -4,6 +4,7 @@ import { type FieldName, useInputControl } from "@conform-to/react" import { useId } from "react" import { cn } from "~/utils" import { Checkbox } from "~/components/ui/checkbox" +import { Textarea } from "./ui/textarea" export const Field = ({ inputProps, @@ -98,6 +99,36 @@ export const FieldCheckbox = ({ ) } +export function TextareaField({ + labelProps, + textareaProps, + errors, + className, +}: { + labelProps: React.LabelHTMLAttributes + textareaProps: React.TextareaHTMLAttributes + errors?: ListOfErrors + className?: string +}) { + const fallbackId = useId() + const id = textareaProps.id ?? textareaProps.name ?? fallbackId + const errorId = errors?.length ? `${id}-error` : undefined + return ( +
+