diff --git a/packages/webui/src/components/layout/main-layout.tsx b/packages/webui/src/components/layout/main-layout.tsx index 2c8b96df..e92bfb98 100644 --- a/packages/webui/src/components/layout/main-layout.tsx +++ b/packages/webui/src/components/layout/main-layout.tsx @@ -28,6 +28,10 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) { return appearance.sidebarDefaultCollapsed; }); const customBg = appearance.background.type !== 'none'; + // Framer's reducedMotion only suppresses transforms, so the always-present + // width + page-transition animations need an explicit opt-out to make the + // “减少动效” setting actually felt. + const reduce = appearance.reduceMotion; const { editing } = useLayout(); // Force the sidebar open while editing layout so its drag-to-reorder list // has room (it returns to the user's collapsed pref on 完成). @@ -46,7 +50,7 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) { @@ -85,10 +89,10 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) { {children} diff --git a/packages/webui/src/components/pages/overview-page.tsx b/packages/webui/src/components/pages/overview-page.tsx index 4c9d3f24..ba7c7a56 100644 --- a/packages/webui/src/components/pages/overview-page.tsx +++ b/packages/webui/src/components/pages/overview-page.tsx @@ -173,7 +173,7 @@ function StatTile({ to?: AppPath; }) { const body = ( - +

{label}

-
{value}
- {subtext &&

{subtext}

} +
{value}
+ {subtext &&

{subtext}

}
{to && } diff --git a/packages/webui/src/components/pages/settings-page.tsx b/packages/webui/src/components/pages/settings-page.tsx index a828aea6..58ec0221 100644 --- a/packages/webui/src/components/pages/settings-page.tsx +++ b/packages/webui/src/components/pages/settings-page.tsx @@ -8,6 +8,7 @@ import { import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { ToggleSwitch } from '@/components/ui/toggle-switch'; +import { Slider } from '@/components/ui/slider'; import { ACCENTS, DEFAULT_APPEARANCE, @@ -361,14 +362,13 @@ function AppearancePanel() {
{Math.round(UI_SCALE.min * 100)}% - setAppearance({ uiScale: Number(e.target.value) })} - className="h-2 flex-1 cursor-pointer accent-primary" + className="flex-1" aria-label="界面缩放" /> {Math.round(UI_SCALE.max * 100)}% @@ -506,26 +506,22 @@ function BackgroundCard({ {a.background.hasImage && ( <> - setAppearance({ background: { imageOpacity: Number(e.target.value) } })} - className="h-2 w-full cursor-pointer accent-primary" aria-label="遮罩强度" /> - setAppearance({ background: { imageBlur: Number(e.target.value) } })} - className="h-2 w-full cursor-pointer accent-primary" aria-label="背景模糊" /> diff --git a/packages/webui/src/components/ui/slider.tsx b/packages/webui/src/components/ui/slider.tsx new file mode 100644 index 00000000..8e995af8 --- /dev/null +++ b/packages/webui/src/components/ui/slider.tsx @@ -0,0 +1,28 @@ +import * as React from 'react'; +import { cn } from '@/lib/utils'; + +interface SliderProps extends Omit, 'type' | 'value'> { + value: number; + min: number; + max: number; +} + +/** + * Themed range input. Styling lives in index.css (`.slider`); here we just + * compute the filled-track percentage and expose it as `--slider-pct` for the + * WebKit track gradient (Firefox fills natively via ::-moz-range-progress). + */ +export function Slider({ value, min, max, className, style, ...props }: SliderProps) { + const pct = max > min ? Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100)) : 0; + return ( + + ); +} diff --git a/packages/webui/src/index.css b/packages/webui/src/index.css index 7559510c..a3ab5b39 100644 --- a/packages/webui/src/index.css +++ b/packages/webui/src/index.css @@ -216,6 +216,91 @@ html[data-reduce-motion="1"] *::after { scroll-behavior: auto !important; } +/* ────────────────────────────────────────────── + Native scrollbars — themed to match. Radix ScrollArea hides its own + native bar and renders a custom thumb, so this only styles plain overflow + containers (textareas,
, the settings rail, grid widget bodies…).
+   ────────────────────────────────────────────── */
+html {
+  scrollbar-width: thin;
+  scrollbar-color: color-mix(in oklab, var(--foreground) 22%, transparent) transparent;
+}
+::-webkit-scrollbar { width: 10px; height: 10px; }
+::-webkit-scrollbar-track { background: transparent; }
+::-webkit-scrollbar-thumb {
+  background-color: color-mix(in oklab, var(--foreground) 22%, transparent);
+  border-radius: 9999px;
+  border: 2px solid transparent;
+  background-clip: padding-box;
+}
+::-webkit-scrollbar-thumb:hover {
+  background-color: color-mix(in oklab, var(--foreground) 38%, transparent);
+}
+::-webkit-scrollbar-corner { background: transparent; }
+
+/* ──────────────────────────────────────────────
+   Custom range slider (via the  component, class `.slider`).
+   The component sets `--slider-pct` for the WebKit filled track; Firefox
+   uses native ::-moz-range-progress.
+   ────────────────────────────────────────────── */
+.slider {
+  -webkit-appearance: none;
+  appearance: none;
+  width: 100%;
+  /* Match the track height so WebKit can't top-align a short track inside a
+     taller input; the 1rem thumb overflows symmetrically as the grab target. */
+  height: 0.375rem;
+  background: transparent;
+  cursor: pointer;
+}
+.slider::-webkit-slider-runnable-track {
+  height: 0.375rem;
+  border-radius: 9999px;
+  background: linear-gradient(to right,
+    var(--primary) var(--slider-pct, 0%),
+    var(--muted) var(--slider-pct, 0%));
+}
+.slider::-webkit-slider-thumb {
+  -webkit-appearance: none;
+  appearance: none;
+  margin-top: -0.3125rem; /* center the 1rem thumb on the 0.375rem track */
+  height: 1rem;
+  width: 1rem;
+  border-radius: 9999px;
+  background: var(--background);
+  border: 2px solid var(--primary);
+  box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
+  transition: transform 0.12s ease;
+}
+.slider:active::-webkit-slider-thumb { transform: scale(1.12); }
+.slider:focus-visible::-webkit-slider-thumb {
+  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
+}
+.slider::-moz-range-track {
+  height: 0.375rem;
+  border-radius: 9999px;
+  background: var(--muted);
+}
+.slider::-moz-range-progress {
+  height: 0.375rem;
+  border-radius: 9999px;
+  background: var(--primary);
+}
+.slider::-moz-range-thumb {
+  height: 1rem;
+  width: 1rem;
+  border: 2px solid var(--primary);
+  border-radius: 9999px;
+  background: var(--background);
+  box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
+}
+.slider:focus-visible::-moz-range-thumb {
+  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
+}
+/* The global reduce-motion rule can't match pseudo-elements, so kill the
+   thumb's active-scale transition explicitly. */
+html[data-reduce-motion="1"] .slider::-webkit-slider-thumb { transition: none !important; }
+
 /* ──────────────────────────────────────────────
    gridstack dashboard — mesh the library's item shell with our cards.
    The widget content (a Card) owns its own bg/border/rounding, so the