Files
ServerKit/frontend/src/components/StatusBadge.jsx
T
Juan DenisandClaude Opus 4.8 9bd757fa0f feat(ui): label connection status + fix status-badge dot, document text tokens
- Dashboard connection state is no longer color-alone: the green/amber dot
  now pairs with a text label (LIVE / RECONNECTING) in the server readout
  and is announced via role="status". Label uses a readable neutral
  (contrast-safe in both themes); the dot carries the status color.
  Removes the orphaned .status-dot-live rules.
- StatusBadge: destructive status dot was bg-white (off-pattern); now
  bg-red-400 to match the semantic hue of the other status dots.
- _variables.scss: document that the $text-*-raw values feed compile-time
  fade() washes (neutral zinc ramp) and are intentionally distinct from the
  lightened runtime --text-* tokens, so the split reads as deliberate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 00:12:23 -04:00

45 lines
1.5 KiB
React

import { Badge } from '@/components/ui/badge';
import { cn } from '@/lib/utils';
const STATUS_VARIANT = {
online: 'success', running: 'success', healthy: 'success',
active: 'success', connected: 'success',
offline: 'destructive', stopped: 'destructive', error: 'destructive',
failed: 'destructive', disconnected: 'destructive',
warning: 'warning', degraded: 'warning',
pending: 'info', building: 'info', deploying: 'info',
paused: 'secondary', unknown: 'secondary',
};
const DOT_COLOR = {
success: 'bg-green-400',
destructive: 'bg-red-400',
warning: 'bg-yellow-400',
info: 'bg-blue-400',
secondary: 'bg-muted-foreground/60',
};
const STATUS_LABEL = {
online: 'Online', running: 'Running', healthy: 'Healthy',
active: 'Active', connected: 'Connected',
offline: 'Offline', stopped: 'Stopped', error: 'Error',
failed: 'Failed', disconnected: 'Disconnected',
warning: 'Warning', degraded: 'Degraded',
pending: 'Pending', building: 'Building', deploying: 'Deploying',
paused: 'Paused', unknown: 'Unknown',
};
export default function StatusBadge({ status, label, className = '' }) {
const key = status?.toLowerCase();
const variant = STATUS_VARIANT[key] || 'secondary';
const dotColor = DOT_COLOR[variant] || DOT_COLOR.secondary;
const displayLabel = label || STATUS_LABEL[key] || status;
return (
<Badge variant={variant} className={cn('status-badge-token', className)}>
<span className={cn('size-1.5 rounded-full shrink-0', dotColor)} />
{displayLabel}
</Badge>
);
}