From da5fbb78c431237f4d0df6a1814f2604e59b537e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 06:19:39 +0000 Subject: [PATCH 1/7] wip(studio): left menu drawn as the app menu, graphite accent Claude-Session: https://claude.ai/code/session_01Utp6CbL6Nn3scsU8yvLyU4 Co-authored-by: Claude --- .../src/views/studio-design/StudioMenu.tsx | 299 ++++++++++++------ .../src/views/studio-design/studio-tokens.ts | 38 +++ ui/packages/layout/src/NavigationRenderer.tsx | 144 ++++++--- 3 files changed, 348 insertions(+), 133 deletions(-) diff --git a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx index bc5cf651a78..0ccd19050c5 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioMenu.tsx @@ -17,12 +17,21 @@ * the shell's leave guard (`useRegisterUnsavedEdits`), whose capture-phase * link guard asks before any of them leaves. * + * ## Drawn as the app's menu (objectstack#37452) + * + * A group is the app menu's collapsible group (`NavigationGroupSection` from + * `@object-ui/layout`): its label is a disclosure button with a chevron, open + * by default and while a search lists matches, and it carries no count. An + * entry is the app menu's row: a line icon with no tile, its name, and its + * muted item count; the open page's entry is the app menu's inset pill with a + * bar on its left edge. Studio's own accent, graphite ({@link STUDIO_ACCENT}), + * tints the pill and the bar, never the app's theme colour. + * * ## Two tiers on a package (ADR-0084, amended 2026-11-25; objectstack#37201) * - * A group's label is a small muted heading: no count, not a link, not - * focusable. Only entries look clickable, and an entry's muted number means - * one thing, its items. The 常用 Common groups come first; below a divider, - * one 「高级」 button folds every 高级 Advanced entry under the same labels. + * An entry's muted number means one thing, its items. The 常用 Common groups + * come first; below a divider, one 「高级」 button folds every 高级 Advanced + * entry under the same labels. * - The fold is closed by default and remembered per browser under its own * cookie, {@link STUDIO_MENU_ADVANCED_COOKIE}; only a click writes it. * - It opens itself while the open page is one of its entries (a bookmark to @@ -39,13 +48,52 @@ import * as React from 'react'; import { Link, useLocation } from 'react-router-dom'; -import { ChevronRight, PanelLeft } from 'lucide-react'; +import { + Activity, + AppWindow, + BarChart3, + BookOpen, + Bot, + Boxes, + Brain, + Building2, + CalendarClock, + ChevronRight, + Database, + File, + FileText, + Gauge, + Globe, + Inbox, + KeyRound, + Languages, + LayoutGrid, + ListChecks, + ListTree, + Mail, + MousePointerClick, + PanelLeft, + Puzzle, + Rows3, + Share2, + Shield, + Sparkles, + Sprout, + Table2, + Unplug, + UserCog, + Users, + Webhook, + Workflow, + Wrench, + ArrowLeftRight, + ShieldCheck, + type LucideIcon, +} from 'lucide-react'; import { cn, Sidebar, SidebarContent, - SidebarGroup, - SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarMenu, @@ -54,6 +102,7 @@ import { SidebarProvider, useSidebar, } from '@object-ui/components'; +import { NavigationGroupSection } from '@object-ui/layout'; import { STUDIO_MENU_ENTRY_LABEL_KEYS, STUDIO_MENU_GROUP_ICONS, @@ -64,7 +113,7 @@ import { } from './studioMenuData.js'; import { t, tFormat, translateMetadataType } from '../metadata-admin/i18n.js'; import { studioMenuGroupLabel } from './studioMenuGroupLabel.js'; -import { STUDIO_HEADER_ICON_BUTTON } from './studio-tokens.js'; +import { STUDIO_ACCENT, STUDIO_HEADER_ICON_BUTTON } from './studio-tokens.js'; import { STUDIO_MENU_ADVANCED_COOKIE, STUDIO_MENU_COOKIE, @@ -76,6 +125,7 @@ import { studioMenuScope, studioMenuTiers, type StudioMenuEntry, + type StudioMenuGroup, type StudioMenuGroupModel, type StudioMenuTier, } from './studioMenuModel.js'; @@ -91,16 +141,90 @@ function writeAdvancedCookie(open: boolean): void { document.cookie = `${STUDIO_MENU_ADVANCED_COOKIE}=${open}; path=/; max-age=${ADVANCED_COOKIE_MAX_AGE}`; } +/** + * Each listed type's line icon, drawn bare (no tile) before its name, as the + * app menu draws an entry's. A type with no row here draws its group's icon. + */ +export const STUDIO_MENU_TYPE_ICONS: Readonly> = { + object: Table2, + app: LayoutGrid, + page: File, + dashboard: Gauge, + report: BarChart3, + flow: Workflow, + permission: Shield, + agent: Bot, + tool: Wrench, + skill: Sparkles, + picklist: ListChecks, + hook: Webhook, + mapping: ArrowLeftRight, + object_extension: Puzzle, + seed: Sprout, + view: Rows3, + action: MousePointerClick, + dataset: Boxes, + job: CalendarClock, + doc: FileText, + book: BookOpen, + email_template: Mail, + translation: Languages, + api: Globe, + datasource: Database, + external_catalog: Unplug, + position: Users, + assignment_rule: UserCog, + sharing_rule: Share2, + queue: Inbox, + capability: ListTree, + ai_context: Brain, +}; + +/** The icon of each entry that is not a type: the page it opens. */ +const STUDIO_MENU_KIND_ICONS: Readonly, LucideIcon>> = { + orgFlows: Building2, + owd: ShieldCheck, + diagnostics: Activity, + environment: KeyRound, + allTypes: AppWindow, +}; + +function studioMenuEntryIcon(entry: StudioMenuEntry, group: StudioMenuGroup | null): LucideIcon { + if (entry.kind !== 'type') return STUDIO_MENU_KIND_ICONS[entry.kind]; + return STUDIO_MENU_TYPE_ICONS[entry.type ?? ''] ?? (group ? STUDIO_MENU_GROUP_ICONS[group] : LayoutGrid); +} /** - * objectui#12795 — every `SidebarGroupLabel` call site hides its label from - * focus and the accessibility tree in the icon sidebar (the primitive's own - * `opacity-0` leaves it reachable). This menu is `offcanvas`, never `icon`, so - * the classes never apply here; it carries them as every call site does. + * One group of the menu: the app menu's collapsible group, open until the + * author closes it, and open whatever its state while a search lists matches. */ -const HIDDEN_ICON_LABEL_NOT_FOCUSABLE = - 'group-data-[state=collapsed]:group-data-[collapsible=icon]:invisible ' + - 'group-data-[state=collapsed]:group-data-[collapsible=icon]:transition-[margin,opacity,visibility]'; +function StudioMenuGroupSection({ + label, + labelId, + searching, + testId, + children, +}: { + label: string; + labelId: string; + searching: boolean; + testId: string; + children: React.ReactNode; +}): React.ReactElement { + const [open, setOpen] = React.useState(true); + return ( + + {children} + + ); +} /** @@ -230,12 +354,13 @@ function StudioMenuBody({ writeAdvancedCookie(next); }; - const renderEntry = (entry: StudioMenuEntry) => { + const renderEntry = (entry: StudioMenuEntry, group: StudioMenuGroup | null) => { const label = labelOf(entry); const isCurrent = entry.key === current; + const Icon = studioMenuEntryIcon(entry, group); return ( - + +