Collection
Life / Healthcare · v0.2.1Validated
See the reported oxygen saturation and measurement time, with an optional patient profile.
Oxygen saturation · Preview
Loading widget…
Preparing source code…
Idle
Life / Healthcare · v0.2.1Validated
See the reported oxygen saturation and measurement time, with an optional patient profile.
Loading widget…
Preparing source code…
Load the Lumo theme once in your app entry point. The example uses the local Lumo workspace packages.
import "@lumo/tokens/tokens.css";
import { SpO2Widget } from "@lumo/widgets";
<SpO2Widget
spo2={97}
measuredAt="09:40 CET"
room="Room 204"
avatar={{ name: "Alex Morgan", src: "/avatars/25.webp", role: "Patient" }}
/>import "@lumo/tokens/tokens.css";
import { SpO2Demo } from "./SpO2Demo";
export default function Example() {
return <SpO2Demo />;
}Props for integrating the React component in your app.
spo2number | nullmeasuredAtstringtrace"hidden" | "illustrative"roomstringavatarVitalAvatarsimulatebooleancompactbooleanlayout"stacked" | "adaptive"tracePlacement"inset" | "inline" | "bottom"{
"spo2": 97,
"measuredAt": "09:40 CET",
"room": "Room 204",
"trace": "hidden"
}"use client";
import { useAnimationInterval } from "@lumo/hooks";
import { useState } from "react";
import { VitalWidget } from "./VitalWidget";
import { vitalBaseRate, vitalDemoInterval } from "./vital-widget.constants";
import type { VitalAvatar, VitalPresentationProps } from "./vital-widget.types";
export interface SpO2WidgetProps extends VitalPresentationProps {
spo2?: number | null;
measuredAt?: string;
/** The optional waveform is illustrative. It is hidden by default for a reported reading. */
trace?: "hidden" | "illustrative";
room?: string;
avatar?: VitalAvatar;
/** Demo only: varies the displayed saturation every 2.2 seconds. */
simulate?: boolean;
}
/** Oxygen saturation with a plethysmography waveform. */
export function SpO2Widget({ spo2, room = "Room 204", avatar, simulate = false, compact = false, tracePlacement, layout, measuredAt, trace }: SpO2WidgetProps) {
const [displaySpO2, setDisplaySpO2] = useState(97);
const demo = spo2 === undefined;
useAnimationInterval(() => setDisplaySpO2((current) => Math.max(95, Math.min(100, current + Math.round((Math.random() - .5) * 3)))), demo && simulate ? vitalDemoInterval : null);
const reading = demo ? (simulate ? displaySpO2 : 97) : spo2;
const valid = reading !== null && Number.isFinite(reading) && reading >= 0 && reading <= 100;
const showTrace = valid && (trace === "illustrative" || (demo && trace !== "hidden"));
const description = [room, demo ? "Demo" : measuredAt].filter(Boolean).join(" · ");
return <VitalWidget kind="spo2" room={room} avatar={avatar} compact={compact} tracePlacement={tracePlacement} layout={layout}
description={description} hideTrace={!showTrace} values={valid ? [reading] : []} rate={vitalBaseRate} />;
}
lucide-reactmotionreactreact-dom