ConceptPortal-public/rsconcept/frontend/src/components/Common/TextArea.tsx

39 lines
894 B
TypeScript
Raw Normal View History

2023-08-10 14:13:34 +03:00
import { TextareaHTMLAttributes } from 'react';
2023-07-15 17:46:19 +03:00
import Label from './Label';
2023-08-23 22:57:25 +03:00
export interface TextAreaProps
2023-08-26 17:26:49 +03:00
extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'className' | 'title'> {
2023-07-15 17:46:19 +03:00
label: string
2023-08-26 17:26:49 +03:00
tooltip?: string
2023-07-15 17:46:19 +03:00
widthClass?: string
2023-08-10 14:13:34 +03:00
colorClass?: string
2023-07-15 17:46:19 +03:00
}
2023-07-20 17:11:03 +03:00
function TextArea({
2023-08-26 17:26:49 +03:00
id, label, required, tooltip,
2023-08-10 14:13:34 +03:00
widthClass = 'w-full',
colorClass = 'clr-input',
2023-08-10 14:13:34 +03:00
rows = 4,
...props
2023-07-20 17:11:03 +03:00
}: TextAreaProps) {
2023-07-15 17:46:19 +03:00
return (
<div className='flex flex-col items-start [&:not(:first-child)]:mt-3'>
2023-07-25 20:27:29 +03:00
<Label
2023-07-15 17:46:19 +03:00
text={label}
required={!props.disabled && required}
2023-07-15 17:46:19 +03:00
htmlFor={id}
/>
2023-07-20 17:11:03 +03:00
<textarea id={id}
2023-08-26 17:26:49 +03:00
title={tooltip}
className={`px-3 py-2 mt-2 leading-tight border shadow clr-outline ${colorClass} ${widthClass}`}
2023-08-26 17:26:49 +03:00
rows={rows}
required={required}
{...props}
2023-07-15 17:46:19 +03:00
/>
</div>
);
}
2023-07-25 20:27:29 +03:00
export default TextArea;