SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

AutoRefresh

"Auto-refresh.

Updated
View code
tsx
<AutoRefresh
	id="runs-refresh"
	url={request.url}
	frame="run-list"
	refreshedAt={new Date()}
	options={[
		{ value: 0, label: "Off" },
		{ value: 10, label: "10s" },
		{ value: 30, label: "30s" },
		{ value: 60, label: "1m" },
		{ value: 300, label: "5m" },
	]}
	labels={{ trigger: "Auto-refresh", updated: "Updated {time}" }}
/>

Demo apps

Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.

Every demo, landings and docs sites alike, is listed in the demo gallery.

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { AutoRefresh } from "@sdxc/ui/app";

Renders the interval menu and the last-updated time. Each menu item is a link, so a choice works without script and lands in the URL; the time island does the reloading.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
idstringYesPrefix for the menu id; unique on the page.
urlURL | stringNoThe page's current URL, which holds the choice. @default "/"
namestringNoThe search parameter holding the interval. @default "refresh"
valuenumberNoThe interval in force, overriding the URL, for a choice stored in a cookie.
defaultValuenumberNoThe interval while neither value nor the URL names one. @default 0
optionsOption[]NoThe intervals offered, such as Off, 10s, 30s, 1m and 5m.
hrefFor(value: number) => stringNoWhere choosing value leads; defaults to the URL with the parameter set (removed for the default).
framestringNoThe named frame to reload; unset reloads the page through its top frame. A name not on the page reloads nothing.
refreshedAtDateNoWhen the list on screen was fetched. Defaults to the time of rendering.
localestringNoLocale for the time. Defaults to the runtime's.
timeZonestringNoTime zone the server writes the first time in. Defaults to the runtime's.
show"all" | "choices" | "status"NoWhich half to draw: "all", the interval menu and the time; "choices", the intervals as a row of links for a menu that already has a trigger; "status", the time alone, which does the reloading, so a page drawing "choices" draws "status" too.
labelsLabelsYes

Also accepts everything in Omit<TagProps<"div">, "children" | "id">.

Types

NameValuesWhat it decides
Show"all" | "choices" | "status"The halves AutoRefresh can draw; see Props.show.
@sdxc/ui

Can’t find it? Contact us