gg
This commit is contained in:
@@ -25,12 +25,17 @@ export default function GlobalSearch() {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const router = useRouter();
|
||||
|
||||
const isApplePlatform =
|
||||
typeof navigator !== "undefined" &&
|
||||
/Mac|iPhone|iPad|iPod/i.test(navigator.platform);
|
||||
const shortcutLabel = isApplePlatform ? "Cmd+K" : "Ctrl+K";
|
||||
const shortcutCapsule = isApplePlatform ? "⌘K" : "Ctrl+K";
|
||||
|
||||
const bg = useColorModeValue("white", "gray.900");
|
||||
const borderColor = useColorModeValue("gray.200", "gray.700");
|
||||
const hoverBg = useColorModeValue("gray.50", "gray.800");
|
||||
const inputBg = useColorModeValue("gray.50", "gray.800");
|
||||
|
||||
// Debounce search input
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setDebouncedQuery(query), 300);
|
||||
return () => clearTimeout(timer);
|
||||
@@ -42,7 +47,6 @@ export default function GlobalSearch() {
|
||||
|
||||
const teams: TeamDto[] = searchData?.data ?? [];
|
||||
|
||||
// Close dropdown on outside click
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (e: MouseEvent) => {
|
||||
if (
|
||||
@@ -56,7 +60,6 @@ export default function GlobalSearch() {
|
||||
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||||
}, []);
|
||||
|
||||
// Keyboard shortcut: Ctrl+K to focus
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "k") {
|
||||
@@ -83,8 +86,11 @@ export default function GlobalSearch() {
|
||||
);
|
||||
|
||||
return (
|
||||
<Box ref={containerRef} position="relative" w={{ base: "full", lg: "280px" }}>
|
||||
{/* Search Input */}
|
||||
<Box
|
||||
ref={containerRef}
|
||||
position="relative"
|
||||
w={{ base: "full", lg: "280px" }}
|
||||
>
|
||||
<Flex
|
||||
align="center"
|
||||
bg={inputBg}
|
||||
@@ -110,7 +116,7 @@ export default function GlobalSearch() {
|
||||
setIsOpen(true);
|
||||
}}
|
||||
onFocus={() => query.length >= 2 && setIsOpen(true)}
|
||||
placeholder="Takım ara... (Ctrl+K)"
|
||||
placeholder={`Takim ara... (${shortcutLabel})`}
|
||||
variant="flushed"
|
||||
size="sm"
|
||||
px={2}
|
||||
@@ -142,11 +148,10 @@ export default function GlobalSearch() {
|
||||
borderRadius="md"
|
||||
fontFamily="mono"
|
||||
>
|
||||
⌘K
|
||||
{shortcutCapsule}
|
||||
</Text>
|
||||
</Flex>
|
||||
|
||||
{/* Dropdown Results */}
|
||||
{isOpen && debouncedQuery.length >= 2 && (
|
||||
<Box
|
||||
position="absolute"
|
||||
@@ -170,7 +175,7 @@ export default function GlobalSearch() {
|
||||
) : teams.length === 0 ? (
|
||||
<Flex justify="center" py={6}>
|
||||
<Text fontSize="sm" color="fg.muted">
|
||||
Sonuç bulunamadı
|
||||
Sonuc bulunamadi
|
||||
</Text>
|
||||
</Flex>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user