Below md a dashboard stacks to one column and dropped its rail. The rail is
now a horizontal row in the dashboard's own look, floated over the bottom
of the screen on /panel/{id} and above the dock in the app's view, with
44px items, sideways scrolling when it overflows, and padding so the last
tile clears it; a panel's read-only notice moves up out of its way. The
three looks share the geometry from ui/core.
170 lines
5.2 KiB
TypeScript
170 lines
5.2 KiB
TypeScript
/**
|
|
* Fluksio: the surfaces.
|
|
*
|
|
* The house style. A widget is a `--card` told from the page by a hairline and
|
|
* a low shadow rather than by colour, floating chrome is frosted, and the one
|
|
* accent is spent on what a person can act on. Nothing here holds state: the
|
|
* behaviour is in `ui/core`.
|
|
*/
|
|
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, initials } from "../../icons"
|
|
import type {
|
|
BackdropProps,
|
|
FrameProps,
|
|
NoticeProps,
|
|
RailProps,
|
|
} from "../core/contract"
|
|
import { railGeometry, TESTID } from "../core/contract"
|
|
import { LOOK } from "../core/motion"
|
|
|
|
/** The page colour is the ground; only an image is drawn over it. */
|
|
export function Backdrop({ image }: BackdropProps) {
|
|
if (!image) return null
|
|
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)})` }}
|
|
/>
|
|
)
|
|
}
|
|
|
|
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,
|
|
scroll,
|
|
selected,
|
|
onClick,
|
|
children,
|
|
}: FrameProps) {
|
|
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.
|
|
// biome-ignore lint/a11y/useKeyWithClickEvents: see above.
|
|
// biome-ignore lint/a11y/noStaticElementInteractions: see above.
|
|
<div
|
|
data-testid={TESTID.frame}
|
|
data-selected={selected ? "" : undefined}
|
|
className="dui-frame fx-frame"
|
|
onClick={onClick}
|
|
>
|
|
{title ? (
|
|
<div
|
|
className={cn(
|
|
"dui-frame-head fx-frame-title",
|
|
grip && `${TESTID.grip} cursor-grab active:cursor-grabbing`,
|
|
)}
|
|
>
|
|
<span className="dui-frame-title">{title}</span>
|
|
{issue ? <Issue issue={issue} /> : null}
|
|
</div>
|
|
) : null}
|
|
<div className={cn("dui-frame-body", scroll && "dui-frame-scroll")}>
|
|
{children}
|
|
</div>
|
|
{/* No header to sit in, so the fault takes the corner instead — a widget
|
|
drawn without its title still says when it is mis-wired. */}
|
|
{!title && issue ? (
|
|
<div className="dui-frame-corner">
|
|
<Issue issue={issue} />
|
|
</div>
|
|
) : null}
|
|
{/* And the editor still needs something to drag it by. */}
|
|
{!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-current opacity-20 active:cursor-grabbing",
|
|
)}
|
|
/>
|
|
) : null}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function Rail({ entries, horizontal }: RailProps) {
|
|
return (
|
|
<nav
|
|
aria-label="Dashboards on this panel"
|
|
data-testid={TESTID.rail}
|
|
data-orientation={horizontal ? "horizontal" : undefined}
|
|
className={cn("dui-rail fx-rail", railGeometry(horizontal))}
|
|
>
|
|
{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="dui-rail-item fx-rail-item relative flex size-10 shrink-0 items-center justify-center text-xs font-medium"
|
|
>
|
|
{entry.active ? (
|
|
<motion.span
|
|
aria-hidden
|
|
layoutId="fx-rail-active"
|
|
transition={LOOK.fluksio.spring}
|
|
className="absolute inset-0 rounded-full bg-accent"
|
|
/>
|
|
) : null}
|
|
<span className="relative z-[1]">
|
|
{Glyph ? <Glyph className="size-5" /> : initials(entry.label)}
|
|
</span>
|
|
</Link>
|
|
</TooltipTrigger>
|
|
<TooltipContent side={horizontal ? "top" : "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="fx-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>
|
|
)
|
|
}
|