Sootzani/components/Search.tsx

112 lines
3.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"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-full p-2"
>
<CiSearch />
</button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
<p className="text-[#464646] text-base font-bold">فرم جستجو</p>
<AlertDialogCancel className="p-0 border-0 h-auto"><IoMdClose /></AlertDialogCancel>
</AlertDialogTitle>
<AlertDialogDescription>
<p className="text-[#464646] text-sm font-medium"> موضوع شکایت: <span className="text-[#7C838A] text-sm font-medium">متن تستی</span></p>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
{/* <AlertDialogCancel>Cancel</AlertDialogCancel> */}
<AlertDialogAction className="bg-blue text-white w-1/2 sm:w-1/6">پرینت گزارش</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
)}
</div>
);
}