Round dashboards: one face at a time, a face per widget type, paged by swipe, dots and keys; slider reading; face row in the editor
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8b8cb5cda9
commit
84071ee106
@@ -1,5 +1,6 @@
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { keepPreviousData, useQuery } from "@tanstack/react-query"
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router"
|
||||
import { useCallback } from "react"
|
||||
|
||||
import type { Dashboard } from "@/components/Dashboard/DashboardView"
|
||||
import { PanelRail } from "@/components/Dashboard/PanelRail"
|
||||
@@ -26,7 +27,8 @@ import { cn } from "@/lib/utils"
|
||||
* anything about the other.
|
||||
*
|
||||
* Which one is open lives in the URL, so a panel that reboots comes back where
|
||||
* it was rather than at the first one.
|
||||
* it was rather than at the first one. A round dashboard has no room for a
|
||||
* rail: its panel is swiped up and down between them instead.
|
||||
*/
|
||||
export const Route = createFileRoute("/panel/$id")({
|
||||
component: PanelRoute,
|
||||
@@ -45,6 +47,7 @@ export const Route = createFileRoute("/panel/$id")({
|
||||
function PanelRoute() {
|
||||
const { id } = Route.useParams()
|
||||
const { d } = Route.useSearch()
|
||||
const navigate = Route.useNavigate()
|
||||
useFlowSocket()
|
||||
|
||||
const { data: panel } = useQuery(panelQueryOptions(id))
|
||||
@@ -56,9 +59,22 @@ function PanelRoute() {
|
||||
const { data: dashboard } = useQuery({
|
||||
...dashboardQueryOptions(current ?? ""),
|
||||
enabled: Boolean(current),
|
||||
// The one showing stays until the next has loaded, rather than the
|
||||
// screen going blank between them.
|
||||
placeholderData: keepPreviousData,
|
||||
})
|
||||
const stacked = useIsMobile()
|
||||
const rail = dashboards.length > 1
|
||||
const round = dashboard?.shape === "round"
|
||||
// Stops at either end, as the faces of one do.
|
||||
const step = useCallback(
|
||||
(by: number) => {
|
||||
const all = panel?.dashboards ?? []
|
||||
const next = all[all.indexOf(current ?? "") + by]
|
||||
if (next) navigate({ search: { d: next } })
|
||||
},
|
||||
[panel, current, navigate],
|
||||
)
|
||||
// Said by the panel rather than by the dashboard: this is the screen, and
|
||||
// whether it is touched or pointed at is a fact about the screen. A document
|
||||
// hanging on a hallway tablet and on a desk browser is one document either
|
||||
@@ -105,15 +121,15 @@ function PanelRoute() {
|
||||
dashboard={dashboard as Dashboard}
|
||||
stacked={stacked}
|
||||
touch={touch}
|
||||
onDashboard={rail && round ? step : undefined}
|
||||
// Drawn on the panel rather than beside it: a screen showing four
|
||||
// dashboards shows the way between them too.
|
||||
rail={
|
||||
rail && current ? (
|
||||
rail && current && !round ? (
|
||||
<PanelRail
|
||||
dashboards={dashboards}
|
||||
current={current}
|
||||
horizontal={stacked}
|
||||
dots={dashboard?.shape === "round"}
|
||||
linkFor={(name) => ({
|
||||
to: "/panel/$id",
|
||||
params: { id },
|
||||
|
||||
Reference in New Issue
Block a user