From 2a56a166770811e7101d28dc3c101984fbbe6f8e Mon Sep 17 00:00:00 2001
From: ZingerLittleBee <6970999@gmail.com>
Date: Thu, 26 Nov 2026 00:39:30 +0800
Subject: [PATCH 01/11] feat(web): add quiet widget chrome and borderless card
surface
Widgets share a quiet title row, large tabular readings with a muted unit, centered status messages and a loading skeleton. Cards drop the border for a hairline ring so spacing carries the hierarchy.
---
.../components/dashboard/dashboard-card.tsx | 7 +-
.../dashboard/module-widget-host.tsx | 8 +-
.../components/dashboard/widget-chrome.tsx | 95 +++++++++++++++++++
.../components/dashboard/widget-renderer.tsx | 2 +-
.../dashboard/widgets/server-cards.tsx | 8 +-
apps/web/src/lib/widget-helpers.ts | 14 +++
apps/web/src/locales/en/dashboard.json | 5 +
apps/web/src/locales/zh/dashboard.json | 4 +
8 files changed, 133 insertions(+), 10 deletions(-)
create mode 100644 apps/web/src/components/dashboard/widget-chrome.tsx
diff --git a/apps/web/src/components/dashboard/dashboard-card.tsx b/apps/web/src/components/dashboard/dashboard-card.tsx
index d715c273f..c50891028 100644
--- a/apps/web/src/components/dashboard/dashboard-card.tsx
+++ b/apps/web/src/components/dashboard/dashboard-card.tsx
@@ -1,7 +1,12 @@
import type { ComponentProps } from 'react'
import { cn } from '@/lib/utils'
-export const DASHBOARD_CARD_CLASS_NAME = 'min-w-0 rounded-xl border border-border/70 shadow-sm'
+/**
+ * Borderless widget surface: a hairline ring plus a soft drop in light mode,
+ * a faint ring in dark mode. Layout rhythm comes from spacing, not borders.
+ */
+export const DASHBOARD_CARD_CLASS_NAME =
+ 'min-w-0 rounded-2xl shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_3px_rgb(0_0_0/0.05)] dark:shadow-[0_0_0_1px_rgb(255_255_255/0.07)]'
export function DashboardCard({ className, ...props }: ComponentProps<'div'>) {
return
diff --git a/apps/web/src/components/dashboard/module-widget-host.tsx b/apps/web/src/components/dashboard/module-widget-host.tsx
index 39b21e809..3e8a3d558 100644
--- a/apps/web/src/components/dashboard/module-widget-host.tsx
+++ b/apps/web/src/components/dashboard/module-widget-host.tsx
@@ -2,8 +2,10 @@ import type { ActionsHelper } from '@serverbee/widget-sdk'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { DashboardCard } from '@/components/dashboard/dashboard-card'
+import { WIDGET_PADDING_CLASS_NAME, WidgetHeader } from '@/components/dashboard/widget-chrome'
import { ScrollArea } from '@/components/ui/scroll-area'
import type { ServerMetrics } from '@/lib/server-catalog'
+import { cn } from '@/lib/utils'
import { parseConfig } from '@/lib/widget-helpers'
import type { DashboardWidget } from '@/lib/widget-types'
import { useWidgetRegistry } from '@/widgets-runtime/registry'
@@ -19,7 +21,7 @@ const NOOP_ACTIONS: ActionsHelper = {
function Placeholder({ message }: { message: string }) {
return (
-
+
{message}
)
@@ -63,8 +65,8 @@ export function ModuleWidgetHost({ widget, servers: _servers }: ModuleWidgetHost
const Component = entry.module.component
const title = widget.title || entry.manifest.name
return (
-
-
{title}
+
+
+
+ {title}
+ {context ? · {context} : null}
+
+ {aside ?
{aside}
: null}
+
+ )
+}
+
+const VALUE_UNIT_RE = /^([+\-−]?\d[\d.,]*)(.*)$/
+
+/** Split a formatted reading such as `75.3%` or `1.1 MB/s` into number and unit. */
+export function splitValueUnit(formatted: string): { unit: string; value: string } {
+ const match = VALUE_UNIT_RE.exec(formatted)
+ if (!match) {
+ return { value: formatted, unit: '' }
+ }
+ return { value: match[1], unit: match[2] }
+}
+
+interface WidgetValueProps extends Omit, 'children'> {
+ /** Pre-formatted reading; a leading number keeps full size, the rest shrinks. */
+ formatted: string
+ unitClassName?: string
+}
+
+/**
+ * Large tabular reading with a de-emphasized unit. Size comes from the caller's
+ * `text-*` class; the unit scales with it.
+ */
+export function WidgetValue({ className, formatted, unitClassName, ...props }: WidgetValueProps) {
+ const { value, unit } = splitValueUnit(formatted)
+ return (
+
+ {value}
+ {unit ? (
+
+ {unit}
+
+ ) : null}
+
+ )
+}
+
+interface WidgetMessageProps {
+ className?: string
+ description?: ReactNode
+ icon?: ReactNode
+ title: ReactNode
+}
+
+/** Centered empty / status message that states what the absence means. */
+export function WidgetMessage({ className, description, icon, title }: WidgetMessageProps) {
+ return (
+
+ {icon ?
{icon}
: null}
+
{title}
+ {description ?
{description}
: null}
+
+ )
+}
+
+/** Loading placeholder for chart widgets: a header line above the chart body. */
+export function WidgetSkeleton() {
+ return (
+
+
+
+
+ )
+}
diff --git a/apps/web/src/components/dashboard/widget-renderer.tsx b/apps/web/src/components/dashboard/widget-renderer.tsx
index 2dde4cbf5..5d3e0ee0f 100644
--- a/apps/web/src/components/dashboard/widget-renderer.tsx
+++ b/apps/web/src/components/dashboard/widget-renderer.tsx
@@ -77,7 +77,7 @@ class WidgetErrorBoundary extends Component
+
Widget failed to render
)
diff --git a/apps/web/src/components/dashboard/widgets/server-cards.tsx b/apps/web/src/components/dashboard/widgets/server-cards.tsx
index c637a5e42..3fc882451 100644
--- a/apps/web/src/components/dashboard/widgets/server-cards.tsx
+++ b/apps/web/src/components/dashboard/widgets/server-cards.tsx
@@ -163,11 +163,9 @@ export function ServerCardsWidget({ config, servers }: ServerCardsWidgetProps) {
// offline tiles match even when body sections differ.
)
}
diff --git a/apps/web/src/locales/en/dashboard.json b/apps/web/src/locales/en/dashboard.json
index 636f61d5c..4b02449ea 100644
--- a/apps/web/src/locales/en/dashboard.json
+++ b/apps/web/src/locales/en/dashboard.json
@@ -334,8 +334,8 @@
"diskIo": "Disk I/O"
},
"past1h": "past 1h",
- "peak": "24H PEAK",
- "avg": "24H AVG",
+ "peak": "Peak",
+ "avg": "Avg",
"unknownServer": "Unknown server",
"unknownMetric": "Metric not configured"
},
diff --git a/apps/web/src/locales/zh/dashboard.json b/apps/web/src/locales/zh/dashboard.json
index 6fe69651d..f2472696f 100644
--- a/apps/web/src/locales/zh/dashboard.json
+++ b/apps/web/src/locales/zh/dashboard.json
@@ -333,8 +333,8 @@
"diskIo": "磁盘 I/O"
},
"past1h": "过去 1 小时",
- "peak": "24H 峰值",
- "avg": "24H 均值",
+ "peak": "峰值",
+ "avg": "均值",
"unknownServer": "未知服务器",
"unknownMetric": "未配置指标"
},
From afc179ae145bc2eaf75c2eade9915251c25d65bf Mon Sep 17 00:00:00 2001
From: ZingerLittleBee <6970999@gmail.com>
Date: Thu, 26 Nov 2026 00:39:39 +0800
Subject: [PATCH 04/11] feat(web): restyle gauge as a thin ring with a severity
word
---
.../components/dashboard/widgets/gauge.tsx | 124 ++++++++----------
apps/web/src/locales/en/dashboard.json | 6 +
apps/web/src/locales/zh/dashboard.json | 6 +
3 files changed, 65 insertions(+), 71 deletions(-)
diff --git a/apps/web/src/components/dashboard/widgets/gauge.tsx b/apps/web/src/components/dashboard/widgets/gauge.tsx
index 1e4af1212..ee4e3e014 100644
--- a/apps/web/src/components/dashboard/widgets/gauge.tsx
+++ b/apps/web/src/components/dashboard/widgets/gauge.tsx
@@ -1,9 +1,10 @@
-import { Activity, Cpu, Gauge as GaugeIcon, HardDrive, MemoryStick, Network } from 'lucide-react'
import { useId, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { DashboardCard } from '@/components/dashboard/dashboard-card'
+import { splitValueUnit, WidgetMessage } from '@/components/dashboard/widget-chrome'
import type { ServerMetrics } from '@/lib/server-catalog'
-import { getUtilizationRingColor } from '@/lib/utilization-colors'
+import { getUtilizationRingColor, getUtilizationSeverity } from '@/lib/utilization-colors'
+import { cn } from '@/lib/utils'
import { normalizeWidgetColor } from '@/lib/widget-color'
import { extractLiveMetric, metricLabel } from '@/lib/widget-helpers'
import type { GaugeConfig } from '@/lib/widget-types'
@@ -19,7 +20,7 @@ const CENTER = VIEWBOX / 2
// Radius pushes the ring close to the viewBox edge so the gauge fills the
// card; clamped so the round linecap (STROKE/2 outward) still fits inside.
const RADIUS = 44
-const STROKE = 8
+const STROKE = 6
// 270° sweep, gap centered at bottom. Angles in degrees, clockwise from 12 o'clock.
// Start at 7:30 (225°), sweep clockwise past 9, 12, 3 to 4:30 (135°), leaving a
// 90° gap centered at 6 o'clock — matches the reference horseshoe orientation.
@@ -41,28 +42,6 @@ function getGaugeGradient(value: number, overrideColor?: string): Gradient {
return { start: color, end: color }
}
-function getMetricIcon(metric: string) {
- switch (metric) {
- case 'cpu':
- return Cpu
- case 'memory':
- case 'swap':
- return MemoryStick
- case 'disk':
- return HardDrive
- case 'load1':
- case 'load5':
- case 'load15':
- return Activity
- case 'net_in':
- case 'net_out':
- case 'bandwidth':
- return Network
- default:
- return GaugeIcon
- }
-}
-
// Convert a polar coordinate (angle in degrees, clockwise from 12 o'clock) to cartesian SVG coords.
function polarToCartesian(cx: number, cy: number, r: number, angleDeg: number) {
const angleRad = ((angleDeg - 90) * Math.PI) / 180
@@ -100,15 +79,18 @@ export function GaugeWidget({ config, servers }: GaugeWidgetProps) {
if (!server) {
return (
-
- {t('widgets.common.empty.serverNotFound')}
+
+
)
}
const label = config.label ?? metricLabel(metric, t)
const gradient = getGaugeGradient(value, config.color)
- const Icon = getMetricIcon(metric)
+ const percent = max > 0 ? (value / max) * 100 : 0
+ const severity = getUtilizationSeverity(percent)
+ const reading = splitValueUnit(`${value.toFixed(1)}%`)
+ const [whole, fraction = ''] = reading.value.split('.')
const progressSweep = max > 0 ? (value / max) * SWEEP : 0
const trackEnd = START_ANGLE + SWEEP
@@ -119,46 +101,10 @@ export function GaugeWidget({ config, servers }: GaugeWidgetProps) {
const showProgress = value > 0
- const mainText = (
- <>
-
-
- {label}
-
-
- {value.toFixed(1)}
- %
-
- >
- )
-
- // Server name sits at the bottom of the card, inside the arc gap (the 90°
- // opening centered at 6 o'clock). Anchored via absolute positioning so it
- // doesn't shift the centered icon/label/value stack.
- const subtitle = (
-