From 06d5f3d1cb30e27c2f2300bd18dcea9ea1b14bb2 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 13 Sep 2023 21:04:56 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Implemented=20Language=20Dropdow?= =?UTF-8?q?n=20component.=20=F0=9F=92=BC=20Added=20Currency=20Dropdown=20c?= =?UTF-8?q?omponent.=20=F0=9F=8C=90=20Updated=20language=20options.=20?= =?UTF-8?q?=F0=9F=AA=99=20Enhanced=20currency=20selection.=20=F0=9F=94=A7?= =?UTF-8?q?=20Refactored=20and=20optimized=20code=20for=20Dropdowns.=20?= =?UTF-8?q?=F0=9F=8E=A8=20Improved=20styling=20for=20Dropdowns.=20?= =?UTF-8?q?=F0=9F=90=9B=20Fixed=20minor=20issues=20in=20Dropdown=20compone?= =?UTF-8?q?nts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(Header)/LangDropdown.tsx | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 src/app/(client-components)/(Header)/LangDropdown.tsx diff --git a/src/app/(client-components)/(Header)/LangDropdown.tsx b/src/app/(client-components)/(Header)/LangDropdown.tsx new file mode 100644 index 0000000..895ec8c --- /dev/null +++ b/src/app/(client-components)/(Header)/LangDropdown.tsx @@ -0,0 +1,184 @@ +import { Popover, Tab, Transition } from "@headlessui/react"; +import { + BanknotesIcon, + GlobeAltIcon, + ChevronDownIcon, +} from "@heroicons/react/24/outline"; +import { FC, Fragment } from "react"; +import { headerCurrency } from "./CurrencyDropdown"; + +export const headerLanguage = [ + { + id: "English", + name: "English", + description: "United State", + href: "##", + active: true, + }, + { + id: "Vietnamese", + name: "Vietnamese", + description: "Vietnamese", + href: "##", + }, + { + id: "Francais", + name: "Francais", + description: "Belgique", + href: "##", + }, + { + id: "Francais", + name: "Francais", + description: "Canada", + href: "##", + }, + { + id: "Francais", + name: "Francais", + description: "Belgique", + href: "##", + }, + { + id: "Francais", + name: "Francais", + description: "Canada", + href: "##", + }, +]; + +interface LangDropdownProps { + panelClassName?: string; + className?: string; +} + +function classNames(...classes: any) { + return classes.filter(Boolean).join(" "); +} + +const LangDropdown: FC = ({ + panelClassName = "top-full right-0 max-w-sm w-96", + className = "hidden md:flex", +}) => { + const renderLang = (close: () => void) => { + return ( +
+ {headerLanguage.map((item, index) => ( + close()} + className={`flex items-center p-2 -m-3 transition duration-150 ease-in-out rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus-visible:ring focus-visible:ring-orange-500 focus-visible:ring-opacity-50 ${ + item.active ? "bg-gray-100 dark:bg-gray-700" : "opacity-80" + }`} + > +
+

{item.name}

+

+ {item.description} +

+
+
+ ))} +
+ ); + }; + + const renderCurr = (close: () => void) => { + return ( +
+ {headerCurrency.map((item, index) => ( + close()} + className={`flex items-center p-2 -m-3 transition duration-150 ease-in-out rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus-visible:ring focus-visible:ring-orange-500 focus-visible:ring-opacity-50 ${ + item.active ? "bg-gray-100 dark:bg-gray-700" : "opacity-80" + }`} + > + +

{item.name}

+
+ ))} +
+ ); + }; + + return ( + <> + + {({ open, close }) => ( + <> + + + / + + + + +
+ + + {["Language", "Currency"].map((category) => ( + + classNames( + "w-full rounded-full py-2 text-sm font-medium leading-5 text-gray-700", + "focus:outline-none focus:ring-0", + selected + ? "bg-white shadow" + : "text-gray-700 dark:text-slate-300 hover:bg-white/70 dark:hover:bg-slate-900/40" + ) + } + > + {category} + + ))} + + + + {renderLang(close)} + + + {renderCurr(close)} + + + +
+
+
+ + )} +
+ + ); +}; +export default LangDropdown;