SPB Git forge

spb/market-atlas

Public
12commits 1branches 0releases
1.1 MBsize
maindefault branch
10 days agolast push
TypeScript 96.7% SQL 1.6% CSS 0.8% JavaScript 0.5%
3.0 KB · 69 lines tsx
Raw Blame History
1import { cx, STATUS_LABEL } from "@/lib/format";23const TONE: Record<string, string> = {4  REALTIME: "bg-positive-soft text-positive",5  DELAYED: "bg-warning-soft text-warning",6  END_OF_DAY: "bg-surface-3 text-ink-2",7  AT_CLOSE: "bg-surface-3 text-ink-2",8  INDICATIVE: "bg-surface-3 text-ink-2",9  STALE: "bg-stale-soft text-stale",10  WITHHELD: "bg-stale-soft text-stale",11  UNKNOWN: "bg-stale-soft text-stale",12  // connector / market states13  HEALTHY: "bg-positive-soft text-positive",14  DEGRADED: "bg-warning-soft text-warning",15  RECONNECTING: "bg-warning-soft text-warning",16  STARTING: "bg-warning-soft text-warning",17  FAILED: "bg-negative-soft text-negative",18  PAUSED: "bg-stale-soft text-stale",19  DISABLED: "bg-stale-soft text-stale",20  NONE: "bg-stale-soft text-stale",21  OPEN: "bg-positive-soft text-positive",22  PRE: "bg-warning-soft text-warning",23  POST: "bg-warning-soft text-warning",24  AUCTION: "bg-warning-soft text-warning",25  HALTED: "bg-negative-soft text-negative",26  CLOSED: "bg-surface-3 text-ink-2",27  operational: "bg-positive-soft text-positive",28  degraded: "bg-warning-soft text-warning",29  outage: "bg-negative-soft text-negative",30  unknown: "bg-stale-soft text-stale",31  // severities32  INFO: "bg-surface-3 text-ink-2",33  NOTICE: "bg-accent-soft text-accent",34  WARNING: "bg-warning-soft text-warning",35  CRITICAL: "bg-negative-soft text-negative",36  DEBUG: "bg-stale-soft text-stale",37};3839export function StatusBadge({ status, label, className, dot }: { status: string | null | undefined; label?: string; className?: string; dot?: boolean }) {40  const s = status ?? "UNKNOWN";41  const text = label ?? STATUS_LABEL[s] ?? s.replace(/_/g, " ").toLowerCase();42  return (43    <span className={cx("inline-flex h-5 items-center gap-1 whitespace-nowrap rounded-[3px] px-1.5 text-[10.5px] font-medium uppercase tracking-wide", TONE[s] ?? "bg-surface-3 text-ink-2", className)}>44      {dot && <span className={cx("inline-block h-1.5 w-1.5 rounded-full bg-current", s === "REALTIME" && "live-dot")} />}45      {text}46    </span>47  );48}4950/** Rights classification chip with a plain-language label. */51export const RIGHTS_LABEL: Record<string, string> = {52  PUBLIC_OPEN: "Public",53  PUBLIC_ATTRIBUTED: "Public · attribution",54  PUBLIC_RESTRICTED_REDISTRIBUTION: "Restricted redistribution",55  OFFICIAL_OPEN_DATA: "Official open data",56  LICENSED: "Licensed",57  DELAYED: "Delayed · attribution",58  INDICATIVE: "Indicative",59  RESEARCH_ONLY: "Research only",60  INTERNAL_ONLY: "Internal only",61  UNKNOWN: "Unknown",62  DISABLED: "Disabled",63};6465export function RightsBadge({ status, className }: { status: string; className?: string }) {66  const restricted = ["PUBLIC_RESTRICTED_REDISTRIBUTION", "RESEARCH_ONLY", "INTERNAL_ONLY", "UNKNOWN", "DISABLED"].includes(status);67  return <span className={cx("inline-flex h-5 items-center whitespace-nowrap rounded-[3px] px-1.5 text-[10.5px] font-medium", restricted ? "bg-stale-soft text-stale" : status === "OFFICIAL_OPEN_DATA" ? "bg-accent-soft text-accent" : "bg-surface-3 text-ink-2", className)}>{RIGHTS_LABEL[status] ?? status}</span>;68}69