diff --git a/.changeset/rude-forks-admire.md b/.changeset/rude-forks-admire.md new file mode 100644 index 000000000..5abf10a4d --- /dev/null +++ b/.changeset/rude-forks-admire.md @@ -0,0 +1,5 @@ +--- +"@radui/ui": minor +--- + +Addition of color and radius api support in TextArea and new styling diff --git a/src/components/ui/TextArea/TextArea.tsx b/src/components/ui/TextArea/TextArea.tsx index 9381c0291..df588534c 100644 --- a/src/components/ui/TextArea/TextArea.tsx +++ b/src/components/ui/TextArea/TextArea.tsx @@ -1,11 +1,13 @@ 'use client'; import React from 'react'; import clsx from 'clsx'; -import TextAreaRoot from './fragments/TextAreaRoot'; -import TextAreaInput from './fragments/TextAreaInput'; +import TextAreaRoot, { TextAreaRootProps } from './fragments/TextAreaRoot'; +import TextAreaInput, { TextAreaInputProps } from './fragments/TextAreaInput'; -export type TextAreaProps = React.ComponentPropsWithoutRef<'div'> & { +export type TextAreaProps = React.ComponentPropsWithoutRef<'div'> & TextAreaRootProps & TextAreaInputProps & { customRootClass?: string; + readonly ?: boolean; + disabled ?: boolean; }; type TextAreaComponent = React.ForwardRefExoticComponent>> & { @@ -13,10 +15,10 @@ type TextAreaComponent = React.ForwardRefExoticComponent, TextAreaProps>(({ customRootClass = '', className = '', children, ...props }, ref) => { +const TextArea = React.forwardRef, TextAreaProps>(({ customRootClass = '', placeholder = '', className = '', disabled = false, readonly = false, children, ...props }, ref) => { return ( - + {children} {children} diff --git a/src/components/ui/TextArea/fragments/TextAreaRoot.tsx b/src/components/ui/TextArea/fragments/TextAreaRoot.tsx index d76af0010..4ccc74245 100644 --- a/src/components/ui/TextArea/fragments/TextAreaRoot.tsx +++ b/src/components/ui/TextArea/fragments/TextAreaRoot.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { customClassSwitcher } from '~/core'; import clsx from 'clsx'; -import { useCreateDataAttribute } from '~/core/hooks/createDataAttribute'; +import { useCreateDataAttribute, useComposeAttributes, useCreateDataAccentColorAttribute } from '~/core/hooks/createDataAttribute'; const COMPONENT_NAME = 'TextArea'; @@ -10,15 +10,19 @@ export type TextAreaRootProps = React.ComponentPropsWithoutRef<'div'> & { variant?: string; size?: string; resize?: 'none' | 'vertical' | 'horizontal' | 'both'; + color?: string; + radius?: string; }; const TextAreaRoot = React.forwardRef, TextAreaRootProps>( - ({ children, customRootClass = '', className = '', variant = '', size = '', resize = 'both', ...props }, ref) => { + ({ children, customRootClass = '', className = '', variant = '', size = '', resize = 'both', color = '', radius = '', ...props }, ref) => { const rootClass = customClassSwitcher(customRootClass, COMPONENT_NAME); - const dataAttributes = useCreateDataAttribute('textarea', { variant, size, resize }); + const dataAttributes = useCreateDataAttribute('textarea', { variant, size, resize, radius}); + const accentAttributes = useCreateDataAccentColorAttribute(color); + const composedAttributes = useComposeAttributes(dataAttributes(), accentAttributes()); return ( -
+
{children}
); diff --git a/src/components/ui/TextArea/stories/TextArea.stories.tsx b/src/components/ui/TextArea/stories/TextArea.stories.tsx index 70f3c696c..725244ca3 100644 --- a/src/components/ui/TextArea/stories/TextArea.stories.tsx +++ b/src/components/ui/TextArea/stories/TextArea.stories.tsx @@ -2,11 +2,20 @@ import React from 'react'; import TextArea from '../TextArea'; import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor'; +const Variants = ['solid', 'soft', 'outline', 'ghost']; +const Sizes = ['small', 'medium', 'large']; +const Resizes: Array<'none' | 'vertical' | 'horizontal' | 'both' | undefined> = ['none', 'vertical', 'horizontal', 'both', undefined ]; +const Radius = ['none', 'small', 'medium', 'large']; const Template = (args:any) => { return + +