Skip to content

Commit 90b54ee

Browse files
committed
docs: centralized crucible-themed mermaid diagrams
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
1 parent 749ccd3 commit 90b54ee

3 files changed

Lines changed: 96 additions & 4 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@ Three core modules form the **ingest → drive → emit** spine: `source` brings
4646
events in, `state` decides what happens, and `sink` fans the resulting effects
4747
out. Each is a thin seam you can adopt on its own, and none imports another.
4848

49+
<!--
50+
Canonical Crucible mermaid palette: molten ember/copper over deep steel/charcoal.
51+
These hexes are kept in sync with docs/src/styles/crucible.css and the central
52+
docs theme in docs/src/mermaid-theme.mjs (used by the docs site for every diagram).
53+
GitHub ignores the astro config, so each diagram below carries the same %%{init}%%.
54+
-->
4955
```mermaid
56+
%%{init: {'theme':'base','themeVariables':{'darkMode':true,'background':'#16191d','primaryColor':'#23272c','primaryBorderColor':'#d9620a','primaryTextColor':'#f4f6f8','lineColor':'#c47a3d','secondaryColor':'#353b42','secondaryBorderColor':'#c47a3d','tertiaryColor':'#1b1f24','tertiaryBorderColor':'#2b3036','mainBkg':'#23272c','nodeBorder':'#d9620a','nodeTextColor':'#f4f6f8','clusterBkg':'#1b1f24','clusterBorder':'#c47a3d','titleColor':'#f6a85b','edgeLabelBackground':'#23272c','labelColor':'#f4f6f8','altBackground':'#353b42','textColor':'#f4f6f8'}}}%%
5057
flowchart LR
5158
streams[(external streams)] -->|source| engine[state engine]
5259
engine -->|sink| destinations[(destinations)]
@@ -59,6 +66,7 @@ folds an event into a new instance and emits effects as plain data, leaving
5966
persistence and dispatch to the host.
6067

6168
```mermaid
69+
%%{init: {'theme':'base','themeVariables':{'darkMode':true,'background':'#16191d','primaryColor':'#23272c','primaryBorderColor':'#d9620a','primaryTextColor':'#f4f6f8','lineColor':'#c47a3d','secondaryColor':'#353b42','secondaryBorderColor':'#c47a3d','tertiaryColor':'#1b1f24','tertiaryBorderColor':'#2b3036','mainBkg':'#23272c','nodeBorder':'#d9620a','nodeTextColor':'#f4f6f8','clusterBkg':'#1b1f24','clusterBorder':'#c47a3d','titleColor':'#f6a85b','edgeLabelBackground':'#23272c','labelColor':'#f4f6f8','altBackground':'#353b42','textColor':'#f4f6f8'}}}%%
6270
stateDiagram-v2
6371
[*] --> Idle
6472
Idle --> Working: Start [guard]
@@ -74,6 +82,7 @@ Consumes external streams (Kafka, JetStream, Redis, CDC, and more) and drives a
7482
machine, with the ack tied to a durable transition so redelivery is safe.
7583

7684
```mermaid
85+
%%{init: {'theme':'base','themeVariables':{'darkMode':true,'background':'#16191d','primaryColor':'#23272c','primaryBorderColor':'#d9620a','primaryTextColor':'#f4f6f8','lineColor':'#c47a3d','secondaryColor':'#353b42','secondaryBorderColor':'#c47a3d','tertiaryColor':'#1b1f24','tertiaryBorderColor':'#2b3036','mainBkg':'#23272c','nodeBorder':'#d9620a','nodeTextColor':'#f4f6f8','clusterBkg':'#1b1f24','clusterBorder':'#c47a3d','titleColor':'#f6a85b','edgeLabelBackground':'#23272c','labelColor':'#f4f6f8','altBackground':'#353b42','textColor':'#f4f6f8'}}}%%
7786
flowchart LR
7887
stream[(stream)] --> decode[decode / codec] --> route["route to (key, event)"] --> fire["Fire on instance"] --> commit[durable commit] --> ack[ack]
7988
```
@@ -84,6 +93,7 @@ Fans emitted effects out to many destinations through a `Manifold`,
8493
fire-and-forget; one outlet's failure never stops the rest.
8594

