Round dashboards: shape and ring, the ring drawn and turned in every look, Knob preset and face guide in the editor
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { useQueries } from "@tanstack/react-query"
|
||||
import type { LinkProps } from "@tanstack/react-router"
|
||||
import { Link, type LinkProps } from "@tanstack/react-router"
|
||||
import { useReducedMotion } from "motion/react"
|
||||
import { useEffect, useRef } from "react"
|
||||
|
||||
import { dashboardQueryOptions } from "@/components/Dashboard/queries"
|
||||
import { useUi } from "./ui"
|
||||
import { TESTID, useUi } from "./ui"
|
||||
|
||||
/**
|
||||
* Switching between the dashboards one panel was assigned.
|
||||
@@ -21,17 +21,24 @@ import { useUi } from "./ui"
|
||||
*
|
||||
* Reading the dashboards it links to is also what fills the labels, and it
|
||||
* warms the cache for the neighbours so a switch draws immediately.
|
||||
*
|
||||
* A round dashboard has no column to give: its way to the neighbours is a row
|
||||
* of page dots in the gap at the bottom of the face, the one place the ring
|
||||
* leaves free. Same links, in canvas pixels; a round device swipes instead.
|
||||
*/
|
||||
export function PanelRail({
|
||||
dashboards,
|
||||
current,
|
||||
linkFor,
|
||||
horizontal,
|
||||
dots,
|
||||
}: {
|
||||
dashboards: string[]
|
||||
current: string
|
||||
linkFor: (name: string) => LinkProps
|
||||
horizontal?: boolean
|
||||
/** Page dots for a round dashboard, instead of the rail. */
|
||||
dots?: boolean
|
||||
}) {
|
||||
const { Rail } = useUi()
|
||||
const box = useRef<HTMLDivElement>(null)
|
||||
@@ -69,7 +76,30 @@ export function PanelRail({
|
||||
// places the rail itself.
|
||||
return (
|
||||
<div ref={box} className="contents">
|
||||
<Rail entries={entries} horizontal={horizontal} />
|
||||
{dots ? (
|
||||
// 16px targets centred 12px above the face's bottom edge, each with
|
||||
// a 6px dot.
|
||||
<nav
|
||||
aria-label="Dashboards on this panel"
|
||||
data-testid={TESTID.rail}
|
||||
className="pointer-events-auto absolute inset-x-0 bottom-1 z-10 flex justify-center"
|
||||
>
|
||||
{entries.map((entry) => (
|
||||
<Link
|
||||
key={entry.name}
|
||||
{...entry.link}
|
||||
aria-label={entry.label}
|
||||
aria-current={entry.active ? "page" : undefined}
|
||||
data-testid={`panel-rail-${entry.name}`}
|
||||
className="dui-dot flex size-4 items-center justify-center"
|
||||
>
|
||||
<span className="dui-dot-mark" />
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
) : (
|
||||
<Rail entries={entries} horizontal={horizontal} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user