Files
fission-ai__openspec/website/components/mermaid.tsx
Clay Good 4e4c9e1ffd docs(workflows): visualize the OpenSpec lifecycle (#1507)
* docs(workflows): add lifecycle diagrams

* docs(workflows): clarify optional archive paths

* docs(workflows): correct lifecycle diagrams

* docs(website): render Mermaid diagrams

* fix(website): preserve Mermaid label text
2026-08-04 18:09:08 +00:00

38 lines
1.1 KiB
TypeScript

import { renderMermaidSVG } from 'beautiful-mermaid';
import { CodeBlock, Pre } from 'fumadocs-ui/components/codeblock';
export function Mermaid({ chart }: { chart: string }) {
try {
// beautiful-mermaid injects remote font imports; the site already provides Inter.
const svg = renderMermaidSVG(chart, {
bg: 'var(--color-fd-background)',
fg: 'var(--color-fd-foreground)',
transparent: true,
}).replace(/^\s*@import url\(['"]https:\/\/fonts\.googleapis\.com\/[^)]*\);\s*$/m, '');
return (
<figure>
<div
aria-label="Scrollable Mermaid diagram"
className="overflow-x-auto"
role="region"
tabIndex={0}
>
<div
aria-hidden="true"
className="[&_svg]:h-auto [&_svg]:max-w-full [&_svg]:min-w-[40rem]"
dangerouslySetInnerHTML={{ __html: svg }}
/>
</div>
<figcaption className="sr-only">Mermaid diagram source: {chart}</figcaption>
</figure>
);
} catch {
return (
<CodeBlock title="Mermaid">
<Pre>{chart}</Pre>
</CodeBlock>
);
}
}