mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-10 06:10:17 -04:00
Ilakkiya_ContainsDropdown_Progress
This commit is contained in:
parent
656edbfac7
commit
a088dc1656
53
compass/components/FilterBox/ContainsDropdown.tsx
Normal file
53
compass/components/FilterBox/ContainsDropdown.tsx
Normal file
|
@ -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 (
|
||||||
|
<div className="relative">
|
||||||
|
<div
|
||||||
|
className={`absolute z-10 mt-8 -top-28 bg-white border border-gray-300 rounded-md shadow-md p-2 ${
|
||||||
|
isDropdownOpen ? "block" : "hidden"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="cursor-pointer hover:bg-gray-100 p-1 rounded"
|
||||||
|
onClick={() => handleFilterTypeChange("contains")}
|
||||||
|
>
|
||||||
|
Contains
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="cursor-pointer hover:bg-gray-100 p-1 rounded"
|
||||||
|
onClick={() => handleFilterTypeChange("does not contain")}
|
||||||
|
>
|
||||||
|
Does not contain
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="cursor-pointer hover:bg-gray-100 p-1 rounded"
|
||||||
|
onClick={() => handleFilterTypeChange("is empty")}
|
||||||
|
>
|
||||||
|
Is empty
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="cursor-pointer hover:bg-gray-100 p-1 rounded"
|
||||||
|
onClick={() => handleFilterTypeChange("is not empty")}
|
||||||
|
>
|
||||||
|
Is not empty
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
|
@ -1,11 +1,17 @@
|
||||||
// FilterBox.tsx
|
// FilterBox.tsx
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { ChevronDownIcon } from "@heroicons/react/24/solid";
|
||||||
|
import { ContainsDropdown } from "./ContainsDropdown";
|
||||||
|
|
||||||
const mockTags = ["food relief", "period poverty", "nutrition education"];
|
const mockTags = ["food relief", "period poverty", "nutrition education"];
|
||||||
|
|
||||||
|
type FilterType = "contains" | "does not contain" | "is empty" | "is not empty";
|
||||||
|
|
||||||
export const FilterBox = () => {
|
export const FilterBox = () => {
|
||||||
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
|
const [showContainsDropdown, setShowContainsDropdown] = useState(false);
|
||||||
|
const [filterType, setFilterType] = useState<FilterType>("contains");
|
||||||
|
|
||||||
const handleTagChange = (tag: string) => {
|
const handleTagChange = (tag: string) => {
|
||||||
setSelectedTags((prevTags) =>
|
setSelectedTags((prevTags) =>
|
||||||
|
@ -38,18 +44,24 @@ export const FilterBox = () => {
|
||||||
return (
|
return (
|
||||||
<div className="bg-white border border-gray-300 rounded-md p-2">
|
<div className="bg-white border border-gray-300 rounded-md p-2">
|
||||||
<div className="mb-2">
|
<div className="mb-2">
|
||||||
<span className="font-semibold">Tags contains:</span>
|
<span className="font-semibold">
|
||||||
|
Tags{" "}
|
||||||
|
<button
|
||||||
|
onClick={() => setShowContainsDropdown((prevState) => !prevState)}
|
||||||
|
className="hover:bg-gray-50 text-gray-500 hover:text-gray-700"
|
||||||
|
>
|
||||||
|
{filterType} <ChevronDownIcon className="inline h-3" />
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap mb-2 px-2 py-1 border border-gray-300 rounded w-full">
|
<div className="flex flex-wrap mb-2 px-2 py-1 border border-gray-300 rounded w-full">
|
||||||
{selectedTags.length > 0 && renderSelectedTags()}
|
{selectedTags.length > 0 && renderSelectedTags()}
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={handleSearchChange}
|
onChange={handleSearchChange}
|
||||||
placeholder="Search tags..."
|
placeholder="Search tags..."
|
||||||
|
/>
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="max-h-48 overflow-y-auto">
|
<div className="max-h-48 overflow-y-auto">
|
||||||
{mockTags
|
{mockTags
|
||||||
|
@ -68,6 +80,14 @@ export const FilterBox = () => {
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
{showContainsDropdown && (
|
||||||
|
<ContainsDropdown
|
||||||
|
isDropdownOpen={showContainsDropdown}
|
||||||
|
setIsDropdownOpen={setShowContainsDropdown}
|
||||||
|
filterType={filterType}
|
||||||
|
setFilterType={setFilterType}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
// TableAction.tsx
|
// TableAction.tsx
|
||||||
import { MagnifyingGlassIcon } from "@heroicons/react/24/solid";
|
import { MagnifyingGlassIcon } from "@heroicons/react/24/solid";
|
||||||
import { ChangeEventHandler, FunctionComponent, useRef, useState } from "react";
|
import { ChangeEventHandler, FunctionComponent, useRef, useState } from "react";
|
||||||
import { FilterBox } from "../../components/FilterBox";
|
import { FilterBox } from "../FilterBox";
|
||||||
|
|
||||||
type TableActionProps = {
|
type TableActionProps = {
|
||||||
query: string;
|
query: string;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user