perf(ui): eliminate software-compositing modal lag and harden UI responsiveness
Remove backdrop-filter from software-composited overlays/dialogs under WebviewGpuIsDisabled: true, preload license text before mounting the modal, fix short-viewport double scrollbars and narrow-screen row wrapping, restore keyboard focus on modal close, wire RTL direction to Radix menus, add ArrowUp/ArrowDown support and signature-based layout measurement in Segmented, and harden CRITICAL-3/CRITICAL-4 static guards.
This commit is contained in:
1 parent
6fbcd6422e
commit
ee5c02f54f
10 files changed
+264
-133
No files matched your search
@@ -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'
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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<Props> = ({
|
||||
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<HTMLPreElement>(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<Props> = ({
|
||||
}
|
||||
|
||||
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<Props> = ({
|
||||
<div className="row-sub">{tr('aboutLicensesSub')}</div>
|
||||
</div>
|
||||
<div className="row-right">
|
||||
<Button icon={<Scale size={14} aria-hidden="true" />} onClick={openLicenses}>
|
||||
<Button icon={<Scale size={14} aria-hidden="true" />} onClick={() => void openLicenses()}>
|
||||
{tr('aboutLicensesView')}
|
||||
</Button>
|
||||
<Button variant="ghost" icon={<ExternalLink size={14} aria-hidden="true" />} onClick={() => openURL(`${REPO_URL}/blob/main/NOTICE.md`)}>
|
||||
@@ -323,16 +347,23 @@ export const AboutPage: React.FC<Props> = ({
|
||||
<Segmented
|
||||
label={tr('aboutLicensesTitle')}
|
||||
value={licenseTab}
|
||||
onChange={setLicenseTab}
|
||||
onChange={handleLicenseTabChange}
|
||||
options={[
|
||||
{ value: 'notice', label: tr('aboutLicensesTabNotice') },
|
||||
{ value: 'license', label: tr('aboutLicensesTabLicense') },
|
||||
]}
|
||||
/>
|
||||
<pre className="license-pre">
|
||||
<pre
|
||||
ref={licensePreRef}
|
||||
className="license-pre"
|
||||
dir="ltr"
|
||||
tabIndex={0}
|
||||
role="region"
|
||||
aria-label={licenseTab === 'notice' ? tr('aboutLicensesTabNotice') : tr('aboutLicensesTabLicense')}
|
||||
>
|
||||
{licenses
|
||||
? (licenseTab === 'notice' ? licenses.notice : licenses.license)
|
||||
: '…'}
|
||||
: ''}
|
||||
</pre>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
|
||||
@@ -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<Props> = ({
|
||||
)
|
||||
if (!onVMContextAction) return trigger
|
||||
return (
|
||||
<Ctx.Root key={vmRefKey(vm)}>
|
||||
<Ctx.Root key={vmRefKey(vm)} dir={localeDir(locale)}>
|
||||
<Ctx.Trigger
|
||||
asChild
|
||||
onContextMenu={(e) => {
|
||||
|
||||
@@ -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<Props> = ({
|
||||
// `indented`: the menu has check marks, so every row shares their indent.
|
||||
const menu = (id: MenuId, label: string, content: React.ReactNode, indented = false) => (
|
||||
<Menu.Root
|
||||
dir={localeDir(locale)}
|
||||
modal={false}
|
||||
open={menuState.id === id}
|
||||
onOpenChange={(o) => {
|
||||
@@ -159,9 +160,10 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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<Props> = ({
|
||||
// "More" menu, grouped by purpose; destructive items last (docs/design-guidelines.md §5.2).
|
||||
const menu = (
|
||||
<Menu.Root
|
||||
dir={localeDir(locale)}
|
||||
open={moreMenuOpen}
|
||||
onOpenChange={(o) => {
|
||||
if (o) morePointerClosed.current = false
|
||||
@@ -980,6 +981,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
{tr('sshOpenTerminal')}
|
||||
</Button>
|
||||
<Menu.Root
|
||||
dir={localeDir(locale)}
|
||||
open={sshMenuOpen}
|
||||
onOpenChange={(o) => {
|
||||
if (o) sshPointerClosed.current = false
|
||||
|
||||
+49
-32
@@ -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; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+82
-56
@@ -14,30 +14,44 @@ interface ConfirmDialogProps {
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({ title, description, cancelLabel, confirmLabel, onCancel, onConfirm, children }) => (
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{title}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">{description}</Alert.Description>
|
||||
{children}
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild><Button>{cancelLabel}</Button></Alert.Cancel>
|
||||
<Alert.Action asChild><Button variant="danger" onClick={onConfirm}>{confirmLabel}</Button></Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
</Alert.Portal>
|
||||
</Alert.Root>
|
||||
)
|
||||
export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({ title, description, cancelLabel, confirmLabel, onCancel, onConfirm, children }) => {
|
||||
const prevFocusRef = React.useRef<HTMLElement | null>(
|
||||
typeof document !== 'undefined' && document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: null,
|
||||
)
|
||||
return (
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content
|
||||
className="dialog sm"
|
||||
onCloseAutoFocus={(e) => {
|
||||
e.preventDefault()
|
||||
const prev = prevFocusRef.current
|
||||
if (prev?.isConnected) prev.focus({ preventScroll: true })
|
||||
}}
|
||||
>
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{title}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">{description}</Alert.Description>
|
||||
{children}
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild><Button>{cancelLabel}</Button></Alert.Cancel>
|
||||
<Alert.Action asChild><Button variant="danger" onClick={onConfirm}>{confirmLabel}</Button></Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
</Alert.Portal>
|
||||
</Alert.Root>
|
||||
)
|
||||
}
|
||||
|
||||
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<Props> = ({ title, subtitle, closeLabel, dismissable = true, onClose, className, children }) => (
|
||||
<RDialog.Root open onOpenChange={(open) => { if (!open && dismissable) onClose() }}>
|
||||
<RDialog.Portal>
|
||||
<RDialog.Overlay className="overlay" />
|
||||
<RDialog.Content
|
||||
className={className ? `dialog ${className}` : 'dialog'}
|
||||
onInteractOutside={(e) => 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<HTMLElement>(
|
||||
'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 })
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="dialog-head">
|
||||
<div>
|
||||
<RDialog.Title className="dialog-title">{title}</RDialog.Title>
|
||||
{subtitle ? <RDialog.Description className="dialog-desc">{subtitle}</RDialog.Description> : <RDialog.Description />}
|
||||
export const Modal: React.FC<Props> = ({ title, subtitle, closeLabel, dismissable = true, onClose, className, children }) => {
|
||||
const prevFocusRef = React.useRef<HTMLElement | null>(
|
||||
typeof document !== 'undefined' && document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: null,
|
||||
)
|
||||
return (
|
||||
<RDialog.Root open onOpenChange={(open) => { if (!open && dismissable) onClose() }}>
|
||||
<RDialog.Portal>
|
||||
<RDialog.Overlay className="overlay" />
|
||||
<RDialog.Content
|
||||
className={className ? `dialog ${className}` : 'dialog'}
|
||||
onInteractOutside={(e) => 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<HTMLElement>(
|
||||
'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 })
|
||||
}}
|
||||
>
|
||||
<div className="dialog-head">
|
||||
<div>
|
||||
<RDialog.Title className="dialog-title">{title}</RDialog.Title>
|
||||
{subtitle ? <RDialog.Description className="dialog-desc">{subtitle}</RDialog.Description> : <RDialog.Description />}
|
||||
</div>
|
||||
<RDialog.Close asChild>
|
||||
<IconButton label={closeLabel} icon={<X size={16} />} disabled={!dismissable} />
|
||||
</RDialog.Close>
|
||||
</div>
|
||||
<RDialog.Close asChild>
|
||||
<IconButton label={closeLabel} icon={<X size={16} />} disabled={!dismissable} />
|
||||
</RDialog.Close>
|
||||
</div>
|
||||
{children}
|
||||
</RDialog.Content>
|
||||
</RDialog.Portal>
|
||||
</RDialog.Root>
|
||||
)
|
||||
{children}
|
||||
</RDialog.Content>
|
||||
</RDialog.Portal>
|
||||
</RDialog.Root>
|
||||
)
|
||||
}
|
||||
@@ -122,7 +122,10 @@ export function Segmented<V extends string | number>({ 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<V extends string | number>({ 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<V extends string>({ 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 (
|
||||
<Menu.Root modal={false}>
|
||||
<Menu.Root dir={dir} modal={false}>
|
||||
<Menu.Trigger asChild>
|
||||
<button type="button" id={id} className={`popup-btn${wide ? ' popup-wide' : ''}`} aria-label={label}>
|
||||
<span className="popup-value">
|
||||
|
||||
Reference in new issue
Block a user