Files
SnowLuma/packages/webui/src/index.css
T
DrSmoothl f127e3dc59 fix(webui): meet WCAG AA for log-level text on light theme
The log-level accent colors (info/success/warn/error) are tuned as fills;
as small text on the light canvas they fell below WCAG AA (info 2.6:1,
success 2.4:1, warn 2.0:1, error 4.3:1, trace 2.5:1). Add dedicated
--log-* text tokens that are darkened in light mode (>=4.5:1) while
keeping the bright, already-passing values in dark mode, so the app-wide
accent is untouched. trace moves from /60 to /90 to clear AA yet stay the
faintest level. Applied to both the logs page and overview RecentAlerts.
2026-07-04 00:08:30 +08:00

427 lines
16 KiB
CSS
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@import "tailwindcss";
@import "tw-animate-css";
@custom-variant dark (&:where(.dark, .dark *));
/* ──────────────────────────────────────────────
Theme tokens (sky-blue accent)
────────────────────────────────────────────── */
:root {
--radius: 0.75rem;
--background: oklch(99% 0.004 240);
--foreground: oklch(20% 0.03 250);
--card: oklch(100% 0 0);
--card-foreground: oklch(20% 0.03 250);
--popover: oklch(100% 0 0);
--popover-foreground: oklch(20% 0.03 250);
/* sky-500 */
--primary: oklch(68.5% 0.155 230);
--primary-foreground: oklch(99% 0.005 240);
--secondary: oklch(96% 0.012 240);
--secondary-foreground: oklch(25% 0.03 250);
--muted: oklch(96% 0.012 240);
--muted-foreground: oklch(50% 0.02 250);
--accent: oklch(94% 0.03 230);
--accent-foreground: oklch(35% 0.07 230);
--destructive: oklch(60% 0.22 27);
--destructive-foreground: oklch(99% 0.005 240);
--success: oklch(70% 0.15 160);
--warning: oklch(78% 0.16 80);
/* Log-level TEXT colors. The accent tokens above are tuned as fills (white
text on them passes AA); as small text on the light canvas they fail WCAG
AA (info 2.6:1, success 2.4:1, warn 2.0:1, error 4.3:1). These darker
variants restore >=4.5:1 for the log viewer without darkening the app-wide
accent. Dark theme keeps the bright values (they already pass on dark). */
--log-info: oklch(50% 0.155 230);
--log-success: oklch(50% 0.15 160);
--log-warn: oklch(52% 0.16 80);
--log-error: oklch(55% 0.22 27);
--border: oklch(92% 0.01 240);
--input: oklch(94% 0.012 240);
--ring: oklch(68.5% 0.155 230);
--sidebar: oklch(98% 0.006 240);
--sidebar-foreground: oklch(25% 0.03 250);
--sidebar-primary: oklch(68.5% 0.155 230);
--sidebar-primary-foreground: oklch(99% 0.005 240);
--sidebar-accent: oklch(94% 0.025 230);
--sidebar-accent-foreground: oklch(35% 0.08 230);
--sidebar-border: oklch(92% 0.01 240);
--sidebar-ring: oklch(68.5% 0.155 230);
}
.dark {
--background: oklch(16% 0.02 250);
--foreground: oklch(96% 0.01 240);
--card: oklch(20% 0.025 250);
--card-foreground: oklch(96% 0.01 240);
--popover: oklch(20% 0.025 250);
--popover-foreground: oklch(96% 0.01 240);
--primary: oklch(75% 0.14 230);
--primary-foreground: oklch(15% 0.02 250);
--secondary: oklch(25% 0.025 250);
--secondary-foreground: oklch(96% 0.01 240);
--muted: oklch(24% 0.02 250);
--muted-foreground: oklch(68% 0.02 240);
--accent: oklch(28% 0.05 230);
--accent-foreground: oklch(85% 0.1 230);
--destructive: oklch(62% 0.2 27);
--destructive-foreground: oklch(98% 0.005 240);
--success: oklch(72% 0.15 160);
--warning: oklch(80% 0.16 80);
/* On the dark canvas the bright accents already clear AA as text, so the
log-level text tokens mirror them (see the :root note above). */
--log-info: oklch(75% 0.14 230);
--log-success: oklch(72% 0.15 160);
--log-warn: oklch(80% 0.16 80);
--log-error: oklch(62% 0.2 27);
--border: oklch(28% 0.02 250);
--input: oklch(26% 0.02 250);
--ring: oklch(75% 0.14 230);
--sidebar: oklch(18% 0.022 250);
--sidebar-foreground: oklch(92% 0.01 240);
--sidebar-primary: oklch(75% 0.14 230);
--sidebar-primary-foreground: oklch(15% 0.02 250);
--sidebar-accent: oklch(28% 0.05 230);
--sidebar-accent-foreground: oklch(85% 0.1 230);
--sidebar-border: oklch(26% 0.02 250);
--sidebar-ring: oklch(75% 0.14 230);
}
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-destructive-foreground: var(--destructive-foreground);
--color-success: var(--success);
--color-warning: var(--warning);
--color-log-info: var(--log-info);
--color-log-success: var(--log-success);
--color-log-warn: var(--log-warn);
--color-log-error: var(--log-error);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--color-sidebar: var(--sidebar);
--color-sidebar-foreground: var(--sidebar-foreground);
--color-sidebar-primary: var(--sidebar-primary);
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
--color-sidebar-accent: var(--sidebar-accent);
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
--color-sidebar-border: var(--sidebar-border);
--color-sidebar-ring: var(--sidebar-ring);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
--font-sans: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
--font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}
@layer base {
* {
border-color: var(--border);
}
html, body, #root {
height: 100%;
}
body {
margin: 0;
background-color: var(--background);
color: var(--foreground);
font-family: var(--font-sans);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
line-height: 1.5;
}
::selection {
background-color: color-mix(in oklab, var(--primary) 28%, transparent);
color: var(--foreground);
}
/* Density: compact tightens the global rhythm a touch. Use rem (not px) so
it still tracks the UI-scale root font-size. */
html[data-density="compact"] body {
font-size: 0.84rem;
line-height: 1.45;
}
html[data-density="compact"] {
--tw-leading: 1.4;
}
}
/* ──────────────────────────────────────────────
Customization layers (driven by ThemeContext via
data-* attributes + CSS vars on <html>)
────────────────────────────────────────────── */
/* Dark intensity: "black" pushes the dark palette toward true black for
OLED screens. Only meaningful in dark mode. */
.dark[data-dark-intensity="black"] {
--background: oklch(0% 0 0);
--foreground: oklch(97% 0.01 240);
--card: oklch(13% 0.008 250);
--card-foreground: oklch(96% 0.01 240);
--popover: oklch(13% 0.008 250);
--popover-foreground: oklch(96% 0.01 240);
--secondary: oklch(17% 0.012 250);
--muted: oklch(15% 0.01 250);
--muted-foreground: oklch(66% 0.02 240);
--border: oklch(22% 0.012 250);
--input: oklch(19% 0.012 250);
}
/* OLED's near-black sidebar applies only when the sidebar follows the canvas;
scoping it to "follow" lets the panel/accent styles below win in OLED too
(otherwise this higher-specificity block would override them). */
.dark[data-dark-intensity="black"][data-sidebar-style="follow"] {
--sidebar: oklch(5% 0.006 250);
--sidebar-border: oklch(20% 0.012 250);
}
/* Sidebar style: how distinct the sidebar surface is from the main canvas. */
html[data-sidebar-style="panel"] {
--sidebar: color-mix(in oklab, var(--card) 90%, var(--primary) 4%);
}
html[data-sidebar-style="accent"] {
--sidebar: color-mix(in oklab, var(--background) 76%, var(--primary) 24%);
--sidebar-foreground: color-mix(in oklab, var(--foreground) 85%, var(--primary));
--sidebar-border: color-mix(in oklab, var(--border) 60%, var(--primary) 40%);
}
/* High contrast: strengthen borders + dim-text contrast for legibility. */
html[data-contrast="high"] {
--border: color-mix(in oklab, var(--foreground) 55%, var(--border));
--input: color-mix(in oklab, var(--foreground) 45%, var(--input));
--muted-foreground: color-mix(in oklab, var(--foreground) 78%, var(--muted-foreground));
--sidebar-border: color-mix(in oklab, var(--foreground) 55%, var(--sidebar-border));
}
/* Kiosk ("展示模式"): hide any in-content edit/config entry points marked with
data-kiosk-hide (the chrome itself is removed in MainLayout). */
html[data-kiosk="1"] [data-kiosk-hide] {
display: none !important;
}
/* Reduce motion: a CSS fallback for non-Framer transitions/animations.
Framer Motion itself is handled by <MotionConfig reducedMotion>. */
html[data-reduce-motion="1"] *,
html[data-reduce-motion="1"] *::before,
html[data-reduce-motion="1"] *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
/* 关闭全部动效: harder than reduce — remove CSS animations outright (e.g. the
pulsing status dots) rather than just collapsing their duration. Framer
entrance fades are gated in components on `disableMotion`. */
html[data-no-motion="1"] *:not(.animate-spin),
html[data-no-motion="1"] *::before,
html[data-no-motion="1"] *::after {
/* Exclude .animate-spin: loading spinners encode "busy", not decoration —
freezing them reads as a hang. Everything else (e.g. pulse dots) stops. */
animation: none !important;
}
/* Hide the browser-native password reveal / clear controls (Edge & IE render
an extra eye / × on inputs) so only our own show-password toggle shows. */
input::-ms-reveal,
input::-ms-clear {
display: none;
}
/* ──────────────────────────────────────────────
Light/dark reveal — a circular wipe from the click point, via the View
Transitions API (Chromium/Edge/Safari; Firefox falls back to an instant
swap). Gated in JS on the motion settings, so this only runs when allowed.
────────────────────────────────────────────── */
::view-transition-old(root),
::view-transition-new(root) {
animation: none;
mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 0; }
::view-transition-new(root) {
z-index: 1;
animation: snowluma-theme-reveal 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes snowluma-theme-reveal {
from { clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 50%)); }
to { clip-path: circle(var(--vt-r, 150%) at var(--vt-x, 50%) var(--vt-y, 50%)); }
}
/* ──────────────────────────────────────────────
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, <pre>, 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; }
/* ──────────────────────────────────────────────
Login background — wavy SVG line field (see <LoginWaves>). Themed to the
accent so it reads as a subtle decorative backdrop behind the login card.
────────────────────────────────────────────── */
.login-waves {
color: color-mix(in oklab, var(--primary) 26%, transparent);
}
.login-waves path {
fill: none;
stroke: currentColor;
stroke-width: 1px;
}
/* ──────────────────────────────────────────────
Custom range slider (via the <Slider> 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
gridstack content box is just a transparent, full-bleed container.
────────────────────────────────────────────── */
.grid-stack {
/* Negative inset cancels gridstack's per-item margin at the edges so the
grid lines up with surrounding page padding. */
background: transparent;
}
.grid-stack-item-content {
inset: 0;
overflow: visible;
background: transparent;
display: block;
}
/* The drag placeholder (drop target preview). */
.grid-stack > .grid-stack-placeholder > .placeholder-content {
border: 2px dashed var(--primary);
background: color-mix(in oklab, var(--primary) 8%, transparent);
border-radius: var(--radius);
}
/* Resize handle — only present while editing (grid is interactive). Make the
bottom-right grip obvious so it's clearly draggable. */
.grid-stack-item > .ui-resizable-se {
width: 18px;
height: 18px;
right: 5px;
bottom: 5px;
background-image: none;
transform: none;
border-right: 3px solid var(--primary);
border-bottom: 3px solid var(--primary);
border-bottom-right-radius: 5px;
opacity: 0.65;
z-index: 30;
}
.grid-stack-item:hover > .ui-resizable-se {
opacity: 1;
}