Computed flow layout, and mobile written into the design
The canvas lays itself out: a layered graph, left to right on a desktop and top to bottom on a phone, with room reserved for the value each edge carries. Nodes cannot be dragged and `NodeDef.position` is gone from the document — a graph nobody can arrange is one worth keeping small, which is what keeps flows atomic. Endpoints join the same layout, so their lanes and the localStorage that remembered where they were dragged go too. Mobile, per the new Responsive section of DESIGN-GUIDELINES.md: the dock caps its width and wraps instead of running off the screen, the dashboard stacks into one column rather than shrinking a wall panel to a fifth of its size, and Home stops widening its grid track past the viewport. A Playwright project at a phone's width fails the build when a screen no longer fits. Along the way: publish is the checkmark that was already there rather than a button that appears and disappears, with discard beside it on both the flow and the dashboard; the brain reveals a neuron's name on the first tap; and the port sparklines get room to breathe. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VDSXaRhvqHYNevgDGmNAto
This commit is contained in:
@@ -2,6 +2,7 @@ import { Handle, type NodeProps, Position } from "@xyflow/react"
|
||||
import { LayoutDashboard, Workflow } from "lucide-react"
|
||||
import { memo } from "react"
|
||||
|
||||
import { useIsMobile } from "@/hooks/useMobile"
|
||||
import { cn } from "@/lib/utils"
|
||||
import type { EndpointNodeData } from "./endpoints"
|
||||
|
||||
@@ -22,15 +23,17 @@ function EndpointNodeComponent({ data, selected }: NodeProps) {
|
||||
const { label, kind, detail, provides, requires } = data as EndpointNodeData
|
||||
const Icon = KIND_ICONS[kind as keyof typeof KIND_ICONS] ?? Workflow
|
||||
const messages = [...provides, ...requires]
|
||||
// Follows the graph's own direction; see DESIGN-GUIDELINES.md → Responsive.
|
||||
const vertical = useIsMobile()
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
// Padding keeps the text off the connector dot, which sits on the edge.
|
||||
"flex max-w-48 cursor-grab items-center gap-2 px-3 py-1",
|
||||
"flex max-w-48 cursor-pointer items-center gap-2 px-3 py-1",
|
||||
// Quiet at rest so the logic reads first; legible when reached for.
|
||||
"text-muted-foreground/55 transition-colors",
|
||||
"hover:text-foreground active:cursor-grabbing",
|
||||
"hover:text-foreground",
|
||||
selected && "text-foreground",
|
||||
)}
|
||||
title={messages.join("\n")}
|
||||
@@ -41,7 +44,7 @@ function EndpointNodeComponent({ data, selected }: NodeProps) {
|
||||
key={`in-${message}`}
|
||||
type="target"
|
||||
id={message}
|
||||
position={Position.Left}
|
||||
position={vertical ? Position.Top : Position.Left}
|
||||
className="!border-border !bg-card"
|
||||
/>
|
||||
))}
|
||||
@@ -50,7 +53,7 @@ function EndpointNodeComponent({ data, selected }: NodeProps) {
|
||||
key={`out-${message}`}
|
||||
type="source"
|
||||
id={message}
|
||||
position={Position.Right}
|
||||
position={vertical ? Position.Bottom : Position.Right}
|
||||
className="!border-border !bg-card"
|
||||
/>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user