Round paging follows the finger: faces and dashboards on a track, swiped one to one with the next beside it, turned or sent back on release, rubber-banded at the ends; keys and dots slide the same track; the reading dot a smaller companion of the handle

This commit is contained in:
Melvin Strobl
2026-10-14 17:08:51 +02:00
parent c294789d85
commit d8e9fbda26
7 changed files with 474 additions and 183 deletions
+11 -1
View File
@@ -1,6 +1,6 @@
import { keepPreviousData, useQuery } from "@tanstack/react-query"
import { createFileRoute, redirect } from "@tanstack/react-router"
import { useCallback } from "react"
import { useCallback, useMemo } from "react"
import type { Dashboard } from "@/components/Dashboard/DashboardView"
import { PanelRail } from "@/components/Dashboard/PanelRail"
@@ -66,6 +66,15 @@ function PanelRoute() {
const stacked = useIsMobile()
const rail = dashboards.length > 1
const round = dashboard?.shape === "round"
// The ones either side, which a round one is swiped to and shows the
// names of on the way. Stable, so the canvas is not rebuilt for it.
const at = dashboards.indexOf(current ?? "")
const before = dashboards[at - 1]
const after = dashboards[at + 1]
const around = useMemo(
(): [string | undefined, string | undefined] => [before, after],
[before, after],
)
// Stops at either end, as the faces of one do.
const step = useCallback(
(by: number) => {
@@ -123,6 +132,7 @@ function PanelRoute() {
stacked={stacked}
touch={touch}
onDashboard={rail && round ? step : undefined}
around={rail && round ? around : undefined}
// Drawn on the panel rather than beside it: a screen showing four
// dashboards shows the way between them too.
rail={