Live toggle
The Live / Pause switch of a live page, with the time since the page last read its data.
LiveToggle is the Live / Pause switch of a page declared with live. It shows how long ago the page last read its data ("Updated 12 s ago", counted every second in the browser), and the L key switches it too. The state belongs to the page: every block and table of the page follows it, and the choice is kept per page in the browser.
LiveToggleOn a page declared without live, the toggle renders nothing. The preview page is not a live page, so the screenshot shows the toggle as it looks on one.
Usage
Place it where you want. A page with a period or live data puts it in a PageToolbar, which draws it beside the PeriodSelector at one size, the same on every page: pageToolbar() adds it as a pill. In a stack of your own:
import { HStack, Spacer } from "@antelopejs/interface-dms/base/stack";
import { LiveToggle } from "@antelopejs/interface-dms/base/live-toggle";
import { PeriodSelector } from "@antelopejs/interface-dms/base/period-selector";
static toolbar = HStack({ alignment: "center" })
.child("spacer", Spacer())
.child("live", LiveToggle({ variant: "pill", missedLabel: "$api.live.new_requests" }))
.child("period", PeriodSelector({ id: "api" }));
Options
| Option | Type | Default | Description |
|---|---|---|---|
missedLabel Content | string | – | What the paused toggle calls the missed events, given {count}. |
align Appearance | "left" | "center" | "right" | – | |
showUpdatedAt Appearance | boolean | – | Shows how long ago the page last read its data. |
variant Appearance | "segmented" | "pill" | – | |
size Appearance | "xs" | "sm" | "md" | – |
variant | Looks like |
|---|---|
segmented | Two segments, Live and Pause. The default. |
pill | A "Live" pill with a pulsing dot beside a Pause button, and a Resume button while paused. |
size (xs, sm, md) scales either variant and its texts. Unset, the toggle takes the size of the PageToolbar holding it, else sm.
While paused
Paused, the toggle says why instead of the time: "Paused · typing in the Tester · 40 new requests · 2 in 5xx". The reason is the hold a component took (or "tab hidden"), the count is the page's missed events named by missedLabel (pluralised on {count}), and the breakdown is what a custom component adds with usePageLive().setMissedDetail().
