108 lines
3.3 KiB
TypeScript
108 lines
3.3 KiB
TypeScript
"use client";
|
|
import React, { useState, useEffect } from "react";
|
|
import { Input } from "./ui/input";
|
|
import { Label } from "./ui/label";
|
|
import { Button } from "./ui/button";
|
|
import { CiSearch } from "react-icons/ci";
|
|
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogDescription,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
AlertDialogTrigger,
|
|
} from "@/components/ui/alert-dialog";
|
|
import { IoMdClose } from "react-icons/io";
|
|
|
|
export default function Search() {
|
|
// resize
|
|
function getSize() {
|
|
return {
|
|
width: window.innerWidth,
|
|
};
|
|
}
|
|
const [windowSize, setWindowSize] = useState(getSize);
|
|
|
|
useEffect(() => {
|
|
function handleResize() {
|
|
setWindowSize(getSize());
|
|
}
|
|
|
|
window.addEventListener("resize", handleResize);
|
|
return () => window.removeEventListener("resize", handleResize);
|
|
}, [windowSize]);
|
|
|
|
return (
|
|
<div>
|
|
{window.innerWidth >= 768 ? (
|
|
<div className=" relative flex bg-gray-300 rounded-xl items-center">
|
|
<Input
|
|
// type="search"
|
|
id="default-search"
|
|
className="mb-0 h-8 bg-[#D6D8DE66] border-none focus-visible:none rounded-lg
|
|
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black text-opacity-60 dark:text-white "
|
|
placeholder="جستجو..."
|
|
required
|
|
/>
|
|
{/* <Button
|
|
className="absolute left-0 bg-transparent h-auto w-auto text-slate-800"
|
|
>
|
|
<CiSearch />
|
|
</Button> */}
|
|
<button className="absolute left-3">
|
|
<CiSearch />
|
|
</button>
|
|
</div>
|
|
) : (
|
|
<div className="">
|
|
<AlertDialog>
|
|
<AlertDialogTrigger asChild>
|
|
<button
|
|
// variant="outline"
|
|
// type="submit"
|
|
className=" bg-gradient2 text-black rounded-md p-1"
|
|
>
|
|
<CiSearch />
|
|
</button>
|
|
</AlertDialogTrigger>
|
|
|
|
<AlertDialogContent className=" h-1/5 min-w-[80%] max-w-fit">
|
|
<AlertDialogHeader className="w-full" >
|
|
<AlertDialogTitle className=" py-1">
|
|
<p className="text-[#464646] text-base font-bold">
|
|
فرم جستجو
|
|
</p>
|
|
<AlertDialogCancel className="p-0 border-0 h-auto">
|
|
<IoMdClose />
|
|
</AlertDialogCancel>
|
|
</AlertDialogTitle>
|
|
|
|
<AlertDialogDescription className="justify-center sm:px-14 sm:py-6">
|
|
|
|
<Input
|
|
// type="search"
|
|
id="default-search"
|
|
className="mb-0 h-12 bg-gray border-none focus-visible:none rounded-lg
|
|
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black text-opacity-60 dark:text-white "
|
|
placeholder="جستجو..."
|
|
required
|
|
/>
|
|
|
|
<button className="absolute left-16 text-black">
|
|
<CiSearch />
|
|
</button>
|
|
</AlertDialogDescription>
|
|
|
|
</AlertDialogHeader>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|