From 1b61639e2cd6ea29313c76945fb27979aae72dde Mon Sep 17 00:00:00 2001 From: d-oit <6849456+d-oit@users.noreply.github.com> Date: Tue, 6 Oct 2026 00:11:17 +0000 Subject: [PATCH] refactor(ui): tokenize z-scale, geometry & grapheme truncation - Tokenize z-scale in globals.css @theme block (--z-index-1, --z-index-toast, --z-index-shortcuts, --z-index-overlay, --z-index-skiplink) and replace arbitrary z-[NNN] utilities - Extract COMMAND_PALETTE_WIDTH_CLASS, COMMAND_PALETTE_TOP_MARGIN_CLASS, and SIDEBAR_WIDTH_CLASS geometry constants - Derive circular graph layout dynamically from canvas dimensions via computeCircularLayout in graph-layout.ts - Implement grapheme-safe truncateGraphemes with Intl.Segmenter in src/lib/text.ts and export GRAPH_LABEL_MAX (24) and TRIZ_LABEL_MAX (12) constants --- src/app/globals.css | 13 ++++++ src/components/studio/app-shell.tsx | 2 +- src/components/studio/command-palette.tsx | 19 +++++++- src/components/studio/shortcuts-dialog.tsx | 2 +- src/components/studio/sidebar.tsx | 10 ++++- src/components/studio/ui/overlay.tsx | 2 +- src/components/studio/views/graph-view.tsx | 16 +++---- .../studio/views/triz-matrix-view.tsx | 6 ++- src/components/ui/navigation-menu.tsx | 2 +- src/components/ui/toast.tsx | 2 +- src/lib/studio/graph-layout.test.ts | 36 ++++++++++++++++ src/lib/studio/graph-layout.ts | 20 +++++++++ src/lib/text.test.ts | 36 ++++++++++++++++ src/lib/text.ts | 43 +++++++++++++++++++ 14 files changed, 193 insertions(+), 16 deletions(-) create mode 100644 src/lib/text.test.ts create mode 100644 src/lib/text.ts diff --git a/src/app/globals.css b/src/app/globals.css index 13e0171b2..8caea27a4 100755 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -13,6 +13,19 @@ --breakpoint-sm: 40rem; --breakpoint-lg: 64rem; --breakpoint-wide: 68.75rem; + + /* Z-index scale tokens: + z-1 - Navigation menu indicator (z-1) + z-toast - Toast notifications viewport (z-100) + z-shortcuts - Keyboard shortcut indicator pill (z-700) + z-overlay - Modal dialogs, command palette & backdrop overlays (z-800) + z-skiplink - Skip to main content focus link (z-1000) + */ + --z-index-1: 1; + --z-index-toast: 100; + --z-index-shortcuts: 700; + --z-index-overlay: 800; + --z-index-skiplink: 1000; } /* ========================================================= diff --git a/src/components/studio/app-shell.tsx b/src/components/studio/app-shell.tsx index 5b24c0909..d37a517ef 100644 --- a/src/components/studio/app-shell.tsx +++ b/src/components/studio/app-shell.tsx @@ -260,7 +260,7 @@ export const AppShell = () => { > Skip to main content diff --git a/src/components/studio/command-palette.tsx b/src/components/studio/command-palette.tsx index 4e793f08e..d0c39b231 100644 --- a/src/components/studio/command-palette.tsx +++ b/src/components/studio/command-palette.tsx @@ -20,6 +20,13 @@ import { Overlay } from '@/components/studio/ui/shared-primitives' import type { ViewId } from '@/lib/studio/types' import { getEntityTypeMeta } from '@/lib/studio/entity-types' import { translate } from '@/lib/i18n/messages/palette' +import { cn } from '@/lib/utils' + +/** Standard top margin class for the command palette overlay dialog. */ +export const COMMAND_PALETTE_TOP_MARGIN_CLASS = 'mt-[12vh]' + +/** Standard width class for the command palette overlay dialog. */ +export const COMMAND_PALETTE_WIDTH_CLASS = 'w-[640px]' interface CmdItem { id: string @@ -130,7 +137,17 @@ export const CommandPalette = ({ onEntitySelect }: CommandPaletteProps) => { if (!commandOpen) return null return ( - + { exit={{ opacity: 0, y: 8 }} transition={reducedMotion ? { duration: 0 } : { duration: 0.15 }} className={cn( - 'fixed bottom-4 left-4 z-[700] flex items-center gap-2 rounded-full border border-saffron/40 bg-popover px-3 py-1.5 shadow-lifted', + 'fixed bottom-4 left-4 z-shortcuts flex items-center gap-2 rounded-full border border-saffron/40 bg-popover px-3 py-1.5 shadow-lifted', )} aria-live="polite" > diff --git a/src/components/studio/sidebar.tsx b/src/components/studio/sidebar.tsx index ad26b1216..aebf0e33e 100644 --- a/src/components/studio/sidebar.tsx +++ b/src/components/studio/sidebar.tsx @@ -176,6 +176,9 @@ const SidebarNav = () => { ) } +/** Sidebar width geometry constant. */ +export const SIDEBAR_WIDTH_CLASS = 'w-[248px]' + /** Sidebar with brand, search trigger, navigation, and footer controls. */ export const Sidebar = () => { const isMacPlatform = useIsMacPlatform() @@ -185,7 +188,12 @@ export const Sidebar = () => { const { theme, setTheme } = useTheme() return ( -