import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import { CaretRightIcon, CheckIcon, CropIcon, EyeClosedIcon, EyeOpenIcon, FileIcon, FrameIcon, GridIcon, Link2Icon, MixerHorizontalIcon, PersonIcon, TransparencyGridIcon, } from "@radix-ui/react-icons"; import cx from "classnames"; import React, { ReactNode, useState } from "react"; interface RadixMenuItem { label: string; shortcut?: string; icon?: ReactNode; } interface User { name: string; url?: string; } const generalMenuItems: RadixMenuItem[] = [ { label: "New File", icon: , shortcut: "⌘+N", }, { label: "Settings", icon: , shortcut: "⌘+,", }, ]; const regionToolMenuItems: RadixMenuItem[] = [ { label: "Frame", icon: , shortcut: "⌘+F", }, { label: "Crop", icon: , shortcut: "⌘+S", }, ]; const users: User[] = [ { name: "Adam", url: "https://github.com/adamwathan.png", }, { name: "Steve", url: "https://github.com/steveschoger.png", }, { name: "Robin", url: "https://github.com/robinmalfait.png", }, ]; interface Props {} const DropdownMenu = () => { const [showGrid, setShowGrid] = useState(false); const [showUi, setShowUi] = useState(false); return (
{generalMenuItems.map( ({ label, icon, shortcut }, i) => ( {icon} {label} {shortcut && ( {shortcut} )} ) )} { if (state !== "indeterminate") { setShowGrid(state); } }} className={cx( "flex w-full cursor-default select-none items-center rounded-md px-2 py-2 text-xs outline-none", "text-gray-400 focus:bg-gray-50 dark:text-gray-500 dark:focus:bg-gray-900" )} > {showGrid ? ( ) : ( )} Show Grid { if (state !== "indeterminate") { setShowUi(state); } }} className={cx( "flex w-full cursor-default select-none items-center rounded-md px-2 py-2 text-xs outline-none", "text-gray-400 focus:bg-gray-50 dark:text-gray-500 dark:focus:bg-gray-900" )} > {showUi ? ( ) : ( )} Show UI Region Tools {regionToolMenuItems.map( ({ label, icon, shortcut }, i) => ( {icon} {label} {shortcut && ( {shortcut} )} ) )} Share {users.map(({ name, url }, i) => ( {url ? ( ) : ( )} {name} ))}
); }; export default DropdownMenu;