diff --git a/src/components/atoms/Dropdown/index.tsx b/src/components/atoms/Dropdown/index.tsx new file mode 100644 index 0000000..e2b3ccf --- /dev/null +++ b/src/components/atoms/Dropdown/index.tsx @@ -0,0 +1,43 @@ +"use client"; +import { FC, useEffect, useState } from "react"; +import { FaFilter } from "react-icons/fa"; + +type Props = { + items: { + label: string; + value: string; + }[]; + defaultValue: string; + callback?: (value: string) => void; +}; + +export const Dropdown: FC = ({ items, defaultValue, callback }) => { + const [value, setValue] = useState(defaultValue); + + useEffect(() => { + callback?.(value); + }, [value]); + + return ( +
+ + +
+ {items.map((item) => ( +

{ + setValue(item.value); + }} + className={`block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-300 transform hover:bg-primary-50 cursor-pointer ${ + value === item.value ? "bg-primary-50" : "" + }`} + > + {item.label} +

+ ))} +
+
+ ); +};