#942
File menu
A dashed file area that opens a Rename, Pinned, Move to and Delete menu at the pointer on right-click, at the finger on a long touch press, or from the keyboard with Shift+F10.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "File menu" pattern (@codeatlasdev/ui demo #942, navigation/context-menu) in my app.
Call get_demo({ ids: ["#942"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Context menus on rows, files or canvases that reuse the DropdownMenu items, including checkbox items and submenus, without wiring any event handler.
Keep these library parts, with the props and tokens the demo uses:
- announce, ContextMenu, DropdownMenuCheckboxItem, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubTrigger from "@codeatlasdev/ui"
Behaviour to keep:
- `<ContextMenu class="cm-area" role="group" aria-label="Project file">` wraps the region content and takes the items in a `{#snippet menu()}`
- The menu holds `DropdownMenuItem`, a `<DropdownMenuCheckboxItem bind:checked={pinned}>`, a `DropdownMenuSub` with `DropdownMenuSubTrigger`, a `DropdownMenuSeparator` and a destructive Delete
- Each action item calls `function pick(action: string)`, which sets `last` and calls `announce`
- Pinned (yes or no) and the last action are shown below the area
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
- ContextMenu
@codeatlasdev/ui - DropdownMenuCheckboxItem
@codeatlasdev/ui - DropdownMenuItem
@codeatlasdev/ui - DropdownMenuSeparator
@codeatlasdev/ui - DropdownMenuSub
@codeatlasdev/ui - DropdownMenuSubTrigger
@codeatlasdev/ui
How it is built
- `<ContextMenu class="cm-area" role="group" aria-label="Project file">` wraps the region content and takes the items in a `{#snippet menu()}`
- The menu holds `DropdownMenuItem`, a `<DropdownMenuCheckboxItem bind:checked={pinned}>`, a `DropdownMenuSub` with `DropdownMenuSubTrigger`, a `DropdownMenuSeparator` and a destructive Delete
- Each action item calls `function pick(action: string)`, which sets `last` and calls `announce`
- Pinned (yes or no) and the last action are shown below the area
Related
Loading source.