diff --git a/frontend/scripts/test-i18n.mjs b/frontend/scripts/test-i18n.mjs index fea549e..953d47d 100644 --- a/frontend/scripts/test-i18n.mjs +++ b/frontend/scripts/test-i18n.mjs @@ -138,17 +138,30 @@ test('Static Guard (CRITICAL-2): every stack-*, notice-*, error-boundary*, and t }) test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never replay on close', () => { - const css = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') + const rawCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') + const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, '') const titleMenus = fs.readFileSync(path.join(srcDir, 'components', 'TitleMenus.tsx'), 'utf8') - // Unconditional `.menu { ... animation: ... }` causes Radix Presence to detect an - // animationName change (`none` -> `menu-in`) when `data-menubar-switch` is removed on close, - // suspending unmount and flashing the previous menu for 160ms. - assert.doesNotMatch( - css, - /\.menu\s*\{[^}]*animation\s*:/, - 'Enter animation on .menu must be scoped to .menu[data-state="open"]', - ) + // Unconditional `.menu` / `.tooltip` animation (including animation-name inside + // comma-separated selector lists or reduced-motion media queries) causes Radix + // Presence to detect an animationName change on close and flash for 160ms. + for (const m of css.matchAll(/([^{}@]+)\{([^{}]+)\}/g)) { + const selectors = m[1].split(',').map((s) => s.trim()).filter(Boolean) + const decls = m[2] + if (!/\banimation(?:-name)?\s*:(?!\s*none\b)/.test(decls)) continue + for (const sel of selectors) { + assert.doesNotMatch( + sel, + /\.menu(?![a-zA-Z0-9_-])(?!\[data-state="open"\])/, + `Non-open .menu selector "${sel}" must not apply an active animation`, + ) + assert.doesNotMatch( + sel, + /\.tooltip(?![a-zA-Z0-9_-])(?!\[data-state="delayed-open"\])/, + `Non-delayed-open .tooltip selector "${sel}" must not apply an active animation`, + ) + } + } assert.match( css, /\.menu\[data-state="open"\]\s*\{[^}]*animation\s*:/, @@ -156,19 +169,24 @@ test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never ) assert.match( css, - /\.menu\[data-state="closed"\]\s*\{[^}]*animation\s*:\s*none/, - '.menu[data-state="closed"] must explicitly disable animation so Radix Presence unmounts immediately', - ) - assert.doesNotMatch( - css, - /\.tooltip\s*\{[^}]*animation\s*:/, - 'Enter animation on .tooltip must be scoped to .tooltip[data-state="delayed-open"]', + /\.menu\[data-state="open"\]\[data-menubar-switch="true"\][^\{]*\{[^}]*animation\s*:\s*none/, + '.menu[data-state="open"][data-menubar-switch="true"] must disable enter animation', ) assert.match( css, - /\.tooltip\[data-state="closed"\]\s*\{[^}]*animation\s*:\s*none/, + /\.menu\[data-state="closed"\][^\{]*\{[^}]*animation\s*:\s*none/, + '.menu[data-state="closed"] must explicitly disable animation so Radix Presence unmounts immediately', + ) + assert.match( + css, + /\.tooltip\[data-state="closed"\][^\{]*\{[^}]*animation\s*:\s*none/, '.tooltip[data-state="closed"] must explicitly disable animation', ) + assert.match( + css, + /@media\s*\(\s*prefers-reduced-motion\s*:\s*reduce\s*\)\s*\{[\s\S]*?\.toast\[data-state="closed"\][^{]*\{[^}]*animation-name\s*:\s*fade-out/, + 'Reduced-motion .toast[data-state="closed"] must use fade-out', + ) assert.doesNotMatch( titleMenus, /data-menubar-switch=\{\s*menuState\.id\s*===\s*id\s*&&\s*menuState\.switched/, @@ -176,6 +194,29 @@ test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never ) }) +test('Static Guard (CRITICAL-4): software-composited UI avoids backdrop-filter and slow pre shaping', () => { + const rawCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') + const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, '') + + // main.go sets WebviewGpuIsDisabled: true (software compositing), where + // backdrop-filter blurs stall CPU rasterization on animations and scrolling. + assert.doesNotMatch( + css, + /(?:-webkit-)?backdrop-filter\s*:/i, + 'app.css must not apply backdrop-filter under software compositing', + ) + assert.match( + css, + /\.license-pre\s*\{[^}]*contain\s*:\s*content/, + '.license-pre should isolate scroll/layout repaints with contain: content', + ) + assert.match( + css, + /\.license-pre\s*\{[^}]*text-rendering\s*:\s*auto/, + '.license-pre should opt out of global optimizeLegibility for long monospace texts', + ) +}) + test('Runtime i18n v2: ICU formatting, ghost-locale isolation (H-3), parseAppError (HIGH-2), RTL (L-2), and en-XA', async () => { const mod = await loadBundledTS(` import './i18n/domains/wizard.gen' diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 8368fac..2709c1e 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1069,7 +1069,12 @@ export const App: React.FC = () => { selected={selected} hostReady={hostReady} canSuspend={canSuspend} - onSelect={setSelected} + onSelect={(id) => { + setSelected(id) + if (sidebarOpen && window.matchMedia('(max-width: 768px)').matches) { + toggleSidebar() + } + }} displayNames={displayNames} macosMajors={macosMajors} onActivate={primaryAction} diff --git a/frontend/src/components/AboutPage.tsx b/frontend/src/components/AboutPage.tsx index 3f06d55..2b919ee 100644 --- a/frontend/src/components/AboutPage.tsx +++ b/frontend/src/components/AboutPage.tsx @@ -1,5 +1,5 @@ import { Copy, Download, ExternalLink, RotateCw, Scale } from 'lucide-react' -import React, { useEffect, useState } from 'react' +import React, { useEffect, useRef, useState } from 'react' import '../i18n/domains/settings.gen' import { I18nKey, t } from '../i18n' import { taskDetail } from '../lib/tasks' @@ -50,14 +50,34 @@ export const AboutPage: React.FC = ({ const [licenseOpen, setLicenseOpen] = useState(false) const [licenseTab, setLicenseTab] = useState<'notice' | 'license'>('notice') const [licenses, setLicenses] = useState<{ license: string; notice: string } | null>(null) + const mountedRef = useRef(true) + const loadingLicensesRef = useRef(false) + const licensePreRef = useRef(null) - const openLicenses = () => { - setLicenseOpen(true) - if (!licenses) { - api.GetLicenseTexts() - .then((res) => setLicenses({ license: res?.license ?? '', notice: res?.notice ?? '' })) - .catch((e) => onError(tr('failGeneric'), e)) + const openLicenses = async () => { + if (licenses) { + setLicenseOpen(true) + return } + if (loadingLicensesRef.current) return + loadingLicensesRef.current = true + try { + // Load embedded license text before mounting the modal so the dialog opens + // with its final content on frame 1 instead of reflowing mid-animation. + const res = await api.GetLicenseTexts() + if (!mountedRef.current) return + setLicenses({ license: res?.license ?? '', notice: res?.notice ?? '' }) + setLicenseOpen(true) + } catch (e) { + if (mountedRef.current) onError(tr('failGeneric'), e) + } finally { + loadingLicensesRef.current = false + } + } + + const handleLicenseTabChange = (next: 'notice' | 'license') => { + setLicenseTab(next) + if (licensePreRef.current) licensePreRef.current.scrollTop = 0 } const runUpdateCheck = async (force: boolean) => { @@ -73,12 +93,16 @@ export const AboutPage: React.FC = ({ } useEffect(() => { + mountedRef.current = true if (!appUpdate) void runUpdateCheck(false) let cancelled = false api.CanOpenQQGroup() .then((ok) => { if (!cancelled) setQQInstalled(!!ok) }) .catch(() => { if (!cancelled) setQQInstalled(false) }) - return () => { cancelled = true } + return () => { + mountedRef.current = false + cancelled = true + } }, []) const openURL = (url: string) => { @@ -245,7 +269,7 @@ export const AboutPage: React.FC = ({
{tr('aboutLicensesSub')}
-
diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index 87d25c1..3bcaae5 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx @@ -1,7 +1,7 @@ import * as Ctx from '@radix-ui/react-context-menu' import { AppWindow, Camera, CopyPlus, Cpu, Download, FolderOpen, Info, Maximize2, Pause, Play, Plus, Power, Puzzle, RotateCw, Settings, Square, Trash } from 'lucide-react' import React, { useRef } from 'react' -import { I18nKey, t } from '../i18n' +import { I18nKey, localeDir, t } from '../i18n' import { Locale, VMListItem } from '../types' import { vmRefKey } from '../lib/vmRef' import { IconButton, StatusShape, Tip, statusKind } from '../ui/controls' @@ -137,7 +137,7 @@ export const Sidebar: React.FC = ({ ) if (!onVMContextAction) return trigger return ( - + { diff --git a/frontend/src/components/TitleMenus.tsx b/frontend/src/components/TitleMenus.tsx index a53f02a..cc5165c 100644 --- a/frontend/src/components/TitleMenus.tsx +++ b/frontend/src/components/TitleMenus.tsx @@ -1,7 +1,7 @@ import * as Menu from '@radix-ui/react-dropdown-menu' import { Check, PanelLeft } from 'lucide-react' import React, { useRef, useState } from 'react' -import { I18nKey, t } from '../i18n' +import { I18nKey, localeDir, t } from '../i18n' import { useVMStats } from '../lib/vmStats' import { Locale } from '../types' import { Tip } from '../ui/controls' @@ -90,6 +90,7 @@ export const TitleMenus: React.FC = ({ // `indented`: the menu has check marks, so every row shares their indent. const menu = (id: MenuId, label: string, content: React.ReactNode, indented = false) => ( { @@ -159,9 +160,10 @@ export const TitleMenus: React.FC = ({ pointerClosedRef.current = false }} onPointerDownOutside={(e) => { + const orig = e.detail.originalEvent const target = e.target instanceof Element ? e.target : (e.target as Node | null)?.parentElement ?? null const trigger = target?.closest('button.titlebar-menu') ?? null - if (trigger && navRef.current?.contains(trigger)) { + if (orig.button === 0 && !orig.ctrlKey && trigger && navRef.current?.contains(trigger)) { e.preventDefault() return } diff --git a/frontend/src/components/VMPage.tsx b/frontend/src/components/VMPage.tsx index d01f93e..c397152 100644 --- a/frontend/src/components/VMPage.tsx +++ b/frontend/src/components/VMPage.tsx @@ -42,7 +42,7 @@ import { UserRound, } from 'lucide-react' import React, { useEffect, useId, useRef, useState } from 'react' -import { I18nKey, locText, t } from '../i18n' +import { I18nKey, localeDir, locText, t } from '../i18n' import { controllerLabel, formatBytes, formatDiskUsage, formatMemory, formatUptime, graphicsLabel, parseMemoryGB, pendingChangeText, resolveGuestLang, sshCommand, @@ -389,6 +389,7 @@ export const VMPage: React.FC = ({ // "More" menu, grouped by purpose; destructive items last (docs/design-guidelines.md §5.2). const menu = ( { if (o) morePointerClosed.current = false @@ -980,6 +981,7 @@ export const VMPage: React.FC = ({ {tr('sshOpenTerminal')} { if (o) sshPointerClosed.current = false diff --git a/frontend/src/styles/app.css b/frontend/src/styles/app.css index 4c96f69..5bc1d2f 100644 --- a/frontend/src/styles/app.css +++ b/frontend/src/styles/app.css @@ -82,15 +82,15 @@ h1, h2, h3, p { margin: 0; } /* Left of the title bar: sidebar toggle + a small menu bar. Controls and the menu bar group opt out of window dragging so sweeping across menus stays smooth. */ -.titlebar-left { display: flex; align-items: center; gap: 2px; height: 100%; margin-left: calc(var(--sp-2) * -1); } +.titlebar-left { display: flex; align-items: center; gap: 2px; height: 100%; min-width: 0; margin-inline-start: calc(var(--sp-2) * -1); } .titlebar-icon, .titlebar-menu { --wails-draggable: no-drag; height: 28px; border: none; border-radius: var(--r-sm); background: transparent; color: var(--text-2); cursor: pointer; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-press) var(--ease-out); } -.titlebar-icon { width: 32px; display: grid; place-items: center; margin-right: 4px; } -.titlebar-menu { padding: 0 10px; font-size: var(--fs-13); font-weight: var(--fw-medium); } +.titlebar-icon { width: 32px; display: grid; place-items: center; margin-inline-end: 4px; flex-shrink: 0; } +.titlebar-menu { padding: 0 10px; font-size: var(--fs-13); font-weight: var(--fw-medium); white-space: nowrap; flex-shrink: 0; } .titlebar-icon:hover, .titlebar-menu:hover { background: var(--surface-hover); color: var(--text); } .titlebar-menu[data-state="open"] { background: var(--surface-active); color: var(--text); } .titlebar-icon:active, .titlebar-menu:active { transform: scale(0.96); } @@ -100,7 +100,7 @@ h1, h2, h3, p { margin: 0; } /* Menu rows with a trailing shortcut, check marks and group labels. */ .menu-label { flex: 1; min-width: 0; white-space: nowrap; } .menu-shortcut { - margin-left: 24px; font-family: var(--font-sans); font-size: var(--fs-12); + margin-inline-start: 24px; font-family: var(--font-sans); font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; } .menu-item[data-highlighted] .menu-shortcut { color: rgba(255, 255, 255, 0.78); } @@ -109,7 +109,7 @@ h1, h2, h3, p { margin: 0; } .menu-check { position: absolute; inset-inline-start: 9px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; } .menu-group-label { padding: 6px 10px 2px; font-size: 11.5px; font-weight: var(--fw-medium); color: var(--text-3); user-select: none; } .theme-toggle { - width: 30px; height: 28px; margin-right: var(--sp-1); + width: 30px; height: 28px; margin-inline-end: var(--sp-1); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-1); color: var(--text-2); display: grid; place-items: center; cursor: pointer; @@ -138,11 +138,16 @@ h1, h2, h3, p { margin: 0; } display: flex; overflow: hidden; background: var(--surface-sidebar-rail); border-inline-end: 1px solid var(--border); - transition: width var(--dur-modal) var(--ease-out), padding var(--dur-modal) var(--ease-out), opacity var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out); + transition: width var(--dur-modal) var(--ease-out), padding var(--dur-modal) var(--ease-out), opacity var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), visibility 0s linear 0s; } /* Hidden sidebar (Ctrl+B): slides shut; the card keeps its width so its - contents don't reflow while the rail narrows. */ -.workspace.sidebar-hidden .sidebar-wrap { width: 0; padding-inline: 0; opacity: 0; border-inline-end-color: transparent; } + contents don't reflow while the rail narrows, and visibility: hidden removes + off-screen buttons from the keyboard Tab order. */ +.workspace.sidebar-hidden .sidebar-wrap { + width: 0; padding-inline: 0; opacity: 0; border-inline-end-color: transparent; + visibility: hidden; pointer-events: none; + transition: width var(--dur-modal) var(--ease-out), padding var(--dur-modal) var(--ease-out), opacity var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), visibility 0s linear var(--dur-modal); +} .sidebar-wrap > .sidebar { min-width: calc(var(--sidebar-w) - 20px); } .sidebar { flex: 1; min-height: 0; @@ -716,11 +721,14 @@ h1, h2, h3, p { margin: 0; } .about-hero-text h1 { font-size: 22px; font-weight: var(--fw-strong); letter-spacing: -0.02em; color: var(--text); } .about-hero-text p { margin: 0; font-size: var(--fs-13); color: var(--text-2); line-height: 1.5; } .license-modal-body { gap: var(--sp-3); } +.license-modal-body > .seg { align-self: flex-start; flex-shrink: 0; } .license-pre { - margin: 0; padding: 14px 16px; min-height: 260px; max-height: 52vh; overflow: auto; + margin: 0; padding: 14px 16px; flex: 0 1 auto; height: min(440px, 50vh); min-height: 120px; overflow: auto; + overscroll-behavior: contain; contain: content; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-1); font-family: var(--font-mono); font-size: var(--fs-12); line-height: 1.55; color: var(--text-2); white-space: pre-wrap; word-break: break-word; user-select: text; + text-rendering: auto; text-autospace: no-autospace; } .section-count { min-width: 20px; padding: 1px 7px; border-radius: 999px; background: var(--surface-active); color: var(--text-3); font-size: 11px; font-weight: var(--fw-medium); text-align: center; } .installer-row { min-height: 62px; } @@ -886,6 +894,7 @@ button.status-issue + .status-metric { margin-left: 6px; } overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-2) var(--sp-4); font-family: var(--font-mono); font-size: var(--fs-12); line-height: 1.6; color: var(--text-code); white-space: pre-wrap; word-break: break-word; user-select: text; + text-rendering: auto; text-autospace: no-autospace; } .log-line { display: flex; gap: var(--sp-3); } .log-ts { color: var(--text-3); flex-shrink: 0; font-variant-numeric: tabular-nums; } @@ -895,27 +904,30 @@ button.status-issue + .status-metric { margin-left: 6px; } .jump-latest { position: absolute; inset-inline-end: var(--sp-4); bottom: var(--sp-3); } /* ── Overlays: dialog, menu, tooltip, toast ────────────── */ -.overlay { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(5px); z-index: 40; } +/* No backdrop-filter: main.go sets WebviewGpuIsDisabled: true (software + compositing), where per-frame CPU Gaussian blur over modals/overlays stutters + badly during enter animations and inner scrolling. */ +.overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 40; } .dialog { position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 720px; max-width: calc(100vw - 48px); max-height: calc(100vh - 80px); display: flex; flex-direction: column; overflow: hidden; - background: var(--surface-2); backdrop-filter: var(--blur-overlay); + background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-overlay), var(--highlight-top); } .dialog.sm { width: 420px; } -.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 14px 14px 14px 22px; border-bottom: 1px solid var(--border); } +.dialog-head { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding-block: 14px; padding-inline: 22px 14px; border-bottom: 1px solid var(--border); } .dialog-title { font-size: var(--fs-16); font-weight: var(--fw-strong); letter-spacing: -0.01em; text-wrap: balance; } .dialog-desc { font-size: var(--fs-13); color: var(--text-2); margin-top: 2px; } .dialog-body { padding: 20px 22px; overflow-y: auto; overscroll-behavior: contain; flex: 1; display: flex; flex-direction: column; gap: var(--sp-4); } -.dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 12px 22px; border-top: 1px solid var(--border); } +.dialog-foot { flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 12px 22px; border-top: 1px solid var(--border); } .dialog.sm .dialog-body { padding: 22px 22px 14px; gap: var(--sp-3); } .dialog.sm .dialog-foot { border-top: none; justify-content: flex-end; padding-top: 0; padding-bottom: 20px; } .menu { min-width: 188px; padding: 5px; z-index: 50; - background: var(--surface-2); backdrop-filter: var(--blur-overlay); + background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-overlay), var(--highlight-top); } @@ -936,7 +948,7 @@ button.status-issue + .status-metric { margin-left: 6px; } .tooltip { z-index: 60; padding: 5px 9px; border-radius: var(--r-sm); - background: var(--surface-2); backdrop-filter: var(--blur-overlay); + background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); font-size: var(--fs-12); box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16); display: flex; gap: var(--sp-2); align-items: center; @@ -947,7 +959,7 @@ button.status-issue + .status-metric { margin-left: 6px; } .toast-viewport { position: fixed; inset-inline-end: var(--sp-4); bottom: calc(var(--logbar-h) + var(--sp-4)); z-index: 70; display: flex; flex-direction: column; gap: var(--sp-2); width: 380px; max-width: calc(100vw - 32px); margin: 0; padding: 0; list-style: none; outline: none; } .toast { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); - background: var(--surface-2); backdrop-filter: var(--blur-overlay); + background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-overlay), var(--highlight-top); } @@ -968,7 +980,7 @@ button.status-issue + .status-metric { margin-left: 6px; } .toast-title { font-size: var(--fs-13); font-weight: var(--fw-strong); } .toast-code { font-family: var(--font-mono); font-size: var(--fs-11); padding: 1px 5px; - border-radius: 4px; background: var(--surface-active); color: var(--text-3); + border-radius: 4px; background: var(--surface-active); color: var(--text-2); } .toast-desc { font-size: var(--fs-12); color: var(--text-2); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; } .toast-footer { display: flex; flex-direction: column; gap: var(--sp-2); padding-inline-start: 28px; width: 100%; min-width: 0; } @@ -1397,7 +1409,7 @@ button.status-issue + .status-metric { margin-left: 6px; } width: max-content; max-width: calc(100% - 20px); padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 26px; border-radius: 999px; pointer-events: none; - background: rgba(20, 21, 26, 0.72); color: #fff; backdrop-filter: blur(10px); + background: rgba(20, 21, 26, 0.84); color: #fff; font-size: var(--fs-12); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transform: translateX(-50%) translateY(4px); @@ -1497,14 +1509,16 @@ button.status-issue + .status-metric { margin-left: 6px; } /* Reduced motion: stop decorative loops & positional motion */ @media (prefers-reduced-motion: reduce) { - .status-busy, .vm-screen-live, .skeleton-bar { animation: none; } + .status-busy, .vm-screen-live, .skeleton-bar, .market-progress.is-indeterminate .market-progress-fill { animation: none; } .vm-display-unit, .vm-display-unit.is-actionable:hover, .vm-display-unit.is-actionable:active { transform: none; } .vm-screen-img, .vm-spec-meter .meter-fill { transition: none; } .page, .dialog, .menu[data-state="open"]:not([data-menubar-switch="true"]), .tooltip[data-state="delayed-open"], .pane-anim, .step-anim, .toast[data-state="open"] { animation-name: fade-in; animation-duration: 140ms; } - .toast[data-state="closed"] { + .toast[data-state="closed"], + .toast[data-swipe="end"], + :root[dir="rtl"] .toast[data-swipe="end"] { animation-name: fade-out; animation-duration: 140ms; } @@ -1516,14 +1530,13 @@ button.status-issue + .status-metric { margin-left: 6px; } position: absolute; right: 8px; bottom: 8px; z-index: 3; width: 30px; height: 30px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 8px; display: grid; place-items: center; cursor: pointer; - background: rgba(20, 22, 28, 0.68); color: #ffffff; - backdrop-filter: blur(10px); + background: rgba(20, 22, 28, 0.82); color: #ffffff; opacity: 0; transform: translateY(3px); transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); } .vm-screen:hover .vm-screen-shot, .vm-screen-shot:focus-visible { opacity: 1; transform: translateY(0); } -.vm-screen-shot:hover { background: rgba(20, 22, 28, 0.88); } +.vm-screen-shot:hover { background: rgba(20, 22, 28, 0.94); } .vm-screen-shot:active { transform: scale(0.94); } /* The title is the display name; click to rename in place. The pencil hangs @@ -1577,9 +1590,8 @@ button.status-issue + .status-metric { margin-left: 6px; } position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px; border-radius: var(--r-lg); - background: var(--accent-soft); border: 1.5px dashed var(--accent); + background: color-mix(in srgb, var(--surface-canvas) 89%, var(--accent)); border: 1.5px dashed var(--accent); color: var(--accent-soft-text); font-size: var(--fs-13); font-weight: var(--fw-medium); - backdrop-filter: var(--blur-overlay); } /* Interactive install stepper */ @@ -1847,7 +1859,7 @@ button.status-issue + .status-metric { margin-left: 6px; } } .plugin-risk.is-high .plugin-risk-icon { background: var(--warn-soft); color: var(--warn-text); } .plugin-scan-section { display: flex; flex-direction: column; gap: 6px; } -.plugin-scan-section-title { font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-2); } +.plugin-scan-section-title { font-size: var(--fs-12); font-weight: var(--fw-strong); color: var(--text-2); } .plugin-scan-section-title.is-danger { color: var(--danger-text); } .plugin-scan-examples { margin-top: 4px; font-size: var(--fs-11); color: var(--text-2); display: flex; flex-direction: column; gap: 2px; } @@ -1913,6 +1925,7 @@ button.status-issue + .status-metric { margin-left: 6px; } max-height: 180px; overflow: auto; background: var(--surface-0); border: 1px solid var(--border); white-space: pre-wrap; word-break: break-word; + text-rendering: auto; text-autospace: no-autospace; } .error-boundary-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; } @@ -1927,7 +1940,7 @@ button.status-issue + .status-metric { margin-left: 6px; } .sidebar-backdrop { display: block; position: absolute; inset: 0; - background: var(--scrim); backdrop-filter: blur(3px); z-index: 31; + background: var(--scrim); z-index: 31; } .sidebar-wrap { position: absolute; z-index: 32; @@ -1949,18 +1962,22 @@ button.status-issue + .status-metric { margin-left: 6px; } .settings-pane { padding: 16px; } } +@container (max-width: 520px) { + .row, .srow-head { flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); } + .row-main, .srow-text { flex: 1 1 220px; } + .row-right, .srow-ctrl { flex-wrap: wrap; max-width: 100%; min-width: 0; } +} + @media (max-width: 640px) { .source-cards, .field-row, .review-groups { grid-template-columns: 1fr; } .review-group:last-child .review-rows { grid-template-columns: max-content 1fr; } .vm-spec-card { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 14px; } .affinity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .conn-row, .srow-head, .row, .page-head { flex-wrap: wrap; } - .conn-ctrl { flex-wrap: wrap; max-width: 100%; } + .conn-row, .srow-head, .row, .page-head { flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); } + .row-main, .srow-text { flex: 1 1 220px; } + .conn-ctrl, .row-right, .srow-ctrl { flex-wrap: wrap; max-width: 100%; min-width: 0; } .plugins-search { width: 100%; } } -@container (max-width: 560px) { - .review-group:last-child .review-rows { grid-template-columns: max-content 1fr; } -} } diff --git a/frontend/src/styles/tokens.css b/frontend/src/styles/tokens.css index 7d588e2..b821444 100644 --- a/frontend/src/styles/tokens.css +++ b/frontend/src/styles/tokens.css @@ -90,17 +90,19 @@ --surface-statusbar: #eef3fa; --surface-1: #f5f6f8; --surface-card-elevated: #ffffff; - --surface-2: rgba(255, 255, 255, 0.94); + --surface-2: rgba(255, 255, 255, 0.98); --surface-input: #ffffff; --surface-hover: rgba(15, 23, 42, 0.048); --surface-active: rgba(15, 23, 42, 0.085); --border: rgba(15, 23, 42, 0.08); --border-strong: rgba(15, 23, 42, 0.14); --highlight-top: inset 0 1px 0 rgba(255, 255, 255, 0.85); - --scrim: rgba(15, 23, 42, 0.28); + --scrim: rgba(15, 23, 42, 0.34); --shadow-btn: 0 1px 2px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.7); --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.025); - --shadow-overlay: 0 22px 58px rgba(15, 23, 42, 0.18), 0 4px 14px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.06); + --shadow-overlay: 0 16px 36px rgba(15, 23, 42, 0.16), 0 3px 10px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.06); + /* Retained for UI Contract v1 (uiApi 1.0.0) theme compatibility; unused by default + base styles while main.go runs WebView2 in software compositing mode. */ --blur-chrome: blur(20px) saturate(180%); --blur-overlay: blur(18px) saturate(165%); @@ -167,17 +169,17 @@ --surface-statusbar: #18191e; --surface-1: rgba(255, 255, 255, 0.048); --surface-card-elevated: rgba(255, 255, 255, 0.075); - --surface-2: rgba(42, 43, 50, 0.94); + --surface-2: rgba(42, 43, 50, 0.98); --surface-input: rgba(0, 0, 0, 0.28); --surface-hover: rgba(255, 255, 255, 0.075); --surface-active: rgba(255, 255, 255, 0.12); --border: rgba(255, 255, 255, 0.085); --border-strong: rgba(255, 255, 255, 0.16); --highlight-top: inset 0 1px 0 rgba(255, 255, 255, 0.08); - --scrim: rgba(0, 0, 0, 0.56); + --scrim: rgba(0, 0, 0, 0.58); --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.06); --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.18); - --shadow-overlay: 0 26px 68px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 255, 255, 0.09); + --shadow-overlay: 0 18px 40px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(255, 255, 255, 0.09); --text: #f5f5f7; --text-2: #c2c2ca; diff --git a/frontend/src/ui/dialog.tsx b/frontend/src/ui/dialog.tsx index 16ddcdc..d8b6101 100644 --- a/frontend/src/ui/dialog.tsx +++ b/frontend/src/ui/dialog.tsx @@ -14,30 +14,44 @@ interface ConfirmDialogProps { children?: React.ReactNode } -export const ConfirmDialog: React.FC = ({ title, description, cancelLabel, confirmLabel, onCancel, onConfirm, children }) => ( - { if (!open) onCancel() }}> - - - -
- {title} - {description} - {children} -
-
- - -
-
-
-
-) +export const ConfirmDialog: React.FC = ({ title, description, cancelLabel, confirmLabel, onCancel, onConfirm, children }) => { + const prevFocusRef = React.useRef( + typeof document !== 'undefined' && document.activeElement instanceof HTMLElement + ? document.activeElement + : null, + ) + return ( + { if (!open) onCancel() }}> + + + { + e.preventDefault() + const prev = prevFocusRef.current + if (prev?.isConnected) prev.focus({ preventScroll: true }) + }} + > +
+ {title} + {description} + {children} +
+
+ + +
+
+
+
+ ) +} interface Props { title: string subtitle?: string closeLabel: string - /** While false, Esc / outside click / ✕ are ignored (e.g. during a create). */ + /** While false, Esc / ✕ are ignored (e.g. during a create). */ dismissable?: boolean onClose: () => void /** Extra class on the dialog box, e.g. a wider variant. */ @@ -46,41 +60,53 @@ interface Props { } /** Modal frame: head with title and ✕; children supply body/steps/foot sections. */ -export const Modal: React.FC = ({ title, subtitle, closeLabel, dismissable = true, onClose, className, children }) => ( - { if (!open && dismissable) onClose() }}> - - - e.preventDefault()} - // Focus the first enabled form field, or the dialog container itself when there is - // none, so the top-right ✕ close button's tooltip never pops on open. - onOpenAutoFocus={(e) => { - const root = e.currentTarget as HTMLElement | null - if (!root) return - e.preventDefault() - const first = root.querySelector( - 'input:not(:disabled):not([type="hidden"]):not([type="radio"]:not(:checked)), select:not(:disabled), textarea:not(:disabled)', - ) - if (first) { - first.focus({ preventScroll: true }) - } - if (!root.contains(document.activeElement)) { - root.focus({ preventScroll: true }) - } - }} - > -
-
- {title} - {subtitle ? {subtitle} : } +export const Modal: React.FC = ({ title, subtitle, closeLabel, dismissable = true, onClose, className, children }) => { + const prevFocusRef = React.useRef( + typeof document !== 'undefined' && document.activeElement instanceof HTMLElement + ? document.activeElement + : null, + ) + return ( + { if (!open && dismissable) onClose() }}> + + + e.preventDefault()} + // Focus the first enabled form field, or the dialog container itself when there is + // none, so the top-right ✕ close button's tooltip never pops on open. + onOpenAutoFocus={(e) => { + const root = e.currentTarget as HTMLElement | null + if (!root) return + e.preventDefault() + const first = root.querySelector( + 'input:not(:disabled):not([type="hidden"]):not([type="radio"]:not(:checked)), select:not(:disabled), textarea:not(:disabled)', + ) + if (first) { + first.focus({ preventScroll: true }) + } + if (!root.contains(document.activeElement)) { + root.focus({ preventScroll: true }) + } + }} + onCloseAutoFocus={(e) => { + e.preventDefault() + const prev = prevFocusRef.current + if (prev?.isConnected) prev.focus({ preventScroll: true }) + }} + > +
+
+ {title} + {subtitle ? {subtitle} : } +
+ + } disabled={!dismissable} /> +
- - } disabled={!dismissable} /> - -
- {children} - - - -) + {children} + + + + ) +} diff --git a/frontend/src/ui/settings.tsx b/frontend/src/ui/settings.tsx index b487340..2e2b3b0 100644 --- a/frontend/src/ui/settings.tsx +++ b/frontend/src/ui/settings.tsx @@ -122,7 +122,10 @@ export function Segmented({ options, value, onChange, return next }) } - useLayoutEffect(measure, [value, options]) + const optionsSig = options.map((o) => `${String(o.value)}\x1f${o.label}`).join('\x1e') + const docDir = typeof document !== 'undefined' ? document.documentElement.dir : '' + // eslint-disable-next-line react-hooks/exhaustive-deps + useLayoutEffect(measure, [value, optionsSig, wide, docDir]) useEffect(() => { if (!box.current || typeof ResizeObserver === 'undefined') return let raf = 0 @@ -142,12 +145,13 @@ export function Segmented({ options, value, onChange, }, []) const onKey = (e: React.KeyboardEvent) => { - if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') return + if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft' && e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return e.preventDefault() const enabled = options.filter((o) => !o.disabled) const i = enabled.findIndex((o) => o.value === value) const isRTL = box.current ? getComputedStyle(box.current).direction === 'rtl' : false - const delta = (e.key === 'ArrowRight') !== isRTL ? 1 : -1 + const forward = e.key === 'ArrowDown' || (e.key === 'ArrowRight' && !isRTL) || (e.key === 'ArrowLeft' && isRTL) + const delta = forward ? 1 : -1 const next = enabled[(i + delta + enabled.length) % enabled.length] if (next) { onChange(next.value) @@ -384,8 +388,9 @@ export function PopupSelect({ value, options, onChange, label, id?: string }) { const cur = options.find((o) => o.value === value) + const dir: 'ltr' | 'rtl' = typeof document !== 'undefined' && document.documentElement.dir === 'rtl' ? 'rtl' : 'ltr' return ( - +