You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
704 B
TypeScript
39 lines
704 B
TypeScript
export default function input({
|
|
name,
|
|
id,
|
|
label,
|
|
type,
|
|
value,
|
|
placeholder,
|
|
error,
|
|
readonly,
|
|
}: {
|
|
name: string;
|
|
id?: string;
|
|
label?: string;
|
|
type?: string;
|
|
value?: string;
|
|
placeholder?: string;
|
|
readonly?: boolean;
|
|
error: string;
|
|
}) {
|
|
id = id || name;
|
|
label = label || name;
|
|
type = type || "text";
|
|
value = value || "";
|
|
placeholder = placeholder || type;
|
|
readonly = readonly || false;
|
|
return /* HTML */ `<div class="input">
|
|
<label for="${id}">${label}</label>
|
|
<input
|
|
id="${id}"
|
|
type="${type}"
|
|
name="${name}"
|
|
value="${value}"
|
|
placeholder="${placeholder}"
|
|
${readonly ? "readonly" : ""}
|
|
/>
|
|
${error ? `<div class="input__error">${error}</div>` : ""}
|
|
</div>`;
|
|
}
|