From 5051b631eb4278c450446599eaa4821a71872d33 Mon Sep 17 00:00:00 2001 From: Kyle Espinola Date: Thu, 18 May 2023 16:11:07 +0200 Subject: [PATCH] fix: add inline-block to popover so it doesn't grow. feat: add textarea --- .../@holaplexui-playground/pages/form.tsx | 182 +++++++++--------- packages/@holaplexui-react/package.json | 2 +- .../@holaplexui-react/src/components/Form.tsx | 29 ++- .../src/components/Popover.tsx | 2 +- 4 files changed, 122 insertions(+), 93 deletions(-) diff --git a/packages/@holaplexui-playground/pages/form.tsx b/packages/@holaplexui-playground/pages/form.tsx index 8de8a30..08de264 100644 --- a/packages/@holaplexui-playground/pages/form.tsx +++ b/packages/@holaplexui-playground/pages/form.tsx @@ -1,72 +1,72 @@ -import { Form, Icon, Placement } from '@holaplex/ui-library-react'; -import clsx from 'clsx'; -import { watch } from 'fs'; -import { useCallback, useState } from 'react'; -import { useDropzone } from 'react-dropzone'; -import { Controller, useForm } from 'react-hook-form'; -import useUpload from '../hooks/useUpload'; +import { Form, Icon, Placement } from "@holaplex/ui-library-react"; +import clsx from "clsx"; +import { watch } from "fs"; +import { useCallback, useState } from "react"; +import { useDropzone } from "react-dropzone"; +import { Controller, useForm } from "react-hook-form"; +import useUpload from "../hooks/useUpload"; -function HidePasswordIcon({ size = 16, color = 'none', className = '' }) { +function HidePasswordIcon({ size = 16, color = "none", className = "" }) { return ( ); } -function ShowPasswordIcon({ size = 16, color = 'none', className = '' }) { +function ShowPasswordIcon({ size = 16, color = "none", className = "" }) { return ( ); @@ -89,53 +89,57 @@ export default function App() { >(); const options = [ - { name: 'Solana', id: 'sol' }, - { name: 'Polygon', id: 'polygon' }, - { name: 'Near', id: 'near' }, - { name: 'Ethereum', id: 'eth' }, - { name: 'Sui', id: 'sui' }, - { name: 'Aptos', id: 'aptos' }, - { name: 'Avalanche', id: 'avalanche' }, - { name: 'Bitcoin', id: 'btc' }, - { name: 'Cardano', id: 'ada' } + { name: "Solana", id: "sol" }, + { name: "Polygon", id: "polygon" }, + { name: "Near", id: "near" }, + { name: "Ethereum", id: "eth" }, + { name: "Sui", id: "sui" }, + { name: "Aptos", id: "aptos" }, + { name: "Avalanche", id: "avalanche" }, + { name: "Bitcoin", id: "btc" }, + { name: "Cardano", id: "ada" }, ]; const { control, setValue } = useForm(); const onDrop = useCallback( (files: File[]) => { - setValue('files', files, { shouldValidate: true }); + setValue("files", files, { shouldValidate: true }); }, [setValue] ); const { getRootProps, getInputProps, isDragActive } = useUpload(onDrop); return ( -
+
- - + + Forgot Password?
} - className='mt-5' + name="Password" + asideComponent={
Forgot Password?
} + className="mt-5" > } hidePasswordIcon={} /> + + + + { setSingleValue(v); }} value={singleValue} > - } placeholder='e.g. Solana'> + } placeholder="e.g. Solana"> {singleValue?.name} @@ -148,14 +152,14 @@ export default function App() { { setMultiValue(v); }} value={multiValue} > - } placeholder='e.g. Solana'> + } placeholder="e.g. Solana"> {multiValue && multiValue?.length > 0 ? multiValue[0].name : undefined} @@ -169,9 +173,9 @@ export default function App() { - + (
{value ? ( -
+
{value.map((file, index) => ( ))} @@ -208,45 +212,45 @@ export default function App() { /> - + - - - + + + - - + + - + diff --git a/packages/@holaplexui-react/package.json b/packages/@holaplexui-react/package.json index 6d5f590..7e5071c 100644 --- a/packages/@holaplexui-react/package.json +++ b/packages/@holaplexui-react/package.json @@ -1,7 +1,7 @@ { "name": "@holaplex/ui-library-react", "author": "Holaplex Inc.", - "version": "0.18.0", + "version": "0.19.0", "description": "Holaplex react ui library components", "private": false, "files": [ diff --git a/packages/@holaplexui-react/src/components/Form.tsx b/packages/@holaplexui-react/src/components/Form.tsx index ccbfa2c..c811ec5 100644 --- a/packages/@holaplexui-react/src/components/Form.tsx +++ b/packages/@holaplexui-react/src/components/Form.tsx @@ -8,6 +8,7 @@ import { InputHTMLAttributes, useState, Fragment, + TextareaHTMLAttributes, } from 'react'; import { Listbox, RadioGroup } from '@headlessui/react'; import { FieldError } from 'react-hook-form'; @@ -88,10 +89,11 @@ interface FormInputProps className?: string; icon?: JSX.Element; error?: FieldError; + type?: string; } const FormInput = forwardRef(function FormInput( - { className, icon, error, ...props }: FormInputProps, + { className, icon, error, type, ...props }: FormInputProps, ref ) { return ( @@ -99,7 +101,7 @@ const FormInput = forwardRef(function FormInput( | undefined} - type={props.type ?? 'text'} + type={type ?? 'text'} className={clsx( 'w-full', { @@ -123,6 +125,29 @@ const FormInput = forwardRef(function FormInput( }); Form.Input = FormInput; +interface FormTextAreaProps + extends DetailedHTMLProps, HTMLTextAreaElement> { + className?: string; + error?: FieldError; +} + +const FormTextArea = forwardRef(function FormTextArea( + { className, error, ...props }: FormTextAreaProps, + ref +) { + return ( +
+