Notification routing
Choose where alerts go and test how routine and priority messages behave during quiet hours.
Installation
Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/notification-rules.json
Usage
import { Cyber } from "@/components/ui/cyber"
import Recipe from "@/components/recipes/notification-rules"
export default function App() {
return (
<Cyber>
<Recipe />
</Cyber>
)
}
Source
"use client"
import { useState } from "react"
import { Badge } from "@/components/ui/badge"
import { Checkbox, CheckboxGroup } from "@/components/ui/checkbox"
import { Select } from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
import "./recipe-layout.css"
const events = [
{ value: "handoff", label: "Handoff reminder", priority: false },
{ value: "closure", label: "Station closure", priority: true },
]
export default function NotificationRules() {
const [destinations, setDestinations] = useState<string[]>(["Desk"])
const [quiet, setQuiet] = useState(true)
const [eventId, setEventId] = useState("handoff")
const event = events.find(item => item.value === eventId)!
const held = quiet && !event.priority
let outcome = `Delivered to ${destinations.join(" and ")}.`
if (!destinations.length) outcome = "No destinations selected."
else if (held) outcome = "Held until quiet hours end."
return (
<div className="sink-stack">
<CheckboxGroup label="Alert destinations" value={destinations} onValueChange={setDestinations}>
<Checkbox value="Desk" label="Desk" />
<Checkbox value="Wrist relay" label="Wrist relay" />
</CheckboxGroup>
<Switch label="Quiet hours" checked={quiet} onCheckedChange={setQuiet} />
<Select label="Test notification" value={eventId} options={events}
onValueChange={value => { if (value) setEventId(value) }} />
<div className="sink-row" role="status">
<Badge tone={event.priority ? "flag" : "mute"}>{event.priority ? "Priority" : "Routine"}</Badge>
<span>{outcome}</span>
</div>
</div>
)
}
Components in this recipe
- Checkbox — A cut box that fills and marks when checked, with an indeterminate state.
- Switch — A block that slides across a cut track and lights, with its state printed beside it.
- Select — A labelled trigger that opens a list of options to choose from.
- Badge — A small cut label in seven tones, with count and status variants.