d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
69 lines
2.5 KiB
TypeScript
69 lines
2.5 KiB
TypeScript
'use client'
|
|
|
|
import { useMemo } from 'react'
|
|
import { domAnimation, LazyMotion } from 'framer-motion'
|
|
import ReactFlow, { type NodeTypes, ReactFlowProvider } from 'reactflow'
|
|
import 'reactflow/dist/style.css'
|
|
import { BLOCK_DISPLAY_WORKFLOWS } from '@/components/workflow-preview/block-display-workflows'
|
|
import { DocsBlockNode } from '@/components/workflow-preview/docs-block-node'
|
|
import { toReactFlowElements } from '@/components/workflow-preview/workflow-data'
|
|
|
|
/** The hero mounts the same node type the canvas uses, so it can never drift. */
|
|
const NODE_TYPES: NodeTypes = { previewBlock: DocsBlockNode }
|
|
const PRO_OPTIONS = { hideAttribution: true }
|
|
/** `maxZoom` mirrors the previous hand-rolled hero's 1.3 scale. */
|
|
const FIT_VIEW_OPTIONS = { padding: 0.2, maxZoom: 1.3 } as const
|
|
|
|
interface BlockPreviewProps {
|
|
/** Block key from {@link BLOCK_DISPLAY_WORKFLOWS} (e.g. `agent`, `condition`, `webhook_trigger`). */
|
|
type: string
|
|
}
|
|
|
|
/**
|
|
* Renders a single block exactly as it appears on the builder canvas, drawn by the
|
|
* shared {@link WorkflowBlockView} (via `DocsBlockNode`) through the same ReactFlow
|
|
* machinery as the multi-block diagrams — never a parallel hand-rolled card. Static
|
|
* and non-interactive (no pan/zoom), centered in a bordered container. Use as the hero
|
|
* on a block reference page: `<BlockPreview type="agent" />`. Edit the source data in
|
|
* `block-display-workflows.ts`.
|
|
*/
|
|
export function BlockPreview({ type }: BlockPreviewProps) {
|
|
const workflow = BLOCK_DISPLAY_WORKFLOWS[type]
|
|
|
|
const elements = useMemo(() => (workflow ? toReactFlowElements(workflow) : null), [workflow])
|
|
|
|
if (!workflow || !elements) return null
|
|
|
|
return (
|
|
<div
|
|
className='not-prose my-6 overflow-hidden rounded-xl border border-[var(--border)] bg-[var(--bg)]'
|
|
style={{ height: 400 }}
|
|
>
|
|
<LazyMotion features={domAnimation}>
|
|
<ReactFlowProvider>
|
|
<ReactFlow
|
|
nodes={elements.nodes}
|
|
edges={elements.edges}
|
|
nodeTypes={NODE_TYPES}
|
|
proOptions={PRO_OPTIONS}
|
|
fitView
|
|
fitViewOptions={FIT_VIEW_OPTIONS}
|
|
minZoom={0.2}
|
|
maxZoom={1.3}
|
|
nodesDraggable={false}
|
|
nodesConnectable={false}
|
|
elementsSelectable={false}
|
|
zoomOnScroll={false}
|
|
zoomOnDoubleClick={false}
|
|
zoomOnPinch={false}
|
|
panOnDrag={false}
|
|
panOnScroll={false}
|
|
preventScrolling={false}
|
|
className='h-full w-full'
|
|
/>
|
|
</ReactFlowProvider>
|
|
</LazyMotion>
|
|
</div>
|
|
)
|
|
}
|