Set a status that clears itself, go away, pause notifications, and a person's card with their local time.
Availability
Pause notifications
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { StatusPicker, UserStatus } from "./ui/uicontext/components/kit/Presence.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius, space } from "./ui/uicontext/components/tokens.stylex.ts"import { now } from "./chat.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 24rem)", padding: space.lg, borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg, backgroundColor: color.panel },})const Message = UiSchema.TaggedEnum({ SetStatus: { status: Schema.NullOr(UserStatus) }, SetAway: { away: Schema.Boolean }, Paused: { until: Schema.NullOr(Schema.String) },})// Pick a suggestion or write your own, choose when it clears, go away, or pause notificationsexport const MyStatus = Html.component({ name: "MyStatus", model: Schema.Struct({ status: Schema.NullOr(UserStatus), away: Schema.Boolean, pausedUntil: Schema.NullOr(Schema.String) }), message: Message,}).make({ init: () => ({ status: null, away: false, pausedUntil: null }), update: { SetStatus: ($, { status }) => $.evolve({ status }), SetAway: ($, { away }) => $.evolve({ away }), Paused: ($, { until }) => $.evolve({ pausedUntil: until }), }, view: (h, model) => h.div.attrs(sx(styles.frame)).children(StatusPicker(h, { props: { status: model.status, away: model.away, pausedUntil: model.pausedUntil, now, timeZone: "America/Los_Angeles" }, onEmit: { RequestedStatus: ({ emoji, text, until }) => Message.SetStatus({ status: { emoji, text, ...(until === undefined ? {} : { until }) } }), RequestedClearStatus: () => Message.SetStatus({ status: null }), RequestedAway: ({ away }) => Message.SetAway({ away }), RequestedPause: ({ until }) => Message.Paused({ until }), }, })),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/presenceUsage
import { StatusPicker, type UserStatus } from "./ui/uicontext/components/kit/Presence.ts"const Message = UiSchema.TaggedEnum({ SetStatus: { emoji: Schema.String, text: Schema.String, until: Schema.optional(Schema.String) }, ClearedStatus: {}, SetAway: { away: Schema.Boolean }, Paused: { until: Schema.NullOr(Schema.String) },})// `until` is worked out from the reader's "Clear after" choice and `now`export const Status = (h: Html.H<typeof Message.Type>, status: UserStatus | null, away: boolean, pausedUntil: string | null, now: string) => StatusPicker(h, { props: { status, away, pausedUntil, now }, onEmit: { RequestedStatus: (status) => Message.SetStatus(status), RequestedClearStatus: () => Message.ClearedStatus(), RequestedAway: ({ away }) => Message.SetAway({ away }), RequestedPause: ({ until }) => Message.Paused({ until }), }, })Examples
Profile card
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { ProfileCard } from "./ui/uicontext/components/kit/Presence.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius, shadow, space } from "./ui/uicontext/components/tokens.stylex.ts"import { now } from "./chat.ts"const styles = stylex.create({ row: { display: "flex", flexWrap: "wrap", gap: space.lg }, card: { borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg, backgroundColor: color.overlay, boxShadow: shadow.md },})// What opens on a name: presence, title, a status that clears itself, and the time where they areexport const ProfileCards = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.row)).children( h.div.attrs(sx(styles.card)).children(ProfileCard(h, { person: { id: "ben", name: "Ben Okafor", title: "Platform engineer" }, presence: "active", status: { emoji: "📍", text: "Lisbon (UTC+0)" }, timeZone: "Europe/Lisbon", now, message: "#dm-ben", })), h.div.attrs(sx(styles.card)).children(ProfileCard(h, { person: { id: "max", name: "Maximiliana Alexandra Featherstonehaugh-Worthington", title: "Principal staff engineer, platform reliability (EMEA)" }, presence: "dnd", status: { emoji: "🎧", text: "Heads down on the billing ledger", until: "2026-12-01T17:00:00Z" }, timeZone: "Pacific/Chatham", now, message: "#dm-max", })), )API reference
StatusPickerComponent
Props
| Name | Type | Description |
|---|---|---|
statusrequired | UserStatus | null | The reader's status now, or null |
awayrequired | boolean | The reader set themselves away |
pausedUntilrequired | string | null | Notifications are paused until this time (ISO), or null |
nowrequired | string | The time now (ISO), for "until 3:30 PM" |
timeZone | string | — |
agentId | string | — |
Events
| Event | Payload | Description |
|---|---|---|
RequestedStatus | { emoji: string; text: string; until?: string } | Set the reader's status; until is when it clears, worked out from their choice |
RequestedClearStatus | {} | — |
RequestedAway | { away: boolean } | Show the reader as away (or active again) |
RequestedPause | { until: string | null } | Pause notifications until until (ISO), or resume them (null) |
Agent actions
| Action | Description |
|---|---|
ClickedPreset | Fill in a status: emoji, text and when it clears (never, 30m, 1h, 4h, today, week) |
SubmittedStatus | Save the status being written |
ClickedClear | Clear the reader's status |
ClickedPause | Pause notifications: 30m, 1h, 2h or tomorrow |
ProfileCardView function
Options
| Name | Type | Description |
|---|---|---|
personrequired | { readonly id: string; readonly name: string; readonly title?: string | undefined; readonly agent?: boolean | undefined } | — |
presence | "active" | "away" | "dnd" | "offline" | — |
status | UserStatus | null | — |
timeZone | string | The person's time zone (IANA): the card shows their local time |
nowrequired | string | The time now, ISO |
message | string | A printed route to their DM |
call | ((button: ButtonBuilder<Message>) => ButtonBuilder<Message>) | Binds the Call button's press; no button without it |
extra | View.Input | — |
Accessibility
- The status form names its field and its Clear after select; suggestions are buttons. Away is a toggle button, and paused notifications are announced with when they resume.
- A profile card names the person and reads their presence, status and local time as text; Message is a link and Call a button.