From a088dc16569010dafb6bd4daac3062bd4d1e657b Mon Sep 17 00:00:00 2001 From: Ilakkiya Senthilkumar Date: Fri, 19 Apr 2024 18:15:23 -0400 Subject: [PATCH] Ilakkiya_ContainsDropdown_Progress --- .../components/FilterBox/ContainsDropdown.tsx | 53 +++++++++++++++++++ .../{FilterBox.tsx => FilterBox/index.tsx} | 40 ++++++++++---- compass/components/Table/TableAction.tsx | 2 +- 3 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 compass/components/FilterBox/ContainsDropdown.tsx rename compass/components/{FilterBox.tsx => FilterBox/index.tsx} (60%) diff --git a/compass/components/FilterBox/ContainsDropdown.tsx b/compass/components/FilterBox/ContainsDropdown.tsx new file mode 100644 index 0000000..1d942e4 --- /dev/null +++ b/compass/components/FilterBox/ContainsDropdown.tsx @@ -0,0 +1,53 @@ +import { useState } from "react"; +import { ChevronDownIcon } from "@heroicons/react/24/solid"; + +const mockTags = ["food relief", "period poverty", "nutrition education"]; + +type FilterType = "contains" | "does not contain" | "is empty" | "is not empty"; + +export const ContainsDropdown = ({ + isDropdownOpen, + setIsDropdownOpen, + filterType, + setFilterType, +}) => { + const handleFilterTypeChange = (type: FilterType) => { + setFilterType(type); + setIsDropdownOpen(false); + }; + + return ( +
+
+
handleFilterTypeChange("contains")} + > + Contains +
+
handleFilterTypeChange("does not contain")} + > + Does not contain +
+
handleFilterTypeChange("is empty")} + > + Is empty +
+
handleFilterTypeChange("is not empty")} + > + Is not empty +
+
+
+ ); +}; \ No newline at end of file diff --git a/compass/components/FilterBox.tsx b/compass/components/FilterBox/index.tsx similarity index 60% rename from compass/components/FilterBox.tsx rename to compass/components/FilterBox/index.tsx index a38574c..ce1e958 100644 --- a/compass/components/FilterBox.tsx +++ b/compass/components/FilterBox/index.tsx @@ -1,11 +1,17 @@ // FilterBox.tsx import { useState } from "react"; +import { ChevronDownIcon } from "@heroicons/react/24/solid"; +import { ContainsDropdown } from "./ContainsDropdown"; const mockTags = ["food relief", "period poverty", "nutrition education"]; +type FilterType = "contains" | "does not contain" | "is empty" | "is not empty"; + export const FilterBox = () => { const [selectedTags, setSelectedTags] = useState([]); const [searchTerm, setSearchTerm] = useState(""); + const [showContainsDropdown, setShowContainsDropdown] = useState(false); + const [filterType, setFilterType] = useState("contains"); const handleTagChange = (tag: string) => { setSelectedTags((prevTags) => @@ -38,18 +44,24 @@ export const FilterBox = () => { return (
- Tags contains: - + + Tags{" "} + +
- {selectedTags.length > 0 && renderSelectedTags()} - + {selectedTags.length > 0 && renderSelectedTags()} +
{mockTags @@ -68,6 +80,14 @@ export const FilterBox = () => {
))}
+ {showContainsDropdown && ( + + )} ); }; diff --git a/compass/components/Table/TableAction.tsx b/compass/components/Table/TableAction.tsx index 737b95a..852c3a4 100644 --- a/compass/components/Table/TableAction.tsx +++ b/compass/components/Table/TableAction.tsx @@ -1,7 +1,7 @@ // TableAction.tsx import { MagnifyingGlassIcon } from "@heroicons/react/24/solid"; import { ChangeEventHandler, FunctionComponent, useRef, useState } from "react"; -import { FilterBox } from "../../components/FilterBox"; +import { FilterBox } from "../FilterBox"; type TableActionProps = { query: string;