-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
Textarea
component and integrate it into `CqlSearchHeader…
…` + Add form wrapper The `Textarea` is added to keep the structure consistent, and the class `advanced-search-cql-form` is used to maintain spacing between elements.
- Loading branch information
1 parent
d7c8990
commit 230ca57
Showing
3 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import clsx from "clsx"; | ||
import React, { FC } from "react"; | ||
|
||
export interface LabelProps { | ||
id: string; | ||
children: string; | ||
className?: string; | ||
} | ||
|
||
const Label: FC<LabelProps> = ({ id, className, children }) => ( | ||
<label htmlFor={id} className={clsx(className)}> | ||
{children} | ||
</label> | ||
); | ||
|
||
export default Label; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import clsx from "clsx"; | ||
import React, { ChangeEvent, FC } from "react"; | ||
import Label from "../label/Label"; | ||
|
||
export interface TextareaProps { | ||
id: string; | ||
name: string; | ||
label: string; | ||
rows?: number; | ||
cols?: number; | ||
className?: string; | ||
placeholder?: string; | ||
onChange?: (event: ChangeEvent<HTMLTextAreaElement>) => void; | ||
defaultValue?: string; | ||
} | ||
|
||
const Textarea: FC<TextareaProps> = ({ | ||
id, | ||
name, | ||
label, | ||
rows = 8, | ||
cols = 80, | ||
className, | ||
placeholder, | ||
onChange, | ||
defaultValue | ||
}) => { | ||
return ( | ||
<div className="dpl-input"> | ||
<Label id={id}>{label}</Label> | ||
<div> | ||
<textarea | ||
className={clsx(className)} | ||
id={id} | ||
name={name} | ||
rows={rows} | ||
cols={cols} | ||
placeholder={placeholder} | ||
onChange={onChange} | ||
defaultValue={defaultValue} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Textarea; |