perf(webui): scope interactive motion
Replace broad transitions with property-specific animation for progress bars, filters, cards, and dashboard controls. This prevents unrelated layout properties from animating while preserving the existing visual feedback. Standardize standalone press feedback at a 0.96 scale, keep disabled controls static, and honor both operating-system and in-app reduced-motion preferences.
This commit is contained in:
11 files changed
+21
-17
No files matched your search
@@ -9,6 +9,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { QQInfo } from '@/types';
|
||||
|
||||
@@ -31,6 +32,9 @@ export function AccountSidebar({
|
||||
collapsed,
|
||||
onToggleCollapsed,
|
||||
}: AccountSidebarProps) {
|
||||
const { appearance } = useTheme();
|
||||
const reduceMotion = appearance.reduceMotion || appearance.disableMotion;
|
||||
|
||||
return (
|
||||
<motion.aside
|
||||
animate={{ width: collapsed ? 56 : 248 }}
|
||||
@@ -64,8 +68,8 @@ export function AccountSidebar({
|
||||
<motion.button
|
||||
key={q.uin}
|
||||
type="button"
|
||||
whileHover={{ scale: 1.01 }}
|
||||
whileTap={{ scale: 0.98 }}
|
||||
whileHover={reduceMotion ? undefined : { scale: 1.01 }}
|
||||
whileTap={reduceMotion ? undefined : { scale: 0.96 }}
|
||||
onClick={() => onSelect(q.uin)}
|
||||
className={cn(
|
||||
'flex items-center gap-2.5 rounded-lg border text-left transition-colors cursor-pointer',
|
||||
|
||||
@@ -58,7 +58,7 @@ export function NodeSummaryCard<T extends AdapterCommon>({
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={off ? { duration: 0 } : { duration: 0.18 }}
|
||||
className={cn(
|
||||
'flex flex-col gap-2 rounded-xl border bg-card/40 p-3.5 transition-all hover:bg-accent/20 sm:flex-row sm:items-center sm:gap-3',
|
||||
'flex flex-col gap-2 rounded-xl border bg-card/40 p-3.5 transition-[background-color,opacity] duration-150 ease-out hover:bg-accent/20 sm:flex-row sm:items-center sm:gap-3',
|
||||
!enabled && 'opacity-60',
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -283,8 +283,8 @@ export function ActionTester({ accounts, docs, presetAction }: { accounts: QQInf
|
||||
)}
|
||||
|
||||
<div className="flex gap-2">
|
||||
<button type="button" onClick={onExecute} disabled={invoking}
|
||||
className="inline-flex h-11 flex-1 items-center justify-center gap-2 rounded-xl bg-primary text-[15px] font-medium text-primary-foreground shadow-sm transition-all hover:bg-primary/90 active:scale-[0.99] disabled:opacity-50">
|
||||
<button type="button" onClick={onExecute} disabled={invoking} data-press-scale=""
|
||||
className="inline-flex h-11 flex-1 items-center justify-center gap-2 rounded-xl bg-primary text-[15px] font-medium text-primary-foreground shadow-sm transition-[background-color,opacity,scale] duration-150 ease-out hover:bg-primary/90 active:not-disabled:scale-[0.96] motion-reduce:active:scale-100 disabled:opacity-50">
|
||||
{invoking ? <Loader2 className="h-4 w-4 animate-spin" /> : isStream ? <Zap className="h-4 w-4" /> : <Play className="h-4 w-4" />}
|
||||
{invoking ? '执行中…' : isStream ? '流式执行' : '执行'}
|
||||
</button>
|
||||
|
||||
@@ -117,8 +117,8 @@ export function MessageComposer({ accounts }: { accounts: QQInfo[] }) {
|
||||
<MessageBuilder segments={segs} onChange={setSegs} uin={uin} groupId={groupId} />
|
||||
</div>
|
||||
|
||||
<button type="button" onClick={send} disabled={sending}
|
||||
className="inline-flex h-11 items-center justify-center gap-2 rounded-xl bg-primary text-[15px] font-medium text-primary-foreground shadow-sm transition-all hover:bg-primary/90 active:scale-[0.99] disabled:opacity-50">
|
||||
<button type="button" onClick={send} disabled={sending} data-press-scale=""
|
||||
className="inline-flex h-11 items-center justify-center gap-2 rounded-xl bg-primary text-[15px] font-medium text-primary-foreground shadow-sm transition-[background-color,opacity,scale] duration-150 ease-out hover:bg-primary/90 active:not-disabled:scale-[0.96] motion-reduce:active:scale-100 disabled:opacity-50">
|
||||
{sending ? <Loader2 className="h-4 w-4 animate-spin" /> : <Send className="h-4 w-4" />} 发送{hasNodes(segs) ? '(合并转发)' : ''}
|
||||
</button>
|
||||
</motion.section>
|
||||
|
||||
@@ -29,7 +29,7 @@ function Row({ task, onDismiss }: { task: DebugTask; onDismiss: () => void }) {
|
||||
{task.status === 'running' && (
|
||||
<div className="h-1 overflow-hidden rounded-full bg-muted">
|
||||
<div
|
||||
className={cn('h-full rounded-full bg-primary transition-all', pct === null && 'animate-pulse')}
|
||||
className={cn('h-full rounded-full bg-primary transition-[width] duration-300 ease-out', pct === null && 'animate-pulse')}
|
||||
style={{ width: pct === null ? '40%' : `${pct}%` }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -166,7 +166,7 @@ export function DashboardGrid({
|
||||
onClick={() => onConfigOpen(b.id)}
|
||||
title="设置"
|
||||
aria-label="设置"
|
||||
className="pointer-events-auto absolute right-1.5 top-1.5 z-20 inline-flex size-6 items-center justify-center rounded-md bg-background/70 text-muted-foreground opacity-60 backdrop-blur-sm transition-all outline-none hover:opacity-100 hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/40 cursor-pointer"
|
||||
className="pointer-events-auto absolute right-1.5 top-1.5 z-20 inline-flex size-6 items-center justify-center rounded-md bg-background/70 text-muted-foreground opacity-60 backdrop-blur-sm transition-[color,opacity,box-shadow] duration-150 ease-out outline-none hover:opacity-100 hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/40 cursor-pointer"
|
||||
>
|
||||
<Settings2 className="size-3.5" />
|
||||
</button>
|
||||
|
||||
@@ -165,7 +165,7 @@ export function LoginPage({ onLogin }: LoginPageProps) {
|
||||
type="button"
|
||||
onClick={() => setHelpOpen(true)}
|
||||
whileHover={reduce ? undefined : { scale: 1.04 }}
|
||||
whileTap={reduce ? undefined : { scale: 0.97 }}
|
||||
whileTap={reduce ? undefined : { scale: 0.96 }}
|
||||
transition={{ type: 'spring', stiffness: 420, damping: 26 }}
|
||||
className="mt-5 inline-flex items-center gap-2 rounded-full border border-border/50 bg-background/45 px-4 py-2 text-[12px] font-medium text-muted-foreground shadow-lg shadow-black/5 backdrop-blur-xl transition-colors hover:text-foreground supports-[backdrop-filter]:bg-background/35 cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40"
|
||||
>
|
||||
|
||||
@@ -442,7 +442,7 @@ export function LogsPage() {
|
||||
onClick={() => toggleLevel(lv)}
|
||||
aria-pressed={active}
|
||||
className={cn(
|
||||
'inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-all cursor-pointer',
|
||||
'inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-[background-color,color,box-shadow] duration-150 ease-out cursor-pointer',
|
||||
active
|
||||
? cn('bg-card shadow-sm ring-1 ring-border/60', levelClass[lv])
|
||||
: 'text-muted-foreground/55 hover:text-foreground',
|
||||
@@ -486,7 +486,7 @@ export function LogsPage() {
|
||||
aria-pressed={active}
|
||||
title={p.hint}
|
||||
className={cn(
|
||||
'inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-all cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40',
|
||||
'inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-[background-color,color,box-shadow] duration-150 ease-out cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40',
|
||||
active ? 'bg-card text-foreground shadow-sm ring-1 ring-border/60' : 'text-muted-foreground/70 hover:text-foreground',
|
||||
)}
|
||||
>
|
||||
@@ -522,7 +522,7 @@ export function LogsPage() {
|
||||
disabled={levelBusy || serverLevel === null}
|
||||
aria-pressed={active}
|
||||
className={cn(
|
||||
'inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-all cursor-pointer disabled:cursor-not-allowed disabled:opacity-50',
|
||||
'inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-[background-color,color,box-shadow,opacity] duration-150 ease-out cursor-pointer disabled:cursor-not-allowed disabled:opacity-50',
|
||||
active
|
||||
? cn('bg-card shadow-sm ring-1 ring-border/60', levelClass[lv])
|
||||
: 'text-muted-foreground/70 hover:text-foreground',
|
||||
|
||||
@@ -85,7 +85,7 @@ export function ProcessesPage() {
|
||||
aria-checked={active}
|
||||
onClick={() => setPages({ processesSort: o.id })}
|
||||
className={cn(
|
||||
'rounded-md px-2.5 py-1 text-[11px] font-medium transition-all cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40',
|
||||
'rounded-md px-2.5 py-1 text-[11px] font-medium transition-[background-color,color,box-shadow] duration-150 ease-out cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40',
|
||||
active ? 'bg-card font-semibold text-foreground shadow-sm ring-1 ring-border' : 'text-muted-foreground hover:text-foreground',
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -203,7 +203,7 @@ function Segmented<T extends string | number>({
|
||||
disabled={disabled}
|
||||
onClick={() => onChange(opt.value)}
|
||||
className={cn(
|
||||
'inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm transition-all cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40 disabled:cursor-not-allowed',
|
||||
'inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm transition-[background-color,color,box-shadow] duration-150 ease-out cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40 disabled:cursor-not-allowed',
|
||||
active ? 'bg-card font-semibold text-foreground shadow-sm ring-1 ring-border' : 'font-medium text-muted-foreground hover:text-foreground',
|
||||
)}
|
||||
>
|
||||
@@ -393,7 +393,7 @@ function AppearancePanel() {
|
||||
aria-label={p.label}
|
||||
onClick={() => setAppearance({ palette: p.id })}
|
||||
className={cn(
|
||||
'flex w-[5.5rem] flex-col items-center gap-1.5 rounded-xl border p-1.5 transition-all cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40',
|
||||
'flex w-[5.5rem] flex-col items-center gap-1.5 rounded-xl border p-1.5 transition-[border-color,box-shadow] duration-150 ease-out cursor-pointer outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40',
|
||||
active ? 'border-primary ring-2 ring-primary/30' : 'border-border hover:border-foreground/30',
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -226,7 +226,7 @@ function ChannelCard({ channel, testing, onToggle, onTest, onEdit, onDelete }: C
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={off ? { duration: 0 } : { duration: 0.18 }}
|
||||
className={cn(
|
||||
'flex flex-col gap-2 rounded-xl border bg-card/40 p-3.5 transition-all hover:bg-accent/20 sm:flex-row sm:items-center sm:gap-3',
|
||||
'flex flex-col gap-2 rounded-xl border bg-card/40 p-3.5 transition-[background-color,opacity] duration-150 ease-out hover:bg-accent/20 sm:flex-row sm:items-center sm:gap-3',
|
||||
!channel.enabled && 'opacity-60',
|
||||
)}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user