# Status page

A public status page: an overall banner computed from each component’s current state, a 90-day uptime strip per component with its uptime percentage, a legend, and recent incidents in `Card`s with severity `Badge`s and their update history. `Stack`, `Heading`, `Text` and `Link` compose the rest.

**Example: Fernhill status** (`examples/recipes/status-page.tsx`)

```tsx
'use client'

import { Badge, Body, BodySmall, Card, Heading, Link, Stack, Text } from '@blocks/design-system'
import { AlertTriangle, CheckCircle2, type LucideIcon, XCircle } from 'lucide-react'
import { useId, useState } from 'react'
import styles from './status-page.module.css'

type Status = 'operational' | 'degraded' | 'outage'

interface StatusStyle {
  label: string
  icon: LucideIcon
  text: 'success-text' | 'warning-text' | 'danger-text'
}

const statuses: Record<Status, StatusStyle> = {
  operational: { label: 'Operational', icon: CheckCircle2, text: 'success-text' },
  degraded: { label: 'Degraded performance', icon: AlertTriangle, text: 'warning-text' },
  outage: { label: 'Outage', icon: XCircle, text: 'danger-text' },
}

const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
const today = Date.UTC(2026, 11, 2)
const historyLength = 90

// Formats without Intl so the server and the browser render the same text.
function dayLabel(daysAgo: number) {
  const date = new Date(today - daysAgo * 86_400_000)
  return `${months[date.getUTCMonth()]} ${date.getUTCDate()}`
}

interface Component {
  name: string
  current: Status
  /** Days with less than full uptime, keyed by days ago. Every other day is 100%. */
  incidents: Record<number, { status: Status; uptime: number }>
}

const components: Component[] = [
  { name: 'API', current: 'operational', incidents: { 18: { status: 'outage', uptime: 97.9 }, 61: { status: 'degraded', uptime: 99.6 } } },
  { name: 'Dashboard', current: 'operational', incidents: { 18: { status: 'degraded', uptime: 99.4 } } },
  {
    name: 'Webhooks',
    current: 'degraded',
    incidents: { 0: { status: 'degraded', uptime: 99.1 }, 33: { status: 'degraded', uptime: 99.7 }, 34: { status: 'degraded', uptime: 99.8 } },
  },
  { name: 'Background jobs', current: 'operational', incidents: {} },
  { name: 'File storage', current: 'operational', incidents: { 74: { status: 'outage', uptime: 98.6 } } },
]

function historyOf(component: Component) {
  // Oldest first, so the strip reads left to right toward today.
  return Array.from({ length: historyLength }, (_, index) => {
    const daysAgo = historyLength - 1 - index
    return { daysAgo, ...(component.incidents[daysAgo] ?? { status: 'operational' as Status, uptime: 100 }) }
  })
}

interface Update {
  stage: 'Investigating' | 'Identified' | 'Monitoring' | 'Resolved'
  time: string
  label: string
  text: string
}

const incidents: { id: string; title: string; severity: 'Minor' | 'Major'; affects: string; updates: Update[] }[] = [
  {
    id: 'webhook-delays',
    title: 'Delayed webhook deliveries',
    severity: 'Minor',
    affects: 'Webhooks',
    updates: [
      {
        stage: 'Monitoring',
        time: '2026-12-02T10:52:00Z',
        label: 'Dec 2, 10:52 UTC',
        text: 'A fix is deployed and the backlog is draining. New deliveries arrive within a minute.',
      },
      {
        stage: 'Identified',
        time: '2026-12-02T09:40:00Z',
        label: 'Dec 2, 09:40 UTC',
        text: 'A queue consumer stopped acknowledging messages after a config change. We’re rolling it back.',
      },
      {
        stage: 'Investigating',
        time: '2026-12-02T09:12:00Z',
        label: 'Dec 2, 09:12 UTC',
        text: 'Some webhook deliveries are arriving up to 12 minutes late.',
      },
    ],
  },
  {
    id: 'api-errors',
    title: 'Elevated API error rates in us‑east',
    severity: 'Major',
    affects: 'API, Dashboard',
    updates: [
      {
        stage: 'Resolved',
        time: '2026-11-14T16:05:00Z',
        label: 'Nov 14, 16:05 UTC',
        text: 'Error rates are back to normal. A post-incident review will follow within five business days.',
      },
      {
        stage: 'Identified',
        time: '2026-11-14T14:31:00Z',
        label: 'Nov 14, 14:31 UTC',
        text: 'A database failover left one connection pool pointing at the old primary. About 18% of requests returned 503.',
      },
    ],
  },
]

export default function StatusPage() {
  const [hovered, setHovered] = useState<{ component: string; daysAgo: number } | null>(null)
  const id = useId()
  const affected = components.filter((component) => component.current !== 'operational')
  const overall: Status = affected.some((component) => component.current === 'outage') ? 'outage' : affected.length ? 'degraded' : 'operational'
  const OverallIcon = statuses[overall].icon

  return (
    <Stack gap="xl">
      <div className={styles.banner} data-status={overall} role="status">
        <OverallIcon aria-hidden size={20} />
        <Stack gap="xxs">
          <Text fontWeight="semibold">
            {overall === 'operational' ? 'All systems operational' : `${affected.map((component) => component.name).join(', ')}: ${statuses[overall].label.toLowerCase()}`}
          </Text>
          <BodySmall margin="none" color="text-muted">
            Updated <time dateTime="2026-12-02T10:52:00Z">Dec 2 at 10:52 UTC</time>
          </BodySmall>
        </Stack>
      </div>

      <Stack as="section" gap="md" aria-labelledby={`${id}-components`}>
        <Stack direction="row" justify="space-between" align="baseline" wrap="wrap" gap="sm">
          <Heading as="h2" id={`${id}-components`} fontSize="lg">
            Uptime
          </Heading>
          <BodySmall color="text-muted" margin="none">
            Last 90 days
          </BodySmall>
        </Stack>
        <Card as="ul" padding="none" margin="none" dangerouslySetClassName={styles.components}>
          {components.map((component) => {
            const history = historyOf(component)
            const uptime = history.reduce((total, day) => total + day.uptime, 0) / history.length
            const incidentDays = history.filter((day) => day.status !== 'operational')
            const status = statuses[component.current]
            const day = hovered?.component === component.name ? history.find((entry) => entry.daysAgo === hovered.daysAgo) : undefined
            return (
              <li key={component.name} className={styles.component}>
                <Stack direction="row" justify="space-between" align="center" wrap="wrap" gap="sm">
                  <Text fontWeight="semibold">{component.name}</Text>
                  <Text fontSize="sm" color={status.text}>
                    <span className={styles.inlineStatus}>
                      <status.icon aria-hidden size={14} />
                      {status.label}
                    </span>
                  </Text>
                </Stack>
                <div
                  className={styles.strip}
                  role="img"
                  aria-label={`${component.name}: ${uptime.toFixed(2)}% uptime over 90 days. ${
                    incidentDays.length
                      ? incidentDays.map((entry) => `${dayLabel(entry.daysAgo)}, ${statuses[entry.status].label.toLowerCase()}, ${entry.uptime}%`).join('; ')
                      : 'No incidents'
                  }.`}
                  onPointerLeave={() => setHovered(null)}
                >
                  {history.map((entry) => (
                    <span
                      key={entry.daysAgo}
                      className={styles.day}
                      data-status={entry.status}
                      data-active={entry === day || undefined}
                      onPointerEnter={() => setHovered({ component: component.name, daysAgo: entry.daysAgo })}
                    />
                  ))}
                </div>
                <div className={styles.axis} aria-hidden>
                  <span>90 days ago</span>
                  <span className={styles.readout}>
                    {day ? `${dayLabel(day.daysAgo)} · ${day.uptime}% · ${statuses[day.status].label}` : `${uptime.toFixed(2)}% uptime`}
                  </span>
                  <span>Today</span>
                </div>
              </li>
            )
          })}
        </Card>
        <Stack as="ul" direction="row" gap="md" wrap="wrap" margin="none" padding="none" aria-label="Legend" dangerouslySetClassName={styles.legend}>
          {(Object.keys(statuses) as Status[]).map((key) => (
            <li key={key}>
              <span className={styles.swatch} data-status={key} aria-hidden />
              {statuses[key].label}
            </li>
          ))}
        </Stack>
      </Stack>

      <Stack as="section" gap="md" aria-labelledby={`${id}-incidents`}>
        <Heading as="h2" id={`${id}-incidents`} fontSize="lg">
          Recent incidents
        </Heading>
        {incidents.map((incident) => {
          const resolved = incident.updates[0]?.stage === 'Resolved'
          return (
            <Card as="article" key={incident.id} padding="lg" aria-labelledby={`${id}-${incident.id}`}>
              <Stack gap="md">
                <Stack gap="xs">
                  <Stack direction="row" gap="sm" align="center" wrap="wrap">
                    <Heading as="h3" id={`${id}-${incident.id}`} fontSize="md">
                      <Link href={`#incident-${incident.id}`}>{incident.title}</Link>
                    </Heading>
                    <Badge tone={incident.severity === 'Major' ? 'danger' : 'warning'}>{incident.severity}</Badge>
                    <Badge tone={resolved ? 'success' : 'info'}>{resolved ? 'Resolved' : 'Ongoing'}</Badge>
                  </Stack>
                  <BodySmall color="text-muted" margin="none">
                    Affects {incident.affects}
                  </BodySmall>
                </Stack>
                <ol className={styles.updates}>
                  {incident.updates.map((update) => (
                    <li key={update.time} className={styles.update}>
                      <Stack direction="row" gap="sm" align="baseline" wrap="wrap">
                        <Text fontSize="sm" fontWeight="semibold">
                          {update.stage}
                        </Text>
                        <Text fontSize="xs" color="text-muted">
                          <time dateTime={update.time}>{update.label}</time>
                        </Text>
                      </Stack>
                      <Body margin="none" fontSize="sm">
                        {update.text}
                      </Body>
                    </li>
                  ))}
                </ol>
              </Stack>
            </Card>
          )
        })}
      </Stack>
    </Stack>
  )
}
```

## How it works

- **State is never color alone.** The banner, each component’s status and the legend all pair a status color with an icon and words. The banner’s tone and text come from the same component data as the rows below it.
- **Each strip is one image with a full description.** Ninety focusable bars would be ninety tab stops, so the strip is a single `role="img"` whose label gives the uptime and lists every day that wasn’t fully operational. Pointer users can hover any day to read its date, uptime and state under the strip.
- **It fits any width.** The bars share the row with `flex: 1`, so the strip shrinks from a desktop column to a phone without scrolling.
- **Incidents read newest first.** Each update is a list item with its stage, a `<time>` and the message; the latest update gets the accent rule.

## App-owned CSS

The banner tints, uptime bars, legend swatches and update timeline.

`examples/recipes/status-page.module.css`:

```css
/* The overall state: tinted by status, with an icon and words that say the same thing. */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-md);
  padding: var(--ds-space-lg);
  border: var(--ds-border-width-sm) solid transparent;
  border-radius: var(--ds-border-radius-md);

  & > svg {
    flex-shrink: 0;
    margin-top: var(--ds-space-xxs);
  }

  &[data-status="operational"] {
    border-color: color-mix(in srgb, var(--ds-color-success) 30%, transparent);
    background-color: var(--ds-color-success-subtle);
    color: var(--ds-color-success-text);
  }

  &[data-status="degraded"] {
    border-color: color-mix(in srgb, var(--ds-color-warning) 40%, transparent);
    background-color: var(--ds-color-warning-subtle);
    color: var(--ds-color-warning-text);
  }

  &[data-status="outage"] {
    border-color: color-mix(in srgb, var(--ds-color-danger) 30%, transparent);
    background-color: var(--ds-color-danger-subtle);
    color: var(--ds-color-danger-text);
  }
}

