Files
app/frontend/src/components/Dashboard/icons.ts
T
stroblme d2464d4d28 Add a player widget, and let a slider be drawn as a fader
The player is the one tile that both reads and publishes, so it has two
bindings: it shows a `record` describing what is playing — title, artist,
album, status, and position and duration in seconds — and publishes transport
words back to one `str` message (`toggle`, `next`, `prev`, `seek:<seconds>`).
Those are a streamer's own vocabulary rather than this app's, which is what
lets one tile drive whatever is on the other end.

The position counts forward in the browser between readings, so the bar moves
at one second while the device behind it is polled at whatever rate suits it;
every reading that arrives is taken as the truth and the count restarts there.
That is also why this is one record rather than five messages — a tile drawn
from five would redraw itself five times, and show a new title against the old
duration in between.

Being both is why `INPUT_WIDGETS` does not gain it: what that set means is "the
message this widget publishes is its only binding", which is exactly what a
player is not. Its reading is checked the usual way and its `target` separately.

The fader beside it needed nothing new. `ui/core` has had `orientation` on the
slider all along and all three looks draw it; only the widget never passed it,
so a volume control — the one thing reached for without looking, where up is
louder — could not be a column. Now it can, and the tile's height is the track.
2026-08-30 14:17:16 +02:00

97 lines
2.1 KiB
TypeScript

import {
ArrowDown,
ArrowUp,
BatteryCharging,
Bed,
Check,
CircleCheck,
CloudDrizzle,
CloudFog,
CloudLightning,
CloudRain,
CloudSnow,
Cloudy,
DoorOpen,
Droplets,
Fan,
Flame,
House,
Lightbulb,
type LucideIcon,
Moon,
Music,
Plug,
Snowflake,
Sun,
SunSnow,
Thermometer,
ThermometerSun,
TriangleAlert,
Umbrella,
Volume2,
VolumeX,
Wind,
Zap,
} from "lucide-react"
/**
* The icons a tile may be drawn with, by name.
*
* Curated rather than lucide's `dynamicIconImports`: the panel has to offer
* these in a list, and the dynamic map makes the bundler emit a lazy chunk per
* icon — some fifteen hundred of them — so a wall panel would fetch one request
* per tile over its LAN before it could draw anything. A few dozen weather,
* room and status glyphs cover what a dashboard says, and the map is cheap to
* extend.
*/
export const ICONS: Record<string, LucideIcon> = {
sun: Sun,
moon: Moon,
cloudy: Cloudy,
"cloud-rain": CloudRain,
"cloud-drizzle": CloudDrizzle,
"cloud-snow": CloudSnow,
"cloud-lightning": CloudLightning,
"cloud-fog": CloudFog,
wind: Wind,
umbrella: Umbrella,
snowflake: Snowflake,
droplets: Droplets,
thermometer: Thermometer,
"thermometer-sun": ThermometerSun,
flame: Flame,
fan: Fan,
"sun-snow": SunSnow,
"door-open": DoorOpen,
house: House,
bed: Bed,
lightbulb: Lightbulb,
plug: Plug,
music: Music,
"volume-2": Volume2,
"volume-x": VolumeX,
zap: Zap,
"battery-charging": BatteryCharging,
"arrow-up": ArrowUp,
"arrow-down": ArrowDown,
"triangle-alert": TriangleAlert,
check: Check,
"circle-check": CircleCheck,
}
export const ICON_NAMES = Object.keys(ICONS)
/**
* What an icon may be tinted, by name.
*
* Literal classes so Tailwind's scanner sees them. No terracotta: that is the
* one affordance a view gets, and a panel is many tiles.
*/
export const ICON_COLORS: Record<string, string> = {
default: "text-foreground",
muted: "text-muted-foreground",
primary: "text-primary",
success: "text-status-success",
danger: "text-destructive",
}