mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Improve input customization
This commit is contained in:
parent
535c45e50f
commit
05a7ed215b
|
@ -1,24 +1,20 @@
|
||||||
|
import { TextareaHTMLAttributes } from 'react';
|
||||||
|
|
||||||
import Label from './Label';
|
import Label from './Label';
|
||||||
|
|
||||||
interface TextAreaProps {
|
interface TextAreaProps
|
||||||
id: string
|
extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'className'> {
|
||||||
label: string
|
label: string
|
||||||
required?: boolean
|
|
||||||
disabled?: boolean
|
|
||||||
spellCheck?: boolean
|
|
||||||
placeholder?: string
|
|
||||||
widthClass?: string
|
widthClass?: string
|
||||||
rows?: number
|
colorClass?: string
|
||||||
value?: string | ReadonlyArray<string> | number | undefined;
|
|
||||||
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void
|
|
||||||
onFocus?: () => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function TextArea({
|
function TextArea({
|
||||||
id, label, placeholder,
|
id, label, required,
|
||||||
required, spellCheck, disabled,
|
widthClass = 'w-full',
|
||||||
widthClass = 'w-full', rows = 4, value,
|
colorClass = 'colorClass',
|
||||||
onChange, onFocus
|
rows = 4,
|
||||||
|
...props
|
||||||
}: TextAreaProps) {
|
}: TextAreaProps) {
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col items-start [&:not(:first-child)]:mt-3'>
|
<div className='flex flex-col items-start [&:not(:first-child)]:mt-3'>
|
||||||
|
@ -28,15 +24,10 @@ function TextArea({
|
||||||
htmlFor={id}
|
htmlFor={id}
|
||||||
/>
|
/>
|
||||||
<textarea id={id}
|
<textarea id={id}
|
||||||
className={`px-3 py-2 mt-2 leading-tight border shadow clr-input ${widthClass}`}
|
className={`px-3 py-2 mt-2 leading-tight border shadow ${colorClass} ${widthClass}`}
|
||||||
rows={rows}
|
rows={rows}
|
||||||
placeholder={placeholder}
|
|
||||||
required={required}
|
required={required}
|
||||||
value={value}
|
{...props}
|
||||||
onChange={onChange}
|
|
||||||
onFocus={onFocus}
|
|
||||||
disabled={disabled}
|
|
||||||
spellCheck={spellCheck}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,10 +7,13 @@ interface TextInputProps
|
||||||
id: string
|
id: string
|
||||||
label: string
|
label: string
|
||||||
widthClass?: string
|
widthClass?: string
|
||||||
|
colorClass?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function TextInput({
|
function TextInput({
|
||||||
id, required, label, widthClass = 'w-full',
|
id, required, label,
|
||||||
|
widthClass = 'w-full',
|
||||||
|
colorClass = 'clr-input',
|
||||||
...props
|
...props
|
||||||
}: TextInputProps) {
|
}: TextInputProps) {
|
||||||
return (
|
return (
|
||||||
|
@ -21,7 +24,7 @@ function TextInput({
|
||||||
htmlFor={id}
|
htmlFor={id}
|
||||||
/>
|
/>
|
||||||
<input id={id}
|
<input id={id}
|
||||||
className={`px-3 py-2 mt-2 leading-tight border shadow truncate hover:text-clip clr-input ${widthClass}`}
|
className={`px-3 py-2 mt-2 leading-tight border shadow truncate hover:text-clip ${colorClass} ${widthClass}`}
|
||||||
required={required}
|
required={required}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user