From 1a2241c40e10193c5ff7008a7b7b36cc1d855d96 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Tue, 25 Mar 2025 15:55:45 +0900
Subject: initial commit
---
components/layout/command-menu.tsx | 139 +++++++++++++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
create mode 100644 components/layout/command-menu.tsx
(limited to 'components/layout/command-menu.tsx')
diff --git a/components/layout/command-menu.tsx b/components/layout/command-menu.tsx
new file mode 100644
index 00000000..5537a042
--- /dev/null
+++ b/components/layout/command-menu.tsx
@@ -0,0 +1,139 @@
+"use client"
+
+import * as React from "react"
+import { useRouter,usePathname } from "next/navigation"
+import { type DialogProps } from "@radix-ui/react-dialog"
+import { Circle, File, Laptop, Moon, Sun } from "lucide-react"
+import { useTheme } from "next-themes"
+
+import { MenuSection, mainNav, additionalNav, MenuItem, mainNavVendor, additionalNavVendor } from "@/config/menuConfig";
+import { cn } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
+import {
+ CommandDialog,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+ CommandSeparator,
+} from "@/components/ui/command"
+import { DialogTitle } from "@/components/ui/dialog"
+
+export function CommandMenu({ ...props }: DialogProps) {
+ const router = useRouter()
+ const [open, setOpen] = React.useState(false)
+ const { setTheme } = useTheme()
+
+ React.useEffect(() => {
+ const down = (e: KeyboardEvent) => {
+ if ((e.key === "k" && (e.metaKey || e.ctrlKey)) || e.key === "/") {
+ if (
+ (e.target instanceof HTMLElement && e.target.isContentEditable) ||
+ e.target instanceof HTMLInputElement ||
+ e.target instanceof HTMLTextAreaElement ||
+ e.target instanceof HTMLSelectElement
+ ) {
+ return
+ }
+
+ e.preventDefault()
+ setOpen((open) => !open)
+ }
+ }
+
+ document.addEventListener("keydown", down)
+ return () => document.removeEventListener("keydown", down)
+ }, [])
+
+ const runCommand = React.useCallback((command: () => unknown) => {
+ setOpen(false)
+ command()
+ }, [])
+
+
+const pathname = usePathname();
+const isPartnerRoute = pathname.includes("/partners");
+
+ const main = isPartnerRoute ? mainNavVendor : mainNav;
+ const additional = isPartnerRoute ? additionalNavVendor : additionalNav;
+
+
+ return (
+ <>
+
+
+ Search Menu
+
+
+ No results found.
+
+ {main.map((group) => (
+
+ {group.items.map((navItem) => (
+ {
+ runCommand(() => router.push(navItem.href as string))
+ }}
+ >
+
+
+
+ {navItem.title}
+
+ ))}
+
+ ))}
+
+ {additional
+ // .filter((navitem) => !navitem.external)
+ .map((navItem) => (
+ {
+ runCommand(() => router.push(navItem.href as string))
+ }}
+ >
+
+ {navItem.title}
+
+ ))}
+
+
+
+
+
+ runCommand(() => setTheme("light"))}>
+
+ Light
+
+ runCommand(() => setTheme("dark"))}>
+
+ Dark
+
+ runCommand(() => setTheme("system"))}>
+
+ System
+
+
+
+
+ >
+ )
+}
--
cgit v1.2.3