import { useState } from "react"; import { DIAGRAM_FIXTURES } from "@chopin/diagrams/fixtures"; import { Diagram } from "@chopin/diagrams/react"; import { StaticPlanEditor } from "@chopin/editor/static"; import "@chopin/diagrams/styles.css"; import "@chopin/editor/styles.css"; import "./styles.css"; type Fixture = (typeof DIAGRAM_FIXTURES)[number]; let familyLabels: Record = { charts: "Charts", "data-platform": "Data platform", process: "Process", structure: "Structure", systems: "Systems", }; let familyOrder = ["process", "systems", "structure", "charts", "data-platform"]; function fixture(type: string): Fixture { let match = DIAGRAM_FIXTURES.find(item => item.type === type); if (match) return match; let first = DIAGRAM_FIXTURES[0]; if (!first) throw new Error("Diagram gallery requires catalogue fixtures."); return first; } function label(type: string): string { let acronym: Record = { db: "DB", dp: "DP", er: "ER", it: "IT", uml: "UML" }; return type.split("-").map((word, index) => acronym[word] ?? (index === 0 ? word.replace(/^./, first => first.toUpperCase()) : word) ).join(" "); } function FeaturedDiagram({ type }: { type: string }) { let item = fixture(type); return (

{label(item.type)}

{item.type}
); } function DocumentSpecimen() { let [alternate, setAlternate] = useState(false); let [secondMounted, setSecondMounted] = useState(true); let first = fixture(alternate ? "state" : "flowchart"); let second = fixture("sequence"); return (

Document specimen

In the reading flow

Development specimen using the document surface. Diagrams are not persisted MDX nodes.

{label(first.type)} · first instance
{secondMounted ? (
{label(second.type)} · second instance
) : (

Second diagram unmounted.

)}
); } export function DiagramGalleryPage() { let [selectedType, setSelectedType] = useState("flowchart"); let selected = fixture(selectedType); let families = familyOrder.filter(family => DIAGRAM_FIXTURES.some(item => item.family === family) ); let unknownFamilies = [...new Set(DIAGRAM_FIXTURES.map(item => item.family))].filter( family => !familyOrder.includes(family), ); return (

Development gallery · SeeCode rendering module

Diagrams in a document

Browse the retained catalogue, inspect one example at a time, and try two views in a document.

Browse {DIAGRAM_FIXTURES.length} types

Catalogue

Every registered type

Choose a type to view its resolved fixture through the public renderer.

{label(selected.type)}

{selected.type}

Rendered from a resolved local fixture

); }