diff --git a/.changeset/menu-touch-grow.md b/.changeset/menu-touch-grow.md new file mode 100644 index 0000000000000..7ebc16e1d2283 --- /dev/null +++ b/.changeset/menu-touch-grow.md @@ -0,0 +1,7 @@ +--- +'@astryxdesign/core': patch +--- + +[feature] Under a finger or a pen, a DropdownMenu or MoreMenu now grows out of its trigger as it opens and shrinks back into it as it closes, on a Popover's path and timing (`spec:AST-094` FR31). A tap's open grows as a hold's does. Under Reduce Motion on a phone or tablet (a coarse primary pointer), the menu fades in at its size and out where it stands. A mouse, the keyboard and `presentation="popover"` keep the layer's own entrance. + +@vjeux diff --git a/apps/sandbox/scripts/next-export-routes.json b/apps/sandbox/scripts/next-export-routes.json index 1478ce270b345..5e26b13dd89b9 100644 --- a/apps/sandbox/scripts/next-export-routes.json +++ b/apps/sandbox/scripts/next-export-routes.json @@ -28,6 +28,7 @@ "/pages/markdown-perf/", "/pages/media-mode/", "/pages/mega-menu/", + "/pages/menu-grow-cases/", "/pages/menu-press-cases/", "/pages/minute-wheel-loop/", "/pages/mobile-keyboard-fields/", diff --git a/apps/sandbox/src/app/(raw)/pages/menu-grow-cases/page.tsx b/apps/sandbox/src/app/(raw)/pages/menu-grow-cases/page.tsx new file mode 100644 index 0000000000000..332741b48f11a --- /dev/null +++ b/apps/sandbox/src/app/(raw)/pages/menu-grow-cases/page.tsx @@ -0,0 +1,204 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. + +'use client'; + +/** + * @file page.tsx + * @input None + * @output A bare page of large DropdownMenus and a Popover, spread down a + * page that scrolls with the document + * @position A raw page, with no sandbox chrome, for checking on a phone how + * menus grow out of their trigger and shrink back. It has a tall menu that + * scrolls, a wide one and a filter menu with many rows. It also has nested + * sub-menus, menus at each edge, one that flips above, and a Popover. + */ + +import {Button} from '@astryxdesign/core/Button'; +import { + DropdownMenu, + type DropdownMenuOption, +} from '@astryxdesign/core/DropdownMenu'; +import {HStack, VStack} from '@astryxdesign/core/Layout'; +import {Popover} from '@astryxdesign/core/Popover'; +import {Heading, Text} from '@astryxdesign/core/Text'; + +const SHORT: DropdownMenuOption[] = [ + {label: 'Edit'}, + {label: 'Duplicate'}, + {label: 'Share'}, + {label: 'Delete', variant: 'destructive'}, +]; + +const TALL: DropdownMenuOption[] = Array.from({length: 40}, (_, index) => ({ + label: `Project ${index + 1}`, +})); + +const WIDE: DropdownMenuOption[] = [ + { + label: 'Export the whole workspace as a spreadsheet', + description: 'Every table, with its filters and hidden columns', + }, + { + label: 'Copy a link that opens this exact view', + description: 'Sorting, grouping and the scroll position travel with it', + }, + { + label: 'Send a weekly summary to the team channel', + description: 'Every Monday morning, in the channel time zone', + }, +]; + +function section(title: string, labels: string[]): DropdownMenuOption { + return {type: 'section', title, items: labels.map(label => ({label}))}; +} + +const FILTERS: DropdownMenuOption[] = [ + section('Status', ['Open', 'In progress', 'In review', 'Blocked', 'Done']), + {type: 'divider'}, + section('Priority', ['Urgent', 'High', 'Medium', 'Low']), + {type: 'divider'}, + section('Owner', [ + 'Anyone', + 'Me', + 'My team', + 'Unassigned', + 'Recently active', + 'Former members', + ]), + {type: 'divider'}, + section('Labels', [ + 'Bug', + 'Feature', + 'Design', + 'Docs', + 'Performance', + 'Accessibility', + 'Security', + 'Mobile', + ]), +]; + +const NESTED: DropdownMenuOption[] = [ + {label: 'New file'}, + { + label: 'Move to', + items: [ + {label: 'Inbox'}, + { + label: 'Projects', + items: [ + {label: 'Website'}, + {label: 'Mobile app'}, + { + label: 'Archive', + items: [{label: '2024'}, {label: '2025'}, {label: '2026'}], + }, + ], + }, + {label: 'Shared with me'}, + ], + }, + { + label: 'Share', + items: [{label: 'Copy link'}, {label: 'Email'}, {label: 'Message'}], + }, + {label: 'Delete', variant: 'destructive'}, +]; + +const FILLER = Array.from({length: 12}, (_, index) => `Row ${index + 1}`); + +function Filler() { + return ( + + {FILLER.map(row => ( + + {row} + + ))} + + ); +} + +function Case({title, children}: {title: string; children: React.ReactNode}) { + return ( + + {title} + {children} + + ); +} + +export default function MenuGrowCasesPage() { + return ( + + + + + + + Menu grow cases + + Tap or hold each trigger: the menu grows out of it and shrinks back + into it. The Popover below grows the same way. + + + + + + + + + + + + + + + + + + Filter + {['Open', 'In progress', 'In review', 'Done'].map(label => ( + {label} + ))} + + }> +