From 13bca5d95de10c76e95b05beddea20de8cabda61 Mon Sep 17 00:00:00 2001 From: Nolawz Date: Tue, 3 Mar 2026 11:52:14 +0530 Subject: Added search functionality --- src/components/react/SearchButton.tsx | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/components/react/SearchButton.tsx (limited to 'src/components/react/SearchButton.tsx') diff --git a/src/components/react/SearchButton.tsx b/src/components/react/SearchButton.tsx new file mode 100644 index 0000000..17aad93 --- /dev/null +++ b/src/components/react/SearchButton.tsx @@ -0,0 +1,51 @@ +import React, { useState, useEffect } from 'react' +import { Search } from 'lucide-react' +import { Button } from '@/components/ui/button' +import SearchDialog from './SearchDialog' +import { ErrorBoundary } from './ErrorBoundary' + +const SearchButton: React.FC = () => { + const [isOpen, setIsOpen] = useState(false) + + // Keyboard shortcut: Cmd/Ctrl + K + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + // Don't trigger if user is typing in an input, textarea, or contenteditable + const target = e.target as HTMLElement + const isInput = target.tagName === 'INPUT' || + target.tagName === 'TEXTAREA' || + target.isContentEditable + + if ((e.metaKey || e.ctrlKey) && e.key === 'k' && !isInput) { + e.preventDefault() + setIsOpen(true) + } + } + + window.addEventListener('keydown', handleKeyDown) + return () => window.removeEventListener('keydown', handleKeyDown) + }, []) + + return ( + + + + + + + ) +} + +export default SearchButton -- cgit v1.2.3