mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-02 13:15:17 +09:00
Phase 0 of the ServerKit UI redesign (see docs/REDESIGN_MAP.md): - Remap design tokens to the new infra-console palette behind existing names; add prototype token names (surface ramp, cyan/violet, accent-bright/-bg). Dark/light/system. - Self-host IBM Plex (woff2 vendored via scripts/fetch-fonts.mjs); no Google Fonts CDN. - Runtime-derive the full accent ramp in ThemeContext. - Add shared design-system primitives in components/ds (Pill, EnvTag, SegControl, MetricCard, Gauge, ServiceTile, Sparkline, AreaChart, ScoreGauge, Feed, Drawer). - Restyle the sidebar (gradient rail, mono section headers, left accent bar) and switch the brand to the demo's gradient-tile logo. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
24 lines
849 B
JavaScript
24 lines
849 B
JavaScript
// Helpers for the design-system primitives (see docs/REDESIGN_MAP.md §3).
|
|
|
|
// Deterministic gradient from a name — used by ServiceTile and elsewhere a
|
|
// colored initial avatar is needed. Same name always yields the same hue.
|
|
export function svcGrad(name = '') {
|
|
let h = 0;
|
|
for (let i = 0; i < name.length; i++) {
|
|
h = (h * 31 + name.charCodeAt(i)) % 360;
|
|
}
|
|
return `linear-gradient(150deg, hsl(${h} 58% 60%), hsl(${(h + 24) % 360} 55% 46%))`;
|
|
}
|
|
|
|
// First letter (uppercased) for an avatar/tile label.
|
|
export function initials(name = '') {
|
|
return (name.trim()[0] || '?').toUpperCase();
|
|
}
|
|
|
|
// Threshold color for a percentage gauge (red > 75, amber > 50, else accent).
|
|
export function gaugeColor(pct) {
|
|
if (pct > 75) return 'var(--red)';
|
|
if (pct > 50) return 'var(--amber)';
|
|
return 'var(--accent-bright)';
|
|
}
|