feat: input params
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
@reference "../../index.scss";
|
@reference "../../index.scss";
|
||||||
|
|
||||||
.input_field {
|
.input_field {
|
||||||
@apply rounded-[4xl] border border-gray-300 bg-white p-2 leading-8 placeholder:transition focus:outline-0 focus:placeholder:opacity-25;
|
@apply w-full rounded-[4rem] border border-gray-300 bg-white p-2 leading-8 placeholder:transition focus:outline-0 focus:placeholder:opacity-25;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { FunctionComponent } from "preact";
|
import { cn } from "@/utils/class-merge";
|
||||||
|
import { FunctionComponent, Ref } from "preact";
|
||||||
import { tv } from "tailwind-variants";
|
import { tv } from "tailwind-variants";
|
||||||
import classes from "./Input.module.scss";
|
import classes from "./Input.module.scss";
|
||||||
|
|
||||||
@@ -19,15 +20,29 @@ interface InputProps {
|
|||||||
isPassword?: boolean;
|
isPassword?: boolean;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
textAlign?: "center" | "left";
|
textAlign?: "center" | "left";
|
||||||
|
error?: string;
|
||||||
|
ref: Ref<HTMLInputElement> | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Input: FunctionComponent<InputProps> = ({ isPassword = false, placeholder = "", textAlign }: InputProps) => {
|
const Input: FunctionComponent<InputProps> = ({
|
||||||
|
isPassword = false,
|
||||||
|
placeholder = "",
|
||||||
|
textAlign,
|
||||||
|
error = "",
|
||||||
|
ref = null,
|
||||||
|
}: InputProps) => {
|
||||||
return (
|
return (
|
||||||
|
<div class="flex w-full flex-col items-center gap-1">
|
||||||
<input
|
<input
|
||||||
type={isPassword ? "password" : "text"}
|
type={isPassword ? "password" : "text"}
|
||||||
class={input({ "text-align": textAlign })}
|
class={input({ "text-align": textAlign })}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
|
ref={ref}
|
||||||
/>
|
/>
|
||||||
|
<p class={cn("invisible h-10 w-[80%] text-center text-sm break-words text-red-500", { visible: error !== "" })}>
|
||||||
|
{error}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user