|
@@ -6,6 +6,7 @@ import { spacing } from "./../../theme"
|
|
|
|
|
|
type TextFieldProps = {
|
|
|
label: string
|
|
|
+ helper?: string
|
|
|
value?: string
|
|
|
icon?: IconProp
|
|
|
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void
|
|
@@ -14,6 +15,7 @@ type TextFieldProps = {
|
|
|
|
|
|
export default function TextField({
|
|
|
label,
|
|
|
+ helper = "",
|
|
|
value = "",
|
|
|
icon = null,
|
|
|
disabled = false,
|
|
@@ -49,32 +51,37 @@ export default function TextField({
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
- <div css={styles.container} onClick={onTextFieldClick}>
|
|
|
- <div css={styles.border}>
|
|
|
- <div
|
|
|
- css={styles.label}
|
|
|
- style={!inputTextValue && !isActive ? {} : {
|
|
|
- position: "absolute",
|
|
|
- top: "-8px",
|
|
|
- left: "5px",
|
|
|
- fontSize: "0.7rem",
|
|
|
- padding: `0 ${spacing.xs}`
|
|
|
- }}>
|
|
|
- {label}
|
|
|
+ <div css={styles.wrapper}>
|
|
|
+ <div css={styles.container} onClick={onTextFieldClick}>
|
|
|
+ <div css={styles.border}>
|
|
|
+ <div
|
|
|
+ css={styles.label}
|
|
|
+ style={!inputTextValue && !isActive ? {} : {
|
|
|
+ position: "absolute",
|
|
|
+ top: "-8px",
|
|
|
+ left: "5px",
|
|
|
+ fontSize: "0.7rem",
|
|
|
+ padding: `0 ${spacing.xs}`
|
|
|
+ }}>
|
|
|
+ {label}
|
|
|
+ </div>
|
|
|
+ <input
|
|
|
+ css={styles.input}
|
|
|
+ style={{ display: !!inputTextValue || isActive ? "block" : "none"}}
|
|
|
+ ref={inputRef}
|
|
|
+ type="text"
|
|
|
+ value={inputTextValue}
|
|
|
+ onChange={disabled ? null : onInputTextChange}
|
|
|
+ onBlur={onInputTextBlur}
|
|
|
+ />
|
|
|
+ {!!icon &&
|
|
|
+ <FontAwesomeIcon icon={icon} css={styles.icon} />
|
|
|
+ }
|
|
|
</div>
|
|
|
- <input
|
|
|
- css={styles.input}
|
|
|
- style={{ display: !!inputTextValue || isActive ? "block" : "none"}}
|
|
|
- ref={inputRef}
|
|
|
- type="text"
|
|
|
- value={inputTextValue}
|
|
|
- onChange={disabled ? null : onInputTextChange}
|
|
|
- onBlur={onInputTextBlur}
|
|
|
- />
|
|
|
- {!!icon &&
|
|
|
- <FontAwesomeIcon icon={icon} css={styles.icon} />
|
|
|
- }
|
|
|
</div>
|
|
|
+ {!!helper &&
|
|
|
+ <p css={styles.helper}>{helper}</p>
|
|
|
+ }
|
|
|
</div>
|
|
|
)
|
|
|
}
|