.components {
  list-style: none;
}

.component {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-md);
  padding: var(--ds-space-lg);

  & + & {
    border-top: var(--ds-border-width-sm) solid var(--ds-color-border-subtle);
  }
}

.inlineStatus {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-sm);
}

/* Ninety thin bars; each stretches to share the row, so the strip fits any width. */
.strip {
  display: flex;
  gap: var(--ds-space-xxs);
  height: var(--ds-space-xl);
}

.day {
  flex: 1;
  min-width: 0;
  border-radius: var(--ds-border-radius-pill);
  transition: opacity var(--ds-duration-fast) var(--ds-easing-standard);
}

.day,
.swatch {
  &[data-status="operational"] {
    background-color: var(--ds-color-success);
  }

  &[data-status="degraded"] {
    background-color: var(--ds-color-warning);
  }

  &[data-status="outage"] {
    background-color: var(--ds-color-danger);
  }
}

.strip:hover .day:not([data-active]) {
  opacity: 0.5;
}

.axis {
  display: flex;
  justify-content: space-between;
  gap: var(--ds-space-md);
  font-size: var(--ds-font-size-xs);
  color: var(--ds-color-text-muted);
  white-space: nowrap;
}

.readout {
  overflow: hidden;
  color: var(--ds-color-text);
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.legend {
  list-style: none;
  font-size: var(--ds-font-size-xs);
  color: var(--ds-color-text-muted);

  & li {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-space-sm);
    white-space: nowrap;
  }
}

.swatch {
  width: var(--ds-space-md);
  height: var(--ds-space-md);
  border-radius: var(--ds-border-radius-sm);
}

/* Incident updates: newest first, joined by a thin rule. */
.updates {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-lg);
  margin: 0;
  padding: 0;
  list-style: none;
}

.update {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-xs);
  padding-left: var(--ds-space-lg);
  border-left: var(--ds-border-width-md) solid var(--ds-color-border-subtle);

  &:first-child {
    border-left-color: var(--ds-color-accent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .day {
    transition: none;
  }
}
```
