component seprator
This commit is contained in:
+13
-12
@@ -1,30 +1,31 @@
|
|||||||
|
import { cn } from "@/app/lib/cn";
|
||||||
import { SearchNormal } from "iconsax-reactjs";
|
import { SearchNormal } from "iconsax-reactjs";
|
||||||
import { forwardRef } from "react";
|
import { FC } from "react";
|
||||||
|
|
||||||
export type InputVariant = "primary" | "search";
|
export type InputVariant = "primary" | "search";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
variant?: InputVariant;
|
variant?: InputVariant;
|
||||||
|
className?: string;
|
||||||
} & React.InputHTMLAttributes<HTMLInputElement>;
|
} & React.InputHTMLAttributes<HTMLInputElement>;
|
||||||
|
|
||||||
const Input = forwardRef<HTMLInputElement, Props>(({ variant = "search", className, type, ...props }, ref) => {
|
const Input: FC<Props> = (props) => {
|
||||||
const isSearch = variant === "search";
|
const { variant = "primary", className, ...rest } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative w-full" dir="rtl">
|
<div className="relative w-full" dir="rtl">
|
||||||
{isSearch && <SearchNormal aria-hidden="true" className="pointer-events-none absolute top-1/2 right-5 -translate-y-1/2 text-primary" color="currentColor" size={24} />}
|
{variant === "search" && <SearchNormal aria-hidden="true" className="pointer-events-none absolute top-1/2 right-5 -translate-y-1/2 text-primary" color="currentColor" size={24} />}
|
||||||
<input
|
<input
|
||||||
ref={ref}
|
type={variant === "search" ? "search" : "text"}
|
||||||
type={type ?? (isSearch ? "search" : "text")}
|
className={cn(
|
||||||
className={`h-12 w-full rounded-2xl border border-secondary bg-white px-5 text-right text-sm text-[#3A4147] placeholder:text-[#D7E0E8] transition-colors focus:border-primary ${
|
"h-12 w-full rounded-2xl border border-secondary bg-white px-5 text-right text-sm text-[#3A4147] placeholder:text-[#D7E0E8] transition-colors focus:border-primary",
|
||||||
isSearch ? "pr-13" : ""
|
variant === "search" && "pr-13",
|
||||||
} ${className ?? ""}`}
|
className,
|
||||||
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
};
|
||||||
|
|
||||||
Input.displayName = "Input";
|
|
||||||
|
|
||||||
export default Input;
|
export default Input;
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { FC } from "react";
|
||||||
|
import { cn } from "../lib/cn";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const Seprator: FC<Props> = ({ className }) => {
|
||||||
|
return <div className={cn("bg-secondary", className)}></div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Seprator;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export function cn(...classes: (string | boolean | undefined | null)[]): string {
|
||||||
|
return classes.filter(Boolean).join(' ')
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user