Skip to content

Commit

Permalink
refactor(component): Enable text area to be within a fieldset or not
Browse files Browse the repository at this point in the history
ref: #42 #45
  • Loading branch information
jon-nfc committed Jan 19, 2025
1 parent 6c19e9d commit e36ef5b
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions src/components/form/Textarea.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
const TextArea = ({
id,
error_text=null,
value= '',
fieldset = true,
value='',
onChange = null,
class_name = null,
field_data = null
}) => {

if( value === null ) {
value = ''
}

let field_class_name = "common-field"
let helptext = null
Expand Down Expand Up @@ -50,17 +48,14 @@ const TextArea = ({
}
}


return (
<fieldset className={class_name}>
<label className="name" for={id}>{label}</label>
<span className="help-text">{helptext}</span>
<textarea
id={id}
required={required}
className={field_class_name}
onChange={onChange}
onKeyUp={(e) =>{
let field = (
<>
<textarea
id={id}
required={required}
className={fieldset ? field_class_name : field_class_name + ' ' + class_name}
onChange={onChange}
onKeyUp={(e) =>{

const currentScrollY = window.scrollY

Expand All @@ -85,9 +80,29 @@ const TextArea = ({
}}

>{value}</textarea>
<span className="error-text">{error_text}</span>
</fieldset>
);
</>
)


if( fieldset ) {

return (
<fieldset className={class_name}>
<label className="name" for={id}>{label}</label>
<span className="help-text">{helptext}</span>
{field}
<span className="error-text">{error_text}</span>
</fieldset>
);

} else {

return (
<>
{field}
</>
)
}
}

export default TextArea;

0 comments on commit e36ef5b

Please sign in to comment.