mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
reusable input component
This commit is contained in:
1 parent
66cd29ffe0
commit
e2f3a308fb
1 file changed
+36
@@ -0,0 +1,36 @@
|
||||
import React from "react";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
||||
|
||||
interface InputProps {
|
||||
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
value?: string;
|
||||
icon?: IconDefinition;
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export default function Input(props: InputProps) {
|
||||
return (
|
||||
<div>
|
||||
{props.label && <label className="sub-title">{props.label}</label>}
|
||||
|
||||
<div className={`form-group ${props.icon ? "input-icon" : ""}`}>
|
||||
{props.icon && (
|
||||
<FontAwesomeIcon
|
||||
icon={props.icon}
|
||||
className="form-control-feedback"
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
onChange={props.onChange}
|
||||
className="form-control"
|
||||
type={props.type && "text"}
|
||||
placeholder={props.placeholder}
|
||||
value={props.value}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user