Shadcn Command Menu
revola/shadcn-command-menuFreeComponent
A responsive shadcn's adapted command menu component that automatically adapts to screen size - drawer on mobile, modal on desktop.
Install it
npx shadcn@latest add https://revola.sameerjs.com/r/shadcn-command-menu.jsonSource
1"use client";23import * as React from "react";4import { useRouter } from "next/navigation";56import { ArrowRight, CornerDownLeftIcon } from "lucide-react";78import { Button } from "@/components/ui/button";9import {10 ResponsiveCommand,11 ResponsiveCommandEmpty,12 ResponsiveCommandGroup,13 ResponsiveCommandInput,14 ResponsiveCommandItem,15 ResponsiveCommandList,16} from "@/components/ui/responsive-command";17import {18 ResponsiveDialog,19 ResponsiveDialogContent,20 ResponsiveDialogDescription,21 ResponsiveDialogHeader,22 ResponsiveDialogTitle,23 ResponsiveDialogTrigger,24} from "@/components/ui/revola";25import { Separator } from "@/components/ui/separator";26import { type Color, type ColorPalette } from "@/lib/colors";27import { source, type Tree } from "@/lib/source";28import { cn } from "@/lib/utils";2930import { useIsMac } from "@/hooks/use-is-mac";31import { useMutationObserver } from "@/hooks/use-mutation-observer";3233type TreeNode = (typeof source.pageTree)["children"][number];3435function copyToClipboardWithoutMeta(value: string) {36 navigator.clipboard.writeText(value);37}3839type SimplifiedGroup = {40 name: string;41 children: Array<{42 type: "page";43 name: string;44 url: string;45 icon?: React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;46 }>;47};4849type CommandMenuProps = {50 tree: Tree["pageTree"];51 colors: ColorPalette[];52};5354// Transform the mixed tree structure into simplified groups55function simplifyTreeStructure(tree: TreeNode[]): SimplifiedGroup[] {56 const groups: SimplifiedGroup[] = [];57 let currentGroup: SimplifiedGroup | null = null;5859 for (const item of tree) {60 switch (item.type) {61 case "separator": {62 currentGroup = {63 name: item.name?.toString() || "Untitled",64 children: [],65 };66 groups.push(currentGroup);67 break;68 }69 case "page": {70 if (currentGroup) {71 currentGroup.children.push({72 type: "page",73 name: item.name?.toString() || "Untitled",74 url: item.url,75 ...(item.icon && { icon: item.icon }),76 });77 } else {78 groups.push({79 name: item.name?.toString() || "Untitled",80 children: [81 {82 type: "page",83 name: item.name?.toString() || "Untitled",84 url: item.url,85// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from revola
All 24 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Alert Dialogalert-dialog | revola | Components | Free | no deps | |
| Alert Dialog with Iconalert-dialog-with-icon | revola | Components | Free | 1 dep | |
| Change Plan Dialogchange-plan | revola | Components | Free | 1 dep | |
| Checkout Dialogcheckout | revola | Components | Free | 2 deps | |
| Credit Card Dialogcredit-card | revola | Components | Free | 2 deps | |
| Custom Scrollbar Dialogcustom-scrollbar | revola | Components | Free | no deps | |
| Delete Project Dialogdelete-project | revola | Components | Free | 1 dep | |
| Edit Profile Dialogedit-profile | revola | Components | Free | 1 dep · 3 files |
