Skip to content

Commit 3142ea2

Browse files
fahchenclaude
andcommitted
feat(dashboard): wrap NetDiagram nodes in Kumo Surface + Badge
Honors the M4 immutable spec calling for Kumo Surface/Badge primitives in the NetDiagram custom nodes. PlaceNode + TransitionNode now wrap their outer container in `Surface as="div"` so React Flow positioning + the existing cf-token chrome (className, style, data-attrs, glow pulse, click routing) pass through unchanged. PlaceNode's token-count chip swaps to a Kumo Badge styled with cf-accent tokens. Test selectors preserved via a contents-wrapper around the badge. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent b2dbc1e commit 3142ea2

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

dashboard/ui/src/components/NetDiagram.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
type NodeProps
1212
} from "@xyflow/react"
1313
import dagre from "@dagrejs/dagre"
14+
import { Badge, Surface } from "@cloudflare/kumo"
1415

1516
type NetDiagramPayload = ColouredFlowDashboardWeb.Views.NetDiagram
1617
type DiagramPlace = ColouredFlowDashboardWeb.Views.NetDiagramPlace
@@ -226,7 +227,8 @@ function PlaceNodeViewImpl({ data }: NodeProps<PlaceNode>) {
226227
const hasTokens = data.tokens_count > 0
227228
const tooltip = data.tokens_summary || `${data.tokens_count} token(s)`
228229
return (
229-
<div
230+
<Surface
231+
as="div"
230232
title={tooltip}
231233
className="relative flex h-[96px] w-[96px] items-center justify-center rounded-full border bg-cf-surface text-center shadow-sm"
232234
style={{
@@ -243,11 +245,13 @@ function PlaceNodeViewImpl({ data }: NodeProps<PlaceNode>) {
243245
/>
244246
<div className="flex flex-col items-center gap-0.5 px-2">
245247
{hasTokens ? (
246-
<span
247-
className="text-lg font-semibold leading-none tabular-nums text-cf-accent-ink"
248-
data-testid={`place-tokens-${data.name}`}
249-
>
250-
{data.tokens_count}
248+
<span data-testid={`place-tokens-${data.name}`} className="contents">
249+
<Badge
250+
variant="primary"
251+
className="bg-cf-accent-tint px-2 py-0 text-base font-semibold leading-none tabular-nums text-cf-accent-ink"
252+
>
253+
{data.tokens_count}
254+
</Badge>
251255
</span>
252256
) : null}
253257
<span className="max-w-[80px] truncate text-xs font-medium text-cf-ink">
@@ -265,7 +269,7 @@ function PlaceNodeViewImpl({ data }: NodeProps<PlaceNode>) {
265269
style={PLACE_HANDLE_STYLE}
266270
isConnectable={false}
267271
/>
268-
</div>
272+
</Surface>
269273
)
270274
}
271275

@@ -297,7 +301,8 @@ function TransitionNodeViewImpl({ data }: NodeProps<TransitionNode>) {
297301
: null
298302

299303
return (
300-
<div
304+
<Surface
305+
as="div"
301306
className="flex h-[56px] w-[128px] items-center justify-center rounded-md border bg-cf-surface text-center shadow-sm"
302307
style={{
303308
borderColor: "var(--color-cf-border)",
@@ -327,7 +332,7 @@ function TransitionNodeViewImpl({ data }: NodeProps<TransitionNode>) {
327332
style={PLACE_HANDLE_STYLE}
328333
isConnectable={false}
329334
/>
330-
</div>
335+
</Surface>
331336
)
332337
}
333338

0 commit comments

Comments
 (0)