From 1cf03fec5f75c84439474f107605216945151359 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 14 Jul 2026 16:03:54 +0300 Subject: [PATCH] feat(panel): Faceplate component library + Overview showcase Token-driven, accessible components: Faceplate/FaceplateHeader, Module, Toggle, Led, SegMeter, QueryLog, Button, Clock, ThemeSwitch + reduced-motion hook. App is a realistic Overview showcase (throughput VU meters, module grid, streaming query log, apply->toast, theme switch). Built to match the north-star prototype: instrument-panel language, orange only as accent, semantic good/warn/crit. Verified (Playwright): dark+light, desktop+mobile (3->1 col), :focus-visible ring, reduced-motion honored, no console errors. dist ~162KB (49KB gzip), no heavy deps. --- panel/index.html | 12 ++ panel/src/App.css | 72 +++---- panel/src/App.tsx | 202 ++++++++++++++++-- panel/src/components/Button.css | 32 +++ panel/src/components/Button.tsx | 19 ++ panel/src/components/Clock.tsx | 18 ++ panel/src/components/Faceplate.css | 179 ++++++++++++++++ panel/src/components/Faceplate.tsx | 39 ++++ panel/src/components/FaceplateHeader.tsx | 33 +++ panel/src/components/Led.css | 36 ++++ panel/src/components/Led.tsx | 37 ++++ panel/src/components/Module.css | 84 ++++++++ panel/src/components/Module.tsx | 74 +++++++ panel/src/components/QueryLog.css | 107 ++++++++++ panel/src/components/QueryLog.tsx | 50 +++++ panel/src/components/SegMeter.css | 53 +++++ panel/src/components/SegMeter.tsx | 79 +++++++ panel/src/components/ThemeSwitch.tsx | 56 +++++ panel/src/components/Toggle.css | 66 ++++++ panel/src/components/Toggle.tsx | 37 ++++ panel/src/components/index.ts | 20 ++ .../src/components/usePrefersReducedMotion.ts | 22 ++ 22 files changed, 1266 insertions(+), 61 deletions(-) create mode 100644 panel/src/components/Button.css create mode 100644 panel/src/components/Button.tsx create mode 100644 panel/src/components/Clock.tsx create mode 100644 panel/src/components/Faceplate.css create mode 100644 panel/src/components/Faceplate.tsx create mode 100644 panel/src/components/FaceplateHeader.tsx create mode 100644 panel/src/components/Led.css create mode 100644 panel/src/components/Led.tsx create mode 100644 panel/src/components/Module.css create mode 100644 panel/src/components/Module.tsx create mode 100644 panel/src/components/QueryLog.css create mode 100644 panel/src/components/QueryLog.tsx create mode 100644 panel/src/components/SegMeter.css create mode 100644 panel/src/components/SegMeter.tsx create mode 100644 panel/src/components/ThemeSwitch.tsx create mode 100644 panel/src/components/Toggle.css create mode 100644 panel/src/components/Toggle.tsx create mode 100644 panel/src/components/index.ts create mode 100644 panel/src/components/usePrefersReducedMotion.ts diff --git a/panel/index.html b/panel/index.html index a79b6536..b1c2a3cf 100644 --- a/panel/index.html +++ b/panel/index.html @@ -4,7 +4,19 @@ + shater +
diff --git a/panel/src/App.css b/panel/src/App.css index 29f94790..b45eeaf6 100644 --- a/panel/src/App.css +++ b/panel/src/App.css @@ -1,52 +1,28 @@ -.boot { - min-height: 100%; - display: grid; - place-items: center; - padding: 24px; -} - -.boot-plate { - position: relative; - max-width: 420px; - width: 100%; - padding: 40px 32px; - text-align: center; - background: var(--raised); - border: 1px solid var(--edge); - border-radius: 10px; - box-shadow: - 0 1px 0 var(--edge) inset, - 0 12px 32px var(--shadow); -} - -.boot-wordmark { - font-size: 28px; - font-weight: 700; - letter-spacing: var(--track-label-wide); - color: var(--ink); -} - -.boot-sub { - margin-top: 6px; +/* Showcase-only styling. The Faceplate layout/components live in components/*.css; + * this file only owns the transient "Applied" toast. */ +.toast { + position: fixed; + left: 50%; + bottom: 24px; + transform: translateX(-50%); + padding: 10px 18px; + border-radius: 6px; + background: var(--accent); + color: #fff; font-family: var(--font-mono); - font-size: 11px; + font-size: 12px; + letter-spacing: 0.14em; text-transform: uppercase; - letter-spacing: var(--track-label); - color: var(--dim); + box-shadow: 0 8px 24px -8px var(--shadow); + animation: toast-in 0.25s ease; } - -.boot-led { - width: 9px; - height: 9px; - margin: 20px auto 0; - border-radius: 50%; - background: var(--led-on); - box-shadow: 0 0 8px var(--led-on); -} - -.boot-note { - margin: 20px 0 0; - font-size: 13px; - line-height: 1.5; - color: var(--faint); +@keyframes toast-in { + from { + opacity: 0; + transform: translate(-50%, 8px); + } + to { + opacity: 1; + transform: translate(-50%, 0); + } } diff --git a/panel/src/App.tsx b/panel/src/App.tsx index 871a3c97..df0734c6 100644 --- a/panel/src/App.tsx +++ b/panel/src/App.tsx @@ -1,19 +1,195 @@ import './App.css' +import { useCallback, useEffect, useRef, useState } from 'react' +import { + Button, + Faceplate, + FaceplateHeader, + Module, + QueryLog, + SegMeter, +} from './components' +import type { QueryEntry, QueryTag } from './components' + +// Realistic streaming sample — domains a household router actually sees. +const FEED: ReadonlyArray<[string, string, QueryTag]> = [ + ['youtube.com', 'tv-livingroom', 'proxy'], + ['googleads.g.doubleclick.net', 'iphone-lena', 'block'], + ['github.com', 'macbook-max', 'proxy'], + ['telegram.org', 'iphone-lena', 'proxy'], + ['app-measurement.com', 'android-kolya', 'block'], + ['cloudflare.com', 'macbook-max', 'pass'], + ['pool.ntp.org', 'router', 'pass'], + ['ads.tiktok.com', 'iphone-nina', 'block'], + ['reality.example.net', 'tv-livingroom', 'proxy'], + ['analytics.google.com', 'macbook-max', 'block'], + ['discord.gg', 'desktop-pc', 'proxy'], + ['tracker.metrics.io', 'android-kolya', 'block'], + ['wikipedia.org', 'ipad-kids', 'pass'], +] + +function stamp(): string { + const d = new Date() + const p = (n: number) => String(n).padStart(2, '0') + return `${p(d.getUTCHours())}:${p(d.getUTCMinutes())}:${p(d.getUTCSeconds())}` +} + +const LOG_LEN = 7 -// Placeholder shell. The real component library — -// — and the pages are built per docs-shater/DESIGN.md -// (north-star prototype) in Phase 3. This only proves the scaffold + tokens load. export function App() { + const seq = useRef(0) + const makeEntry = useCallback((): QueryEntry => { + const [domain, device, tag] = FEED[Math.floor(Math.random() * FEED.length)] + return { id: seq.current++, time: stamp(), domain, device, tag } + }, []) + + // ---- throughput targets (the meters ease toward these) ---- + const [dn, setDn] = useState(62) + const [up, setUp] = useState(9) + useEffect(() => { + const id = window.setInterval(() => { + if (Math.random() < 0.55) setDn(8 + Math.random() * 90) + if (Math.random() < 0.55) setUp(2 + Math.random() * 22) + }, 1400) + return () => window.clearInterval(id) + }, []) + + // ---- streaming query log ---- + const [entries, setEntries] = useState(() => + Array.from({ length: LOG_LEN }, makeEntry), + ) + useEffect(() => { + const id = window.setInterval(() => { + setEntries((prev) => [makeEntry(), ...prev].slice(0, LOG_LEN)) + }, 2200) + return () => window.clearInterval(id) + }, [makeEntry]) + + // ---- module switches ---- + const [tunnel, setTunnel] = useState(true) + const [filter, setFilter] = useState(true) + + // ---- apply flow → toast ---- + const [toast, setToast] = useState(null) + const toastTimer = useRef(undefined) + const apply = useCallback(() => { + setToast('Applied') + window.clearTimeout(toastTimer.current) + toastTimer.current = window.setTimeout(() => setToast(null), 2400) + }, []) + useEffect(() => () => window.clearTimeout(toastTimer.current), []) + + // ---- stable per-device activity bars ---- + const bars = useRef( + Array.from({ length: 12 }, () => 20 + Math.random() * 80), + ).current + return ( -
-
-
SHATER
-
admin panel · v0.2
-
-

- Faceplate scaffold ready. Component library and pages land in Phase 3. -

-
-
+ + } + footer={ +
+ SN 5AC4-B177-689C-B8E0 + feed signed · gitea + + + +
+ } + > +
+ + +
+ +
+ + + + + + + + + + + + + +
+ + + + {toast && ( +
+ {toast} +
+ )} +
) } diff --git a/panel/src/components/Button.css b/panel/src/components/Button.css new file mode 100644 index 00000000..e15da763 --- /dev/null +++ b/panel/src/components/Button.css @@ -0,0 +1,32 @@ +/* Buttons — mono, uppercase. .btn is ghost; .btn.primary is solid orange. */ +.btn { + display: inline-block; + padding: 7px 12px; + border: 1px solid var(--groove); + border-radius: 6px; + background: var(--raised); + color: var(--ink); + box-shadow: 0 1px 0 var(--edge) inset; + font-family: var(--font-mono); + font-size: 11px; + letter-spacing: 0.12em; + text-transform: uppercase; + text-decoration: none; + cursor: pointer; + transition: + border-color 0.15s, + color 0.15s; +} +.btn:hover { + border-color: var(--accent); + color: var(--accent); +} +.btn.primary { + border-color: transparent; + background: var(--accent); + color: #fff; +} +.btn.primary:hover { + color: #fff; + filter: brightness(1.05); +} diff --git a/panel/src/components/Button.tsx b/panel/src/components/Button.tsx new file mode 100644 index 00000000..27ca19a7 --- /dev/null +++ b/panel/src/components/Button.tsx @@ -0,0 +1,19 @@ +import './Button.css' +import type { ButtonHTMLAttributes } from 'react' + +export interface ButtonProps extends ButtonHTMLAttributes { + /** `primary` is the solid-orange call to action; `ghost` is the default. */ + variant?: 'ghost' | 'primary' +} + +export function Button({ variant = 'ghost', className, type, ...rest }: ButtonProps) { + return ( +