8695
```mermaid
96+
%%{init: {'theme':'base','themeVariables':{'darkMode':true,'background':'#16191d','primaryColor':'#23272c','primaryBorderColor':'#d9620a','primaryTextColor':'#f4f6f8','lineColor':'#c47a3d','secondaryColor':'#353b42','secondaryBorderColor':'#c47a3d','tertiaryColor':'#1b1f24','tertiaryBorderColor':'#2b3036','mainBkg':'#23272c','nodeBorder':'#d9620a','nodeTextColor':'#f4f6f8','clusterBkg':'#1b1f24','clusterBorder':'#c47a3d','titleColor':'#f6a85b','edgeLabelBackground':'#23272c','labelColor':'#f4f6f8','altBackground':'#353b42','textColor':'#f4f6f8'}}}%%
8797
flowchart LR
8898
effect[emitted effect] --> manifold[Manifold]
8999
manifold --> a[destination A]

docs/astro.config.mjs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { defineConfig } from 'astro/config';
33
import starlight from '@astrojs/starlight';
44
import mermaid from 'astro-mermaid';
5+
import { crucibleMermaidThemeVariables } from './src/mermaid-theme.mjs';
56

67
// GitHub project page: https://stablekernel.github.io/crucible
78
// `site` + `base` must match the Pages URL so generated links and assets resolve.
@@ -13,11 +14,27 @@ export default defineConfig({
1314
// Chosen over rehype-mermaid because it needs no headless browser (Playwright)
1415
// at build time, keeping the CI `npm run build` step fast and dependency-light.
1516
// It registers a remark plugin that transforms mermaid code blocks into a
16-
// hydrated <pre class="mermaid"> element. `theme: 'dark'` matches the
17-
// dark-default Crucible brand; mermaid auto-syncs when the user toggles theme.
17+
// hydrated <pre class="mermaid"> element.
18+
//
19+
// Theming is centralized in ./src/mermaid-theme.mjs and applied to every
20+
// diagram on the site (all stateDiagram-v2 + flowchart blocks, and the
21+
// diagrams generated by tools/docsgen). We build on mermaid's `base` theme
22+
// because it is the only theme that honors `themeVariables`, and pass the
23+
// crucible brand palette through `mermaidConfig` (astro-mermaid forwards it
24+
// verbatim to mermaid.initialize()).
25+
//
26+
// autoTheme is OFF deliberately. When on, the integration swaps in stock
27+
// 'dark'/'default' mermaid themes per page mode, which discards most of our
28+
// base themeVariables on toggle. astro-mermaid exposes a single mermaidConfig
29+
// (no per-mode themeVariables), so to keep one source of truth we render the
30+
// dark brand palette in both page modes. Dark charcoal nodes with white text
31+
// stay legible on a light page the same way a fenced code block does.
1832
mermaid({
19-
theme: 'dark',
20-
autoTheme: true,
33+
theme: 'base',
34+
autoTheme: false,
35+
mermaidConfig: {
36+
themeVariables: crucibleMermaidThemeVariables,
37+
},
2138
}),
2239
starlight({
2340
title: 'Crucible',

docs/src/mermaid-theme.mjs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Crucible "foundry" mermaid theme — the single source of truth for diagram
2+
// colors across the docs site (every stateDiagram-v2 + flowchart, plus the
3+
// diagrams generated by tools/docsgen → ToMermaid).
4+
//
5+
// These hexes mirror the brand tokens in src/styles/crucible.css and the
6+
// %%{init}%% directives in the repo-root README.md. Keep all three in sync.
7+
//
8+
// Identity: molten ember/copper accents over a deep steel/charcoal base.
9+
// The brand is dark-default, so we build on mermaid's `base` theme — the only
10+
// theme that honors `themeVariables` (see https://mermaid.js.org/config/theming.html)
11+
// — with `darkMode: true` so derived shades resolve for a dark canvas. Every
12+
// variable name below is a documented mermaid theme variable; nothing invented.
13+
export const crucibleMermaidThemeVariables = {
14+
darkMode: true,
15+
background: '#16191d', // deep steel base canvas
16+
17+
// Primary nodes: charcoal surface, molten-ember border, white label.
18+
primaryColor: '#23272c',
19+
primaryBorderColor: '#d9620a', // ember-orange
20+
primaryTextColor: '#f4f6f8',
21+
22+
// Edges / links: copper, with ember-glow reserved for emphasis (titles).
23+
lineColor: '#c47a3d', // copper
24+
defaultLinkColor: '#c47a3d',
25+
26+
// Secondary nodes: lighter charcoal panel, copper border.
27+
secondaryColor: '#353b42',
28+
secondaryBorderColor: '#c47a3d',
29+
secondaryTextColor: '#f4f6f8',
30+
31+
// Tertiary / deep-composite + subgraph fills: nav-dark with a steel hairline.
32+
tertiaryColor: '#1b1f24',
33+
tertiaryBorderColor: '#2b3036',
34+
tertiaryTextColor: '#e3e7ec',
35+
36+
// Flowchart specifics.
37+
mainBkg: '#23272c',
38+
nodeBorder: '#d9620a',
39+
nodeTextColor: '#f4f6f8',
40+
clusterBkg: '#1b1f24', // subgraph background
41+
clusterBorder: '#c47a3d',
42+
titleColor: '#f6a85b', // ember-glow emphasis on subgraph/diagram titles
43+
edgeLabelBackground: '#23272c',
44+
45+
// stateDiagram-v2 specifics.
46+
labelColor: '#f4f6f8',
47+
altBackground: '#353b42', // deep composite-state background
48+
49+
// General text + notes.
50+
textColor: '#f4f6f8',
51+
noteBkgColor: '#353b42',
52+
noteTextColor: '#f4f6f8',
53+
};
54+
55+
// astro-mermaid passes `mermaidConfig` straight through to mermaid.initialize().
56+
// We pin `theme: 'base'` here too because base is the only themeVariables-aware
57+
// theme; the integration spreads this config and (when autoTheme is on) would
58+
// otherwise swap in stock 'dark'/'default'. We keep autoTheme OFF in the astro
59+
// config so the dark brand palette renders consistently in both page modes —
60+
// dark charcoal nodes with white text stay legible on a light page background,
61+
// the same way a fenced code block does.
62+
export const crucibleMermaidConfig = {
63+
theme: 'base',
64+
themeVariables: crucibleMermaidThemeVariables,
65+
};

0 commit comments

Comments
 (0)