aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web/components/dashboard/search/SearchInput.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-10 20:27:59 +0000
committerMohamedBassem <me@mbassem.com>2024-03-10 20:27:59 +0000
commit364e82c7f2f10759b437c0282021d5dfef98c922 (patch)
tree3760491f24b4c25d8d5c826fba9d796d48172550 /packages/web/components/dashboard/search/SearchInput.tsx
parentd6dd76021226802adf5295b3243d6f2ae4fa5cc2 (diff)
downloadkarakeep-364e82c7f2f10759b437c0282021d5dfef98c922.tar.zst
feature: Change top nav to include search and move add link to a modal
Diffstat (limited to 'packages/web/components/dashboard/search/SearchInput.tsx')
-rw-r--r--packages/web/components/dashboard/search/SearchInput.tsx25
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/web/components/dashboard/search/SearchInput.tsx b/packages/web/components/dashboard/search/SearchInput.tsx
new file mode 100644
index 00000000..73d14c90
--- /dev/null
+++ b/packages/web/components/dashboard/search/SearchInput.tsx
@@ -0,0 +1,25 @@
+import { Input } from "@/components/ui/input";
+import { useDoBookmarkSearch } from "@/lib/hooks/bookmark-search";
+import { cn } from "@/lib/utils";
+import React from "react";
+
+const SearchInput = React.forwardRef<
+ HTMLInputElement,
+ React.HTMLAttributes<HTMLInputElement> & { loading?: boolean }
+>(({ className, loading = false, ...props }, ref) => {
+ const { debounceSearch, searchQuery } = useDoBookmarkSearch();
+
+ return (
+ <Input
+ ref={ref}
+ placeholder="Search"
+ defaultValue={searchQuery}
+ onChange={(e) => debounceSearch(e.target.value)}
+ className={cn(loading ? "animate-pulse-border" : undefined, className)}
+ {...props}
+ />
+ );
+});
+SearchInput.displayName = "SearchInput";
+
+export { SearchInput };