Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

feat: ui input field for tags

flooorianflo03679d0450ad
diff --git a/apps/web/ui/analytics/tag-selector.tsx b/apps/web/ui/analytics/tag-selector.tsx
index 5fd0ff42f3..4413977161 100644
--- a/apps/web/ui/analytics/tag-selector.tsx
+++ b/apps/web/ui/analytics/tag-selector.tsx
@@ -1,6 +1,6 @@
import useTags from "@/lib/swr/use-tags";
import { IconMenu, Popover, Tick, useRouterStuff } from "@dub/ui";
-import { ChevronDown, Tag } from "lucide-react";
+import { ChevronDown, Search, Tag } from "lucide-react";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { useState } from "react";
@@ -14,11 +14,33 @@ export default function TagSelector() {
const selectedTagId = searchParams?.get("tagId");
const [openPopover, setOpenPopover] = useState(false);
+ const [filterValue, setFilterValue] = useState("");
+
+ // filter the tags through the search input
+ const filteredTags = tags
+ ? tags!.filter((tag) =>
+ tag.name.toLowerCase().includes(filterValue.toLowerCase()),
+ )
+ : [];
return tags && tags.length > 0 ? (
<Popover
content={
<div className="grid w-full p-2 md:w-48">
+ {tags.length > 10 && (
+ <div className="relative mb-2">
+ <div className="pointer-events-none absolute inset-y-0 left-3.5 flex items-center">
+ <Search className="h-4 w-4 text-gray-400" />
+ </div>
+ <input
+ type="text"
+ value={filterValue}
+ onChange={(e) => setFilterValue(e.target.value)}
+ className="w-full rounded-md border border-gray-300 py-2 pl-10 text-black placeholder:text-gray-400 focus:border-black focus:outline-none focus:ring-gray-600 sm:text-sm"
+ placeholder="Filter tags..."
+ />
+ </div>
+ )}
<Link
href={
queryParams({
@@ -31,7 +53,7 @@ export default function TagSelector() {
<p className="text-sm">All tags</p>
{!selectedTagId && <Tick className="h-4 w-4" aria-hidden="true" />}
</Link>
- {tags.map((tag) => (
+ {filteredTags.map((tag) => (
<Link
key={tag.id}
href={