ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
refactor(ui): expand shared StatCard + card system
Juan Denis5338e2930a68
diff --git a/frontend/src/components/StatCard.jsx b/frontend/src/components/StatCard.jsxindex 69b26195..a3635cde 100644--- a/frontend/src/components/StatCard.jsx+++ b/frontend/src/components/StatCard.jsx@@ -1,46 +1,84 @@import React from 'react';-export function StatsGrid({ children, className = '' }) {- return <div className={`stats-grid ${className}`.trim()}>{children}</div>;+// ─────────────────────────────────────────────────────────────────────────────+// Stat strip — a compact, instrument-panel readout bar.+//+// Replaces the old hero-metric stat cards (big number + icon chip) with a single+// dense bordered strip of segments. Use it for the page-level summary row that+// sits above a page's tabs/content.+//+// <StatStrip>+// <Stat label="Total Backups" value={12} />+// <Stat label="ClamAV" value="Active" state="success" />+// </StatStrip>+//+// `state` (success | warning | danger | info | neutral) tints the value and adds+// a status dot. Status is never carried by color alone — the value text always+// states it too, the dot is only reinforcement.+// ─────────────────────────────────────────────────────────────────────────────++const STATEFUL = new Set(['success', 'warning', 'danger', 'info']);++export function StatStrip({ children, className = '', ariaLabel }) {+ return (+ <div+ className={`stat-strip ${className}`.trim()}+ role="group"+ aria-label={ariaLabel}+ >+ {children}+ </div>+ );}-export function StatCard({- icon: Icon,- iconVariant,- iconNode,+export function Stat({label,value,suffix,detail,+ state,valueClassName = '',onClick,active = false,children,}) {- const iconClass = ['stat-icon', iconVariant].filter(Boolean).join(' ');- const cardClass = ['stat-card', active && 'active', onClick && 'stat-card--clickable']- .filter(Boolean).join(' ');+ const hasDot = STATEFUL.has(state);+ const itemClass = [+ 'stat-strip__item',+ state && `is-${state}`,+ onClick && 'stat-strip__item--clickable',+ active && 'is-active',+ ].filter(Boolean).join(' ');+const Tag = onClick ? 'button' : 'div';+return (<Tag- className={cardClass}+ className={itemClass}{...(onClick && { type: 'button', onClick, 'aria-pressed': active })}>- <div className={iconClass}>- {iconNode ?? (Icon ? <Icon size={20} /> : null)}- </div>- <div className="stat-content">- <span className="stat-label">{label}</span>- {children ?? (- <span className={`stat-value ${valueClassName}`.trim()}>- {value}- {suffix && <span className="stat-suffix">{suffix}</span>}- </span>- )}- {detail && <span className="stat-detail">{detail}</span>}- </div>+ <span className="stat-strip__label">{label}</span>+ <span className={`stat-strip__value ${valueClassName}`.trim()}>+ {hasDot && <span className="stat-strip__dot" aria-hidden="true" />}+ {children ?? value}+ {suffix && <span className="stat-strip__suffix">{suffix}</span>}+ </span>+ {detail && <span className="stat-strip__detail">{detail}</span>}</Tag>);}+// ── Back-compat aliases ──────────────────────────────────────────────────────+// Existing call sites import { StatCard, StatsGrid }. They now render the strip;+// the old icon/iconVariant props are intentionally ignored (the strip drops the+// decorative icon chips). No call-site changes required for these.++export function StatsGrid({ children, className = '', ...rest }) {+ return <StatStrip className={className} {...rest}>{children}</StatStrip>;+}++export function StatCard({ icon: _icon, iconVariant: _iconVariant, iconNode: _iconNode, ...rest }) {+ return <Stat {...rest} />;+}+export default StatCard;diff --git a/frontend/src/styles/components/_cards.scss b/frontend/src/styles/components/_cards.scssindex 212732c8..95d505ce 100644--- a/frontend/src/styles/components/_cards.scss+++ b/frontend/src/styles/components/_cards.scss@@ -63,7 +63,122 @@@include mono-text();}-// Stats grid layout+// ============================================+// STAT STRIP — compact instrument-panel readout bar+// ============================================+// The page-level summary row that sits above a page's tabs. One bordered+// container divided into segments; replaces the old hero-metric stat cards.+// Dividers are drawn by a 1px grid gap revealing the border-coloured backdrop,+// so they stay crisp on wrap (no per-cell side borders).++.stat-strip {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));+ gap: 1px;+ background: $border-subtle;+ border: 1px solid $border-subtle;+ border-radius: $radius-lg;+ overflow: hidden;+ margin-bottom: $space-6;+}++.stat-strip__item {+ display: flex;+ flex-direction: column;+ gap: 6px;+ min-width: 0;+ padding: $space-4 $space-5;+ background: $bg-card;+}++.stat-strip__label {+ font-size: $font-size-xs;+ font-weight: $font-weight-semibold;+ letter-spacing: 0.05em;+ text-transform: uppercase;+ color: $text-secondary;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.stat-strip__value {+ display: inline-flex;+ align-items: center;+ gap: $space-2;+ font-size: $font-size-lg;+ font-weight: $font-weight-semibold;+ color: $text-primary;+ line-height: 1.2;+ font-variant-numeric: tabular-nums;+ min-width: 0;++ // long string values (URLs, versions) shouldn't blow out the segment+ > :not(.stat-strip__dot):not(.stat-strip__suffix) {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }+}++.stat-strip__suffix {+ font-size: $font-size-sm;+ font-weight: $font-weight-medium;+ color: $text-tertiary;+}++.stat-strip__detail {+ font-size: $font-size-xs;+ color: $text-tertiary;+}++// Status dot — reinforces the (already text-stated) value; never the sole signal.+.stat-strip__dot {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ flex-shrink: 0;+ background: $text-tertiary;+}++@each $state, $color in (success: $success, warning: $warning, danger: $danger, info: $info) {+ .stat-strip__item.is-#{$state} {+ .stat-strip__dot { background: $color; }+ .stat-strip__value { color: $color; }+ }+}++// Clickable segment (acts as a filter toggle)+.stat-strip__item--clickable {+ appearance: none;+ font: inherit;+ text-align: left;+ color: inherit;+ cursor: pointer;+ transition: background $transition-base;++ &:hover { background: $bg-hover; }++ &.is-active {+ background: $bg-hover;+ box-shadow: inset 3px 0 0 $accent-primary;+ }++ &:focus-visible {+ outline: 2px solid $accent-primary;+ outline-offset: -2px;+ }+}++@media (max-width: $breakpoint-sm) {+ .stat-strip {+ grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));+ }+ .stat-strip__value { font-size: $font-size-md; }+}++// Legacy stats grid layout (retained for widgets that still use raw .stat-* inner+// classes; the StatsGrid component now renders .stat-strip instead)..stats-grid {display: grid;grid-template-columns: repeat(4, 1fr);