{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "incident-status-banner",
  "title": "Incident Status Banner",
  "description": "A calm site-wide status bar: a live dot, a clear severity, the latest update time, and a timeline that opens over the page without moving it.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/incident-status-banner/incident-status-banner.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type IncidentLevel =\n  \"operational\" | \"maintenance\" | \"degraded\" | \"outage\";\n\nexport interface IncidentUpdate {\n  /** Short time, e.g. \"14:02\". */\n  time: string;\n  /** Short state, e.g. \"Monitoring\". */\n  state: string;\n  text: string;\n}\n\nexport interface IncidentStatusBannerProps extends Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  level?: IncidentLevel;\n  title?: string;\n  /** Newest first. The panel opens from the banner, over the page. */\n  updates?: IncidentUpdate[];\n  /** Link to your full status page. */\n  statusUrl?: string;\n  dismissible?: boolean;\n  onDismiss?: () => void;\n}\n\nconst PALETTES = {\n  dark: {\n    bar: \"#0F1011\",\n    surface: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.06)\",\n    btn: \"#E5E5E6\",\n    btnText: \"#08090A\",\n    accent: \"#5E6AD2\",\n    shadow: \"0 8px 32px rgba(0,0,0,0.45)\",\n  },\n  light: {\n    bar: \"#FFFFFF\",\n    surface: \"#FFFFFF\",\n    border: \"rgba(8,9,10,0.1)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.05)\",\n    btn: \"#08090A\",\n    btnText: \"#F7F8F8\",\n    accent: \"#5E6AD2\",\n    shadow: \"0 8px 28px rgba(8,9,10,0.12)\",\n  },\n};\n\ntype Palette = (typeof PALETTES)[\"dark\"];\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction CloseButton({\n  label,\n  pal,\n  onClick,\n}: {\n  label: string;\n  pal: Palette;\n  onClick: () => void;\n}) {\n  return (\n    <button\n      type=\"button\"\n      aria-label={label}\n      onClick={onClick}\n      className=\"grid size-7 shrink-0 cursor-pointer place-items-center rounded-full transition-colors outline-none hover:bg-[var(--chip)] focus-visible:ring-2\"\n      style={{ \"--chip\": pal.chip, color: pal.sub } as React.CSSProperties}\n    >\n      <svg\n        width=\"10\"\n        height=\"10\"\n        viewBox=\"0 0 10 10\"\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.6\"\n        strokeLinecap=\"round\"\n        aria-hidden=\"true\"\n      >\n        <path d=\"m1 1 8 8M9 1 1 9\" />\n      </svg>\n    </button>\n  );\n}\n\n/** Folds its content away when closed, so a dismissed bar doesn't leave a gap. */\nfunction Collapse({\n  open,\n  onGone,\n  children,\n}: {\n  open: boolean;\n  onGone?: () => void;\n  children: React.ReactNode;\n}) {\n  return (\n    <div\n      className=\"grid motion-safe:transition-[grid-template-rows,opacity] motion-safe:duration-300\"\n      style={{ gridTemplateRows: open ? \"1fr\" : \"0fr\", opacity: open ? 1 : 0 }}\n      onTransitionEnd={(e) => {\n        if (!open && e.propertyName === \"grid-template-rows\") onGone?.();\n      }}\n    >\n      <div className=\"min-h-0 overflow-hidden\">{children}</div>\n    </div>\n  );\n}\n\nconst LEVELS: Record<\n  IncidentLevel,\n  { color: string; name: string; live: boolean }\n> = {\n  operational: { color: \"#27A644\", name: \"All systems normal\", live: false },\n  maintenance: { color: \"#4EA7FC\", name: \"Maintenance\", live: true },\n  degraded: { color: \"#F0BF00\", name: \"Degraded\", live: true },\n  outage: { color: \"#EB5757\", name: \"Outage\", live: true },\n};\n\nconst UPDATES: IncidentUpdate[] = [\n  {\n    time: \"14:32\",\n    state: \"Monitoring\",\n    text: \"A fix is live and sync times are back to normal. We are watching it.\",\n  },\n  {\n    time: \"14:05\",\n    state: \"Identified\",\n    text: \"A full queue in one region is delaying sync by up to two minutes.\",\n  },\n  {\n    time: \"13:48\",\n    state: \"Investigating\",\n    text: \"We are looking into slow sync for some workspaces.\",\n  },\n];\n\nexport function IncidentStatusBanner({\n  theme = \"dark\",\n  level = \"degraded\",\n  title = \"Sync is running slowly for some workspaces\",\n  updates = UPDATES,\n  statusUrl = \"#\",\n  dismissible = true,\n  onDismiss,\n  className,\n  style,\n  ...props\n}: IncidentStatusBannerProps) {\n  const pal = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const info = LEVELS[level];\n  const panelId = React.useId();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const pulseRef = React.useRef<HTMLSpanElement>(null);\n  const [open, setOpen] = React.useState(true);\n  const [details, setDetails] = React.useState(false);\n\n  React.useEffect(() => {\n    if (reduce || !info.live) return;\n    const run = pulseRef.current?.animate(\n      [\n        { transform: \"scale(1)\", opacity: 0.55 },\n        { transform: \"scale(2.6)\", opacity: 0 },\n      ],\n      { duration: 2000, iterations: Infinity, easing: \"ease-out\" },\n    );\n    return () => run?.cancel();\n  }, [reduce, info.live]);\n\n  // The panel closes on Escape or a click anywhere else.\n  React.useEffect(() => {\n    if (!details) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") setDetails(false);\n    };\n    const onDown = (e: PointerEvent) => {\n      if (!rootRef.current?.contains(e.target as Node)) setDetails(false);\n    };\n    window.addEventListener(\"keydown\", onKey);\n    window.addEventListener(\"pointerdown\", onDown);\n    return () => {\n      window.removeEventListener(\"keydown\", onKey);\n      window.removeEventListener(\"pointerdown\", onDown);\n    };\n  }, [details]);\n\n  return (\n    <div ref={rootRef} className=\"relative z-20 w-full\">\n      <Collapse open={open} onGone={onDismiss}>\n        <div\n          role=\"status\"\n          className={`flex w-full flex-wrap items-center gap-x-3 gap-y-1.5 px-4 py-2.5 ${className ?? \"\"}`}\n          style={{\n            background: pal.bar,\n            boxShadow: `inset 0 -1px 0 ${pal.border}`,\n            color: pal.text,\n            fontFamily: FONT,\n            ...style,\n          }}\n          {...props}\n        >\n          <span\n            aria-hidden=\"true\"\n            className=\"relative grid size-2.5 shrink-0 place-items-center\"\n          >\n            <span\n              ref={pulseRef}\n              className=\"absolute inset-0 rounded-full\"\n              style={{ background: info.color, opacity: 0 }}\n            />\n            <span\n              className=\"relative size-2 rounded-full\"\n              style={{ background: info.color }}\n            />\n          </span>\n          <span\n            className=\"shrink-0 text-[13px] font-[590] tracking-[-0.011em]\"\n            style={{ color: info.color }}\n          >\n            {info.name}\n          </span>\n          <p\n            className=\"m-0 min-w-0 flex-1 basis-48 truncate text-[13px] tracking-[-0.011em]\"\n            style={{ color: pal.soft }}\n          >\n            {title}\n          </p>\n          {updates.length > 0 && (\n            <button\n              type=\"button\"\n              aria-expanded={details}\n              aria-controls={panelId}\n              onClick={() => setDetails((d) => !d)}\n              className=\"flex h-7 shrink-0 cursor-pointer items-center gap-1.5 rounded-full px-3 text-[12px] font-[510] outline-none focus-visible:ring-2\"\n              style={{ background: pal.chip, color: pal.soft }}\n            >\n              Updated {updates[0].time}\n              <svg\n                width=\"8\"\n                height=\"8\"\n                viewBox=\"0 0 8 8\"\n                fill=\"none\"\n                stroke=\"currentColor\"\n                strokeWidth=\"1.5\"\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n                aria-hidden=\"true\"\n                className=\"motion-safe:transition-transform motion-safe:duration-200\"\n                style={{ transform: details ? \"rotate(180deg)\" : \"none\" }}\n              >\n                <path d=\"m1 2.5 3 3 3-3\" />\n              </svg>\n            </button>\n          )}\n          {dismissible && (\n            <CloseButton\n              label=\"Dismiss\"\n              pal={pal}\n              onClick={() => {\n                setDetails(false);\n                setOpen(false);\n              }}\n            />\n          )}\n        </div>\n      </Collapse>\n\n      {/* Laid over the page, so opening it never pushes anything down. */}\n      <div\n        id={panelId}\n        hidden={!details}\n        className=\"absolute top-full right-4 mt-2 w-[min(420px,calc(100%-32px))] rounded-xl p-4\"\n        style={{\n          background: pal.surface,\n          boxShadow: `inset 0 0 0 1px ${pal.border}, ${pal.shadow}`,\n          color: pal.text,\n          fontFamily: FONT,\n        }}\n      >\n        <ol className=\"m-0 flex list-none flex-col gap-3 p-0\">\n          {updates.map((u, i) => (\n            <li key={u.time} className=\"flex gap-3\">\n              <span\n                className=\"w-10 shrink-0 pt-px text-[12px] tabular-nums\"\n                style={{ color: pal.faint }}\n              >\n                {u.time}\n              </span>\n              <span className=\"min-w-0\">\n                <span\n                  className=\"block text-[13px] font-[510] tracking-[-0.011em]\"\n                  style={{ color: i === 0 ? pal.text : pal.soft }}\n                >\n                  {u.state}\n                </span>\n                <span\n                  className=\"mt-0.5 block text-[13px] leading-snug tracking-[-0.011em]\"\n                  style={{ color: pal.sub }}\n                >\n                  {u.text}\n                </span>\n              </span>\n            </li>\n          ))}\n        </ol>\n        <a\n          href={statusUrl}\n          className=\"mt-3 inline-block text-[13px] font-[510] no-underline hover:underline\"\n          style={{ color: pal.soft }}\n        >\n          Open status page\n        </a>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}