Rework the dashboard into two looks over one behaviour
A dashboard is a wall panel somebody hangs in their own hallway, so it now wears what they choose: a look, and a palette of their own colours. Two complete component sets live under `Dashboard/ui/` — `glass` (translucent panes over a slowly moving ground) and `material` (Material 3 tonal cards) — behind one prop contract. Every control's state, keyboard and `aria-` live in `ui/core` and are shared, so the two sets are the same dashboard drawn twice rather than two products: a set only decides what a control looks like while doing it. Four settings join the channel, each drivable by a flow like any other: `look`, `palette`, `background` and `touch`. A palette is an ordered list of hex colours — background, surface, primary, accent, text, then more chart colours — pasted from a coolors.co link or typed, written onto the canvas as the token variables everything already reads. Trailing roles are derived, so three colours are a whole dashboard, and derived text is held to AA rather than trusted (`theme.check.ts` measures it). A palette also decides light or dark, since its first colour is the ground. Widgets are measured against their own tile with container queries rather than against the viewport, animate through `motion`, and can be drawn without their title. The three reworks: - a bar draws a row per reading, up to eight, each in the dashboard's own data colours and each able to carry its own scale — replacing readings nested in one fill, which could only ever share one colour and stop at three. Documents written the old way are read as rows. - a chart's range picker moved to a column down its right-hand edge, which gives the plot back a whole row of a short tile. - the colour wheel became a disc: hue is the angle and saturation the distance from the middle, so a colour is one gesture rather than three, with brightness on a slider beside it. `index.css` and `lib/motion.ts` are untouched — the dashboard overrides token *values* on its canvas, never the blocks the two repos share.
This commit is contained in:
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* Liquid glass: the controls.
|
||||
*
|
||||
* A press is answered by the light moving — a soft glow that follows the
|
||||
* pointer across the surface — and by the control giving very slightly. Every
|
||||
* one of these is a `ui/core` hook in a different coat.
|
||||
*/
|
||||
import * as SelectPrimitive from "@radix-ui/react-select"
|
||||
import { Check, ChevronDown } from "lucide-react"
|
||||
import { motion } from "motion/react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { asOriginal, text } from "../core/config"
|
||||
import type {
|
||||
ButtonProps,
|
||||
InputProps,
|
||||
SegmentedProps,
|
||||
SelectProps,
|
||||
SliderProps,
|
||||
SwitchProps,
|
||||
} from "../core/contract"
|
||||
import {
|
||||
usePress,
|
||||
useSegmented,
|
||||
useSliderDrag,
|
||||
useSwitch,
|
||||
} from "../core/controls"
|
||||
import { useLook } from "../core/look"
|
||||
import { LOOK } from "../core/motion"
|
||||
|
||||
export function Button({
|
||||
variant = "tonal",
|
||||
pressed,
|
||||
disabled,
|
||||
label,
|
||||
onClick,
|
||||
children,
|
||||
}: ButtonProps) {
|
||||
const { onPointerDown } = usePress()
|
||||
return (
|
||||
<motion.button
|
||||
type="button"
|
||||
className="gl-button gl-pressable w-full"
|
||||
data-variant={variant}
|
||||
aria-pressed={pressed}
|
||||
aria-label={label}
|
||||
disabled={disabled}
|
||||
whileTap={{ scale: 0.97 }}
|
||||
transition={LOOK.glass.spring}
|
||||
onPointerDown={onPointerDown}
|
||||
onClick={onClick}
|
||||
>
|
||||
<span className="gl-glow" aria-hidden />
|
||||
<span className="min-w-0 truncate">{children}</span>
|
||||
</motion.button>
|
||||
)
|
||||
}
|
||||
|
||||
export function Switch(props: SwitchProps) {
|
||||
const { buttonProps } = useSwitch(props)
|
||||
const { onPointerDown } = usePress()
|
||||
return (
|
||||
<button
|
||||
{...buttonProps}
|
||||
className="gl-switch gl-pressable"
|
||||
onPointerDown={onPointerDown}
|
||||
>
|
||||
<span className="gl-glow" aria-hidden />
|
||||
<motion.span
|
||||
layout
|
||||
transition={LOOK.glass.spring}
|
||||
className="gl-switch-thumb"
|
||||
/>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export function Slider(props: SliderProps) {
|
||||
const { fraction, inputProps, marks } = useSliderDrag(props)
|
||||
const vertical = props.orientation === "vertical"
|
||||
return (
|
||||
<div
|
||||
className={cn("dui-slider gl-slider", vertical ? "h-full" : "w-full")}
|
||||
style={{ "--dui-fraction": fraction } as React.CSSProperties}
|
||||
>
|
||||
<div
|
||||
className={cn("flex min-w-0 flex-col", vertical ? "h-full" : "w-full")}
|
||||
>
|
||||
<input
|
||||
{...inputProps}
|
||||
data-orientation={props.orientation ?? "horizontal"}
|
||||
/>
|
||||
{marks.length > 0 ? (
|
||||
// Decoration: the input itself announces min, max and where it stands.
|
||||
<div aria-hidden className="gl-ticks">
|
||||
{marks.map((mark) => (
|
||||
<span
|
||||
key={mark.percent}
|
||||
className="absolute top-0"
|
||||
style={{
|
||||
left: `${mark.percent}%`,
|
||||
transform: `translateX(-${mark.percent}%)`,
|
||||
}}
|
||||
>
|
||||
{mark.label}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function Segmented(props: SegmentedProps) {
|
||||
const { chosen, thumbId, groupProps, itemProps } = useSegmented(props)
|
||||
const vertical = props.orientation === "vertical"
|
||||
const { onPointerDown } = usePress()
|
||||
return (
|
||||
<div
|
||||
{...groupProps}
|
||||
data-testid={props.testId}
|
||||
className="gl-segmented"
|
||||
style={
|
||||
vertical
|
||||
? undefined
|
||||
: {
|
||||
gridTemplateColumns: `repeat(${props.options.length}, minmax(0, 1fr))`,
|
||||
}
|
||||
}
|
||||
>
|
||||
{props.options.map(([value, label], index) => (
|
||||
<button
|
||||
key={value}
|
||||
{...itemProps(index)}
|
||||
className="gl-segment gl-pressable"
|
||||
onPointerDown={onPointerDown}
|
||||
>
|
||||
{index === chosen ? (
|
||||
<motion.span
|
||||
aria-hidden
|
||||
layoutId={thumbId}
|
||||
transition={LOOK.glass.spring}
|
||||
className="gl-segment-thumb"
|
||||
/>
|
||||
) : null}
|
||||
<span className="gl-glow" aria-hidden />
|
||||
<span className="gl-segment-label">{label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function Select({
|
||||
value,
|
||||
options,
|
||||
label,
|
||||
disabled,
|
||||
onChange,
|
||||
}: SelectProps) {
|
||||
// The menu is portalled to `body`, which is outside the canvas — so it
|
||||
// re-states the dashboard's own colours rather than borrowing the app's.
|
||||
const { style } = useLook()
|
||||
return (
|
||||
<SelectPrimitive.Root
|
||||
value={value}
|
||||
onValueChange={(selected) => onChange(asOriginal(selected, options))}
|
||||
>
|
||||
<SelectPrimitive.Trigger
|
||||
aria-label={label}
|
||||
disabled={disabled}
|
||||
className="gl-field gl-pressable justify-between"
|
||||
>
|
||||
<span className="gl-glow" aria-hidden />
|
||||
<span className="min-w-0 truncate">
|
||||
<SelectPrimitive.Value placeholder="Choose" />
|
||||
</span>
|
||||
<SelectPrimitive.Icon asChild>
|
||||
<ChevronDown className="size-4 shrink-0 opacity-60" aria-hidden />
|
||||
</SelectPrimitive.Icon>
|
||||
</SelectPrimitive.Trigger>
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Content
|
||||
position="popper"
|
||||
sideOffset={4}
|
||||
style={style}
|
||||
className="gl-menu z-50 max-h-64 min-w-[var(--radix-select-trigger-width)] overflow-y-auto p-1 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95"
|
||||
>
|
||||
<SelectPrimitive.Viewport>
|
||||
{options.map((option) => (
|
||||
<SelectPrimitive.Item
|
||||
key={text(option.value)}
|
||||
value={text(option.value)}
|
||||
className="flex cursor-pointer select-none items-center justify-between gap-2 rounded-xl px-3 py-2 text-sm outline-none data-[highlighted]:bg-white/15"
|
||||
>
|
||||
<SelectPrimitive.ItemText>
|
||||
{option.label ?? text(option.value)}
|
||||
</SelectPrimitive.ItemText>
|
||||
<SelectPrimitive.ItemIndicator>
|
||||
<Check className="size-4" aria-hidden />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</SelectPrimitive.Item>
|
||||
))}
|
||||
</SelectPrimitive.Viewport>
|
||||
</SelectPrimitive.Content>
|
||||
</SelectPrimitive.Portal>
|
||||
</SelectPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
export function Input({
|
||||
value,
|
||||
type,
|
||||
label,
|
||||
disabled,
|
||||
onChange,
|
||||
onCommit,
|
||||
}: InputProps) {
|
||||
return (
|
||||
<input
|
||||
className="gl-field"
|
||||
value={value}
|
||||
type={type}
|
||||
aria-label={label}
|
||||
disabled={disabled}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
onBlur={onCommit}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter") onCommit()
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* Liquid glass: the readings.
|
||||
*
|
||||
* Lit fills over translucent tracks, and every number written out beside the
|
||||
* picture it is drawn as — an angle or a length nobody can measure is not a
|
||||
* reading.
|
||||
*/
|
||||
import { motion, useTransform } from "motion/react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { arcPath, GAUGE_START, GAUGE_SWEEP, GAUGE_TRACK } from "../core/arc"
|
||||
import { cssOf } from "../core/color"
|
||||
import { format } from "../core/config"
|
||||
import type {
|
||||
BarProps,
|
||||
ColorDiskProps,
|
||||
GaugeProps,
|
||||
ReadoutProps,
|
||||
} from "../core/contract"
|
||||
import { TESTID } from "../core/contract"
|
||||
import { useColorDisk } from "../core/disc"
|
||||
import { useAnimatedFraction, useAnimatedNumber } from "../core/values"
|
||||
import { Slider } from "./Controls"
|
||||
|
||||
export function Readout({
|
||||
value,
|
||||
precision,
|
||||
unit,
|
||||
size = "hero",
|
||||
}: ReadoutProps) {
|
||||
const { label, numeric } = useAnimatedNumber(value, precision)
|
||||
return (
|
||||
<span className="flex min-w-0 items-baseline gap-1.5">
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 truncate",
|
||||
size === "hero" ? "dui-hero" : "tabular-nums",
|
||||
)}
|
||||
>
|
||||
{numeric ? (
|
||||
<motion.span>{label}</motion.span>
|
||||
) : (
|
||||
format(value, precision)
|
||||
)}
|
||||
</span>
|
||||
{unit ? (
|
||||
<span
|
||||
className={cn(
|
||||
"shrink-0 text-muted-foreground",
|
||||
size === "hero" && "dui-hero-unit",
|
||||
)}
|
||||
>
|
||||
{unit}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export function Gauge({ value, min, max, precision, unit, label }: GaugeProps) {
|
||||
const fraction = useAnimatedFraction(
|
||||
value === null
|
||||
? 0
|
||||
: Math.min(1, Math.max(0, (value - min) / (max - min || 1))),
|
||||
)
|
||||
const { label: reading, numeric } = useAnimatedNumber(value, precision)
|
||||
return (
|
||||
<div className="flex min-h-0 flex-1 items-center justify-center">
|
||||
<svg
|
||||
viewBox="0 0 100 78"
|
||||
className="h-full max-h-full w-full"
|
||||
role="img"
|
||||
aria-label={`${label}: ${format(value, precision)}${unit ?? ""} of ${max}`}
|
||||
>
|
||||
<path
|
||||
d={GAUGE_TRACK}
|
||||
fill="none"
|
||||
stroke="var(--gl-track)"
|
||||
strokeWidth={9}
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
{/* The same full arc as the track, revealed rather than re-pathed: `d`
|
||||
is not animatable, so a reading that redrew the arc could only
|
||||
jump. `pathLength` normalises it, which makes the reveal the
|
||||
fraction itself. */}
|
||||
<motion.path
|
||||
d={arcPath(GAUGE_START, GAUGE_START + GAUGE_SWEEP)}
|
||||
// Glass lights what it draws: the arc carries the same glow the
|
||||
// fills and the active controls do.
|
||||
style={{
|
||||
pathLength: fraction,
|
||||
filter: "drop-shadow(0 0 4px var(--primary))",
|
||||
}}
|
||||
fill="none"
|
||||
stroke="var(--primary)"
|
||||
strokeWidth={9}
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
<text
|
||||
x={50}
|
||||
y={54}
|
||||
// User units of the viewBox, not the text scale: the readout has to
|
||||
// stay proportional to the dial at whatever size the tile is.
|
||||
fontSize={13}
|
||||
textAnchor="middle"
|
||||
className="fill-foreground tabular-nums"
|
||||
>
|
||||
{numeric ? (
|
||||
<motion.tspan>{reading}</motion.tspan>
|
||||
) : (
|
||||
format(value, precision)
|
||||
)}
|
||||
{unit ?? ""}
|
||||
</text>
|
||||
</svg>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Row({ row }: { row: BarProps["rows"][number] }) {
|
||||
const fraction = useAnimatedFraction(row.fraction)
|
||||
const width = useTransform(fraction, (at) => `${at * 100}%`)
|
||||
return (
|
||||
<div
|
||||
data-testid={TESTID.barRow}
|
||||
role="img"
|
||||
aria-label={`${row.label} ${format(row.value, row.precision)}${row.unit ?? ""}`}
|
||||
className="dui-bar-row"
|
||||
style={{ "--dui-fill": row.color } as React.CSSProperties}
|
||||
>
|
||||
<span className="dui-bar-label">{row.label}</span>
|
||||
<span className="dui-bar-track gl-track">
|
||||
<motion.span
|
||||
data-testid={TESTID.barFill}
|
||||
className="dui-bar-fill gl-fill"
|
||||
style={{ width }}
|
||||
/>
|
||||
</span>
|
||||
{/* Beside the track rather than on it: a number written on a fill has to
|
||||
clear the fill it sits on and the track it slides onto, and one that
|
||||
reads across a room cannot do both. */}
|
||||
<span className="dui-bar-value">
|
||||
{format(row.value, row.precision)}
|
||||
{row.unit ?? ""}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function Bar({ rows }: BarProps) {
|
||||
// No group role of its own: each row already announces what it reads and
|
||||
// what it is worth, and the tile's title is on the frame around them.
|
||||
return (
|
||||
<div className="dui-bar">
|
||||
{rows.map((row, index) => (
|
||||
// Two rows can read the same message under different labels; position
|
||||
// is the identity, as it is for chart series.
|
||||
<Row key={`row-${index}`} row={row} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function ColorDisk({
|
||||
name,
|
||||
hsv,
|
||||
disabled,
|
||||
onChange,
|
||||
onCommit,
|
||||
}: ColorDiskProps) {
|
||||
const { discProps, thumb, shade } = useColorDisk({
|
||||
name,
|
||||
hsv,
|
||||
disabled,
|
||||
onChange,
|
||||
onCommit,
|
||||
})
|
||||
const [hue, saturation, brightness] = hsv
|
||||
return (
|
||||
<div className="grid h-full min-h-0 grid-cols-[minmax(0,1fr)_auto] items-center justify-items-center gap-3">
|
||||
<div
|
||||
{...discProps}
|
||||
data-testid={TESTID.disc}
|
||||
className="dui-disc"
|
||||
style={
|
||||
{
|
||||
"--dui-shade": shade,
|
||||
"--dui-sx": thumb.sx,
|
||||
"--dui-sy": thumb.sy,
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<span className="dui-disc-shade" aria-hidden />
|
||||
<span
|
||||
aria-hidden
|
||||
data-testid={TESTID.swatch}
|
||||
className="dui-disc-thumb gl-disc-thumb"
|
||||
style={{ background: cssOf(hsv) }}
|
||||
/>
|
||||
</div>
|
||||
<Slider
|
||||
orientation="vertical"
|
||||
value={brightness}
|
||||
min={0}
|
||||
max={100}
|
||||
step={1}
|
||||
unit="%"
|
||||
label={`${name} brightness`}
|
||||
disabled={disabled}
|
||||
onCommit={(next) => {
|
||||
onChange([hue, saturation, next])
|
||||
onCommit()
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
* Liquid glass: the surfaces.
|
||||
*
|
||||
* Glass needs something behind it, so this look brings its own ground: two or
|
||||
* three soft blobs of the dashboard's colours, drifting slowly enough to be
|
||||
* noticed only if you look. An image, when one is set, replaces them.
|
||||
*/
|
||||
import { Link } from "@tanstack/react-router"
|
||||
import { Lock } from "lucide-react"
|
||||
import { motion } from "motion/react"
|
||||
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { ICONS } from "../../icons"
|
||||
import type {
|
||||
BackdropProps,
|
||||
FrameProps,
|
||||
NoticeProps,
|
||||
RailProps,
|
||||
} from "../core/contract"
|
||||
import { TESTID } from "../core/contract"
|
||||
import { LOOK } from "../core/motion"
|
||||
|
||||
/** Where each blob drifts to and back. Pixels on the unscaled canvas. */
|
||||
const DRIFTS = [
|
||||
{ x: [0, 80], y: [0, -60] },
|
||||
{ x: [0, -70], y: [0, 50] },
|
||||
{ x: [0, 50], y: [0, -40] },
|
||||
]
|
||||
|
||||
export function Backdrop({ image }: BackdropProps) {
|
||||
if (image) {
|
||||
return (
|
||||
<div
|
||||
aria-hidden
|
||||
data-testid="canvas-ground"
|
||||
className="pointer-events-none absolute inset-0 bg-cover bg-center"
|
||||
style={{ backgroundImage: `url(${JSON.stringify(image)})` }}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div
|
||||
aria-hidden
|
||||
data-testid="canvas-ground"
|
||||
className="pointer-events-none absolute inset-0 overflow-hidden"
|
||||
>
|
||||
<span className="gl-ground" />
|
||||
{DRIFTS.map((drift, index) => (
|
||||
<motion.span
|
||||
// Position is the identity: which blob this is decides its colour.
|
||||
key={`blob-${index}`}
|
||||
className="gl-blob"
|
||||
animate={drift}
|
||||
transition={{
|
||||
duration: LOOK.glass.drift,
|
||||
repeat: Number.POSITIVE_INFINITY,
|
||||
repeatType: "mirror",
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Issue({ issue }: { issue: string }) {
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span
|
||||
role="img"
|
||||
className="block size-2 shrink-0 rounded-full bg-destructive"
|
||||
aria-label={issue}
|
||||
data-testid={TESTID.issue}
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent className="max-w-xs break-words">{issue}</TooltipContent>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
export function Frame({
|
||||
title,
|
||||
issue,
|
||||
grip,
|
||||
selected,
|
||||
onClick,
|
||||
children,
|
||||
}: FrameProps) {
|
||||
const { hover, spring } = LOOK.glass
|
||||
return (
|
||||
// A card is not a control: the click only picks it in edit mode, and every
|
||||
// interactive element inside keeps its own role and keyboard handling.
|
||||
<motion.div
|
||||
data-testid={TESTID.frame}
|
||||
data-selected={selected ? "" : undefined}
|
||||
className="dui-frame gl-surface gl-frame"
|
||||
whileHover={hover}
|
||||
transition={spring}
|
||||
onClick={onClick}
|
||||
>
|
||||
{title ? (
|
||||
<div
|
||||
className={cn(
|
||||
"dui-frame-head gl-frame-title",
|
||||
grip &&
|
||||
`${TESTID.grip} -m-1 cursor-grab p-1 active:cursor-grabbing`,
|
||||
)}
|
||||
>
|
||||
<span className="dui-frame-title">{title}</span>
|
||||
{issue ? <Issue issue={issue} /> : null}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="dui-frame-body">{children}</div>
|
||||
{/* No header to sit in, so the fault takes the corner instead. */}
|
||||
{!title && issue ? (
|
||||
<div className="dui-frame-corner">
|
||||
<Issue issue={issue} />
|
||||
</div>
|
||||
) : null}
|
||||
{!title && grip ? (
|
||||
<span
|
||||
aria-hidden
|
||||
className={cn(
|
||||
TESTID.grip,
|
||||
"absolute left-1/2 top-1 z-[2] h-1 w-8 -translate-x-1/2 cursor-grab rounded-full bg-white/40 active:cursor-grabbing",
|
||||
)}
|
||||
/>
|
||||
) : null}
|
||||
</motion.div>
|
||||
)
|
||||
}
|
||||
|
||||
/** Two letters off the title, so a rail of four reads as four different things. */
|
||||
function initials(label: string): string {
|
||||
const words = label.split(/[\s_-]+/).filter(Boolean)
|
||||
if (words.length === 0) return "?"
|
||||
if (words.length === 1) return words[0].slice(0, 2).toUpperCase()
|
||||
return (words[0][0] + words[1][0]).toUpperCase()
|
||||
}
|
||||
|
||||
export function Rail({ entries }: RailProps) {
|
||||
return (
|
||||
<nav
|
||||
aria-label="Dashboards on this panel"
|
||||
data-testid={TESTID.rail}
|
||||
className={cn(
|
||||
"gl-surface gl-rail pointer-events-auto absolute inset-y-4 left-4 z-10 flex w-14 flex-col items-center gap-1 p-2",
|
||||
"overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
||||
)}
|
||||
>
|
||||
{entries.map((entry) => {
|
||||
const Glyph = ICONS[entry.icon ?? ""]
|
||||
return (
|
||||
<Tooltip key={entry.name}>
|
||||
<TooltipTrigger asChild>
|
||||
<Link
|
||||
{...entry.link}
|
||||
aria-label={entry.label}
|
||||
aria-current={entry.active ? "page" : undefined}
|
||||
data-testid={`panel-rail-${entry.name}`}
|
||||
className={cn(
|
||||
"gl-pressable relative flex size-10 shrink-0 items-center justify-center rounded-full text-xs font-medium",
|
||||
entry.active ? "text-foreground" : "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
<span className="gl-glow" aria-hidden />
|
||||
{entry.active ? (
|
||||
<motion.span
|
||||
aria-hidden
|
||||
layoutId="gl-rail-active"
|
||||
transition={LOOK.glass.spring}
|
||||
className="absolute inset-0 rounded-full border border-white/30 bg-white/20"
|
||||
/>
|
||||
) : null}
|
||||
<span className="relative z-[1]">
|
||||
{Glyph ? <Glyph className="size-5" /> : initials(entry.label)}
|
||||
</span>
|
||||
</Link>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right">{entry.label}</TooltipContent>
|
||||
</Tooltip>
|
||||
)
|
||||
})}
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
export function Notice({ children }: NoticeProps) {
|
||||
return (
|
||||
<div
|
||||
// Announced rather than merely drawn: `locked` may be driven by a flow,
|
||||
// so the state can change under someone already looking at the page.
|
||||
aria-live="polite"
|
||||
data-testid={TESTID.locked}
|
||||
className="gl-surface gl-notice pointer-events-none absolute bottom-0 right-0 flex items-center gap-1.5 px-3 py-1.5 text-sm"
|
||||
>
|
||||
<Lock className="size-4" aria-hidden />
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,472 @@
|
||||
/*
|
||||
* Liquid glass.
|
||||
*
|
||||
* Every surface is the same recipe: a thin wash of white, the ground behind it
|
||||
* blurred, a hairline that catches the light, and a highlight falling from the
|
||||
* top edge. It only reads as glass when there is something behind it to
|
||||
* refract, which is why this look brings its own ground — two soft drifting
|
||||
* blobs of the dashboard's own colours, or the image it was given.
|
||||
*
|
||||
* Dark is the natural direction for it. In light the same wash would be white
|
||||
* on white, so the mixture goes the other way: more opaque, brighter edges,
|
||||
* and a shadow soft enough not to read as a border.
|
||||
*
|
||||
* Paint only; the measurements are in `../core/core.css`.
|
||||
*/
|
||||
|
||||
[data-look="glass"] {
|
||||
--gl-bg: rgb(255 255 255 / 0.1);
|
||||
--gl-bg-strong: rgb(255 255 255 / 0.18);
|
||||
--gl-border: rgb(255 255 255 / 0.2);
|
||||
--gl-highlight: rgb(255 255 255 / 0.22);
|
||||
--gl-inset: inset 0 1px 1px rgb(255 255 255 / 0.1);
|
||||
--gl-shadow: 0 8px 32px rgb(0 0 0 / 0.37);
|
||||
--gl-blur: 24px;
|
||||
--gl-glow: 0 0 22px color-mix(in srgb, var(--primary) 45%, transparent);
|
||||
--gl-radius: 1.25rem;
|
||||
--gl-track: rgb(255 255 255 / 0.16);
|
||||
--gl-blob-opacity: 0.5;
|
||||
}
|
||||
|
||||
[data-look="glass"].light {
|
||||
--gl-bg: rgb(255 255 255 / 0.5);
|
||||
--gl-bg-strong: rgb(255 255 255 / 0.7);
|
||||
--gl-border: rgb(255 255 255 / 0.75);
|
||||
--gl-highlight: rgb(255 255 255 / 0.6);
|
||||
--gl-shadow: 0 8px 32px rgb(0 0 0 / 0.12);
|
||||
--gl-track: rgb(0 0 0 / 0.1);
|
||||
/* Diluted by the white it mixes into, so it takes more of it to show. */
|
||||
--gl-blob-opacity: 0.6;
|
||||
}
|
||||
|
||||
/* --- the ground ---------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Glass has nothing to be glass against on a flat white page: a translucent
|
||||
* white tile over a white ground is a shadow and nothing else. So the look
|
||||
* brings a ground of its own — a wash of the dashboard's primary, deepest at
|
||||
* the top where a room's light would come from — and the tiles then sit
|
||||
* *brighter* than what is behind them, which is what reads as a pane.
|
||||
*/
|
||||
.gl-ground {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: radial-gradient(
|
||||
120% 90% at 50% 0%,
|
||||
color-mix(in srgb, var(--primary) 14%, var(--background)),
|
||||
var(--background) 70%
|
||||
);
|
||||
}
|
||||
|
||||
.gl-blob {
|
||||
position: absolute;
|
||||
width: 55%;
|
||||
aspect-ratio: 1;
|
||||
border-radius: 50%;
|
||||
/* A gradient that falls off rather than a blurred circle: `filter: blur()`
|
||||
on something this size costs a full-screen pass every frame, and a panel
|
||||
on the wall is often the slowest machine in the house. */
|
||||
background: radial-gradient(
|
||||
circle closest-side,
|
||||
var(--gl-blob, var(--primary)),
|
||||
transparent 100%
|
||||
);
|
||||
opacity: var(--gl-blob-opacity, 0.55);
|
||||
}
|
||||
|
||||
.gl-blob:nth-child(1) {
|
||||
left: -15%;
|
||||
top: -25%;
|
||||
--gl-blob: var(--primary);
|
||||
}
|
||||
|
||||
.gl-blob:nth-child(2) {
|
||||
right: -20%;
|
||||
top: 5%;
|
||||
--gl-blob: var(--accent);
|
||||
}
|
||||
|
||||
.gl-blob:nth-child(3) {
|
||||
left: 25%;
|
||||
bottom: -35%;
|
||||
opacity: calc(var(--gl-blob-opacity, 0.55) * 0.65);
|
||||
--gl-blob: var(--primary);
|
||||
}
|
||||
|
||||
/* --- surfaces ------------------------------------------------------------ */
|
||||
|
||||
.gl-surface {
|
||||
position: relative;
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: var(--gl-radius);
|
||||
background: var(--gl-bg);
|
||||
box-shadow: var(--gl-shadow), var(--gl-inset);
|
||||
backdrop-filter: blur(var(--gl-blur));
|
||||
-webkit-backdrop-filter: blur(var(--gl-blur));
|
||||
}
|
||||
|
||||
/*
|
||||
* The light on the pane: a bright line along the top edge where it catches,
|
||||
* and a short wash falling from it. Carrying the wash the whole way down reads
|
||||
* as a gradient fill rather than as glass — the edge is what does the work.
|
||||
*/
|
||||
.gl-surface::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
border-radius: inherit;
|
||||
pointer-events: none;
|
||||
background: linear-gradient(to bottom, var(--gl-highlight), transparent 30%);
|
||||
opacity: 0.55;
|
||||
box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.28);
|
||||
}
|
||||
|
||||
.gl-frame > * {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.gl-frame[data-selected] {
|
||||
outline: 2px solid var(--primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.gl-frame-title {
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
.gl-rail {
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
.gl-notice {
|
||||
border-radius: 9999px;
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
/* --- the glow a press leaves --------------------------------------------- */
|
||||
|
||||
.gl-pressable {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
.gl-pressable > .gl-glow {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
border-radius: inherit;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
background: radial-gradient(
|
||||
circle at var(--press-x, 50%) var(--press-y, 50%),
|
||||
rgb(255 255 255 / 0.35),
|
||||
transparent 60%
|
||||
);
|
||||
transition: opacity var(--duration-base) var(--ease-standard);
|
||||
}
|
||||
|
||||
.gl-pressable:hover > .gl-glow,
|
||||
.gl-pressable:focus-visible > .gl-glow {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.gl-pressable:active > .gl-glow {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
[data-touch] .gl-pressable:hover > .gl-glow {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.gl-pressable > :not(.gl-glow) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* --- controls ------------------------------------------------------------ */
|
||||
|
||||
.gl-button {
|
||||
display: inline-flex;
|
||||
min-width: 0;
|
||||
min-height: var(--dui-control);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 9999px;
|
||||
padding-inline: 1.25rem;
|
||||
font-size: var(--dui-text);
|
||||
font-weight: 500;
|
||||
background: var(--gl-bg);
|
||||
color: var(--foreground);
|
||||
box-shadow: var(--gl-inset);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.gl-button[data-variant="filled"],
|
||||
.gl-button[aria-pressed="true"] {
|
||||
background: color-mix(in srgb, var(--primary) 78%, transparent);
|
||||
border-color: color-mix(in srgb, var(--primary) 55%, white);
|
||||
color: var(--primary-foreground);
|
||||
box-shadow: var(--gl-glow), var(--gl-inset);
|
||||
}
|
||||
|
||||
.gl-button[data-variant="text"] {
|
||||
border-color: transparent;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.gl-button:disabled {
|
||||
opacity: 0.45;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.gl-switch {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
width: calc(var(--dui-control) * 1.75);
|
||||
height: var(--dui-control);
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 9999px;
|
||||
padding: 0.1875rem;
|
||||
background: var(--gl-track);
|
||||
box-shadow: var(--gl-inset);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.gl-switch[data-state="on"] {
|
||||
justify-content: flex-end;
|
||||
background: color-mix(in srgb, var(--primary) 70%, transparent);
|
||||
box-shadow: var(--gl-glow), var(--gl-inset);
|
||||
}
|
||||
|
||||
.gl-switch-thumb {
|
||||
display: block;
|
||||
height: calc(var(--dui-control) - 0.5rem);
|
||||
aspect-ratio: 1;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 6px rgb(0 0 0 / 0.35);
|
||||
}
|
||||
|
||||
.gl-switch:disabled {
|
||||
opacity: 0.45;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.gl-slider {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.gl-slider input {
|
||||
width: 100%;
|
||||
height: var(--dui-control);
|
||||
margin: 0;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.gl-slider input::-webkit-slider-runnable-track {
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
box-shadow: var(--gl-inset);
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
color-mix(in srgb, var(--primary) 85%, white)
|
||||
calc(var(--dui-fraction, 0) * 100%),
|
||||
var(--gl-track) calc(var(--dui-fraction, 0) * 100%)
|
||||
);
|
||||
}
|
||||
|
||||
.gl-slider input[data-orientation="vertical"]::-webkit-slider-runnable-track {
|
||||
width: 0.5rem;
|
||||
height: 100%;
|
||||
background: linear-gradient(
|
||||
to top,
|
||||
color-mix(in srgb, var(--primary) 85%, white)
|
||||
calc(var(--dui-fraction, 0) * 100%),
|
||||
var(--gl-track) calc(var(--dui-fraction, 0) * 100%)
|
||||
);
|
||||
}
|
||||
|
||||
.gl-slider input::-moz-range-track {
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
background: var(--gl-track);
|
||||
}
|
||||
|
||||
.gl-slider input::-moz-range-progress {
|
||||
height: 0.5rem;
|
||||
border-radius: 9999px;
|
||||
background: color-mix(in srgb, var(--primary) 85%, white);
|
||||
}
|
||||
|
||||
.gl-slider input::-webkit-slider-thumb {
|
||||
appearance: none;
|
||||
width: var(--dui-thumb);
|
||||
height: var(--dui-thumb);
|
||||
margin-top: calc((0.5rem - var(--dui-thumb)) / 2);
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
|
||||
}
|
||||
|
||||
.gl-slider input::-moz-range-thumb {
|
||||
width: var(--dui-thumb);
|
||||
height: var(--dui-thumb);
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.gl-slider input:disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
.gl-ticks {
|
||||
position: relative;
|
||||
height: 1rem;
|
||||
font-size: 0.75rem;
|
||||
color: var(--muted-foreground);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.gl-segmented {
|
||||
position: relative;
|
||||
display: grid;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 9999px;
|
||||
padding: 0.25rem;
|
||||
background: var(--gl-bg);
|
||||
box-shadow: var(--gl-inset);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.gl-segmented[data-orientation="vertical"] {
|
||||
height: 100%;
|
||||
grid-auto-flow: row;
|
||||
grid-auto-rows: minmax(0, 1fr);
|
||||
border-radius: 1.25rem;
|
||||
}
|
||||
|
||||
.gl-segment {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
min-height: calc(var(--dui-control) - 0.5rem);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 9999px;
|
||||
padding-inline: 0.625rem;
|
||||
font-size: var(--dui-text);
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
.gl-segment[data-active] {
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
.gl-segment-thumb {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
border-radius: 9999px;
|
||||
background: var(--gl-bg-strong);
|
||||
box-shadow: var(--gl-inset);
|
||||
}
|
||||
|
||||
.gl-segment-label {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.gl-field {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
min-height: var(--dui-control);
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 0.875rem;
|
||||
background: var(--gl-bg);
|
||||
padding-inline: 0.875rem;
|
||||
font-size: var(--dui-text);
|
||||
color: var(--foreground);
|
||||
text-align: left;
|
||||
box-shadow: var(--gl-inset);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.gl-field::placeholder {
|
||||
color: var(--muted-foreground);
|
||||
}
|
||||
|
||||
.gl-field:disabled {
|
||||
opacity: 0.45;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.gl-menu {
|
||||
border: 1px solid var(--gl-border);
|
||||
border-radius: 0.875rem;
|
||||
background: color-mix(in srgb, var(--popover) 75%, transparent);
|
||||
color: var(--popover-foreground);
|
||||
box-shadow: var(--gl-shadow), var(--gl-inset);
|
||||
backdrop-filter: blur(var(--gl-blur));
|
||||
-webkit-backdrop-filter: blur(var(--gl-blur));
|
||||
}
|
||||
|
||||
/* --- readings ------------------------------------------------------------ */
|
||||
|
||||
.gl-track {
|
||||
border-radius: 9999px;
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--dui-fill, var(--primary)) 22%,
|
||||
transparent
|
||||
);
|
||||
box-shadow: var(--gl-inset);
|
||||
}
|
||||
|
||||
.gl-fill {
|
||||
border-radius: 9999px;
|
||||
background: var(--dui-fill, var(--primary));
|
||||
box-shadow: 0 0 14px
|
||||
color-mix(in srgb, var(--dui-fill, var(--primary)) 55%, transparent);
|
||||
}
|
||||
|
||||
.gl-disc-thumb {
|
||||
border: 2px solid rgb(255 255 255 / 0.85);
|
||||
box-shadow: 0 2px 10px rgb(0 0 0 / 0.4);
|
||||
}
|
||||
|
||||
/* --- focus --------------------------------------------------------------- */
|
||||
|
||||
[data-look="glass"]
|
||||
:is(.gl-button, .gl-switch, .gl-segment, .gl-field, .dui-disc):focus-visible {
|
||||
outline: 2px solid var(--ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Liquid glass — one of the dashboard's two looks.
|
||||
*
|
||||
* Every entry of `ComponentSet` is implemented here; the behaviour comes from
|
||||
* `ui/core`, so this set cannot do anything the other one cannot.
|
||||
*/
|
||||
import "./glass.css"
|
||||
|
||||
import type { ComponentSet } from "../core/contract"
|
||||
import { Button, Input, Segmented, Select, Slider, Switch } from "./Controls"
|
||||
import { Bar, ColorDisk, Gauge, Readout } from "./Data"
|
||||
import { Backdrop, Frame, Notice, Rail } from "./Surfaces"
|
||||
|
||||
export const glass: ComponentSet = {
|
||||
Backdrop,
|
||||
Frame,
|
||||
Button,
|
||||
Switch,
|
||||
Slider,
|
||||
Segmented,
|
||||
Select,
|
||||
Input,
|
||||
Readout,
|
||||
Gauge,
|
||||
Bar,
|
||||
ColorDisk,
|
||||
Rail,
|
||||
Notice,
|
||||
}
|
||||
Reference in New Issue
Block a user