Skip to content

Commit ead7e99

Browse files
authored
Give the diagrams a muted colour palette in the light scheme (#25)
Mermaid's neutral theme left the nodes almost white. Use the base theme with tinted fills and darker borders of the same hue (blue, green, sand, rose), and muted colours for the pie and the timeline.
1 parent c4bb911 commit ead7e99

1 file changed

Lines changed: 55 additions & 3 deletions

File tree

‎internal/web/static/js/post.js‎

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
const darkQuery = window.matchMedia("(prefers-color-scheme: dark)");
276276

277277
// Dark scheme: a retro terminal on black. Bright phosphor strokes (green, cyan, amber, magenta) on near-black
278-
// fills, not pastels. In the light scheme Mermaid's "neutral" theme is used.
278+
// fills, not pastels. The light scheme has its own, muted palette (LIGHT_THEME).
279279
const DARK_THEME = {
280280
darkMode: true,
281281
background: "#000000",
@@ -331,14 +331,66 @@
331331
cScaleLabel0: "#000000", cScaleLabel1: "#000000", cScaleLabel2: "#000000", cScaleLabel3: "#000000",
332332
cScaleLabel4: "#000000", cScaleLabel5: "#000000", cScaleLabel6: "#ffffff", cScaleLabel7: "#000000",
333333
};
334+
// Light scheme: colour, but muted. Tinted fills with a darker border of the same hue, so nothing is white or
335+
// shouting; "neutral" left the nodes almost white.
336+
const LIGHT_THEME = {
337+
darkMode: false,
338+
background: "#ffffff",
339+
fontSize: "15px",
340+
primaryColor: "#d3e1f0",
341+
primaryTextColor: "#1f2f44",
342+
primaryBorderColor: "#5a7fa8",
343+
secondaryColor: "#d6e8d8",
344+
secondaryTextColor: "#1f3a24",
345+
secondaryBorderColor: "#5d8f63",
346+
tertiaryColor: "#efe2c8",
347+
tertiaryTextColor: "#4a3511",
348+
tertiaryBorderColor: "#a8803a",
349+
mainBkg: "#d3e1f0",
350+
nodeBorder: "#5a7fa8",
351+
nodeTextColor: "#1f2f44",
352+
clusterBkg: "#f1ebdd",
353+
clusterBorder: "#b0894a",
354+
titleColor: "#7a5a1e",
355+
lineColor: "#4b5b70",
356+
textColor: "#1f2937",
357+
edgeLabelBackground: "#ffffff",
358+
actorBkg: "#d3e1f0",
359+
actorBorder: "#5a7fa8",
360+
actorTextColor: "#1f2f44",
361+
actorLineColor: "#9aa8b8",
362+
signalColor: "#3f7d6e",
363+
signalTextColor: "#1f2937",
364+
labelBoxBkgColor: "#efe2c8",
365+
labelBoxBorderColor: "#a8803a",
366+
labelTextColor: "#4a3511",
367+
loopTextColor: "#7a5a1e",
368+
noteBkgColor: "#f0d5df",
369+
noteBorderColor: "#b05c7c",
370+
noteTextColor: "#4a1f33",
371+
activationBkgColor: "#cfe3d0",
372+
activationBorderColor: "#5d8f63",
373+
sequenceNumberColor: "#ffffff",
374+
labelColor: "#1f2f44",
375+
altBackground: "#f3f1ea",
376+
pie1: "#5a7fa8", pie2: "#6aa070", pie3: "#c9a24f", pie4: "#b0698a", pie5: "#b86a64", pie6: "#5f9ea0",
377+
pie7: "#8aa24f", pie8: "#8a78b5", pie9: "#c9875a", pie10: "#5f9a90", pie11: "#a56fa8", pie12: "#b59a4a",
378+
pieTitleTextColor: "#1f2937", pieSectionTextColor: "#ffffff", pieLegendTextColor: "#1f2937",
379+
pieStrokeColor: "#ffffff", pieOuterStrokeColor: "#4b5b70", pieOpacity: "0.95",
380+
cScale0: "#5a7fa8", cScale1: "#6aa070", cScale2: "#c9a24f", cScale3: "#b0698a",
381+
cScale4: "#b86a64", cScale5: "#5f9ea0", cScale6: "#8a78b5", cScale7: "#8aa24f",
382+
cScaleLabel0: "#ffffff", cScaleLabel1: "#ffffff", cScaleLabel2: "#1f2937", cScaleLabel3: "#ffffff",
383+
cScaleLabel4: "#ffffff", cScaleLabel5: "#ffffff", cScaleLabel6: "#ffffff", cScaleLabel7: "#1f2937",
384+
};
385+
334386
function configure(mermaid) {
335387
const dark = darkQuery.matches;
336388
mermaid.initialize({
337389
startOnLoad: false,
338390
securityLevel: "strict",
339391
suppressErrorRendering: true,
340-
theme: dark ? "base" : "neutral",
341-
themeVariables: dark ? DARK_THEME : {},
392+
theme: "base",
393+
themeVariables: dark ? DARK_THEME : LIGHT_THEME,
342394
fontFamily: '"Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
343395
// SVG text labels: HTML labels (foreignObject) are measured with the page's own CSS, which skews the layout.
344396
htmlLabels: false,

0 commit comments

Comments
 (0)