From a38cccc395b7a5bac2d49bfec53c03f577ff6d0b Mon Sep 17 00:00:00 2001 From: Gabriel Darbord <78592838+Gabriel-Darbord@users.noreply.github.com> Date: Mon, 23 Nov 2026 17:26:47 +0100 Subject: [PATCH] Soften the dark theme to VS Code's Dark Modern The dark theme takes VS Code's soft greys and token colours instead of near-black and near-white; code blocks use Dark+, and diagrams draw with the page's own colours rather than Mermaid's high-contrast dark theme. Co-Authored-By: Claude Opus 5.5 --- astro.config.mjs | 2 +- src/components/Mermaid.astro | 25 ++++++++++++++++++++++++- src/styles/global.css | 25 +++++++++++++------------ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index fbf5c50..2d8895d 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -20,7 +20,7 @@ export default defineConfig({ integrations: [ // Before mdx, so MDX posts get the same code blocks. expressiveCode({ - themes: ['github-light', 'github-dark'], + themes: ['github-light', 'dark-plus'], themeCssSelector: (theme) => `[data-theme='${theme.type}']`, useDarkModeMediaQuery: false, shiki: { langAlias: { st: 'smalltalk', ston: 'smalltalk' } }, diff --git a/src/components/Mermaid.astro b/src/components/Mermaid.astro index 2c2ef59..af3768e 100644 --- a/src/components/Mermaid.astro +++ b/src/components/Mermaid.astro @@ -6,7 +6,30 @@ const { default: mermaid } = await import('mermaid'); const draw = async () => { const dark = document.documentElement.dataset.theme === 'dark'; - mermaid.initialize({ startOnLoad: false, theme: dark ? 'dark' : 'default' }); + // In the dark, the page's own soft greys rather than Mermaid's high-contrast dark theme. + const color = (name: string) => getComputedStyle(document.documentElement).getPropertyValue(name).trim(); + mermaid.initialize( + dark + ? { + startOnLoad: false, + theme: 'base', + themeVariables: { + darkMode: true, + background: color('--surface'), + primaryColor: color('--code-bg'), + primaryTextColor: color('--text'), + primaryBorderColor: color('--border'), + secondaryColor: color('--accent-soft'), + tertiaryColor: color('--surface'), + lineColor: color('--muted'), + textColor: color('--text'), + clusterBkg: color('--bg'), + clusterBorder: color('--border'), + edgeLabelBackground: color('--surface'), + }, + } + : { startOnLoad: false, theme: 'default' }, + ); for (const diagram of diagrams) { diagram.removeAttribute('data-processed'); diagram.textContent = diagram.dataset.source!; diff --git a/src/styles/global.css b/src/styles/global.css index 3b732ef..7bdb5d3 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -19,18 +19,19 @@ } :root[data-theme='dark'] { - --bg: #14161a; - --surface: #1b1e23; - --text: #e6e7ea; - --muted: #9aa1ad; - --border: #2c3038; - --accent: #7aa7f0; - --accent-soft: #1d2a40; - --code-bg: #22262d; - --kind-guide: #5fc792; - --kind-experiment: #c29af2; - --kind-project: #7aa7f0; - --kind-news: #eb9b55; + /* VS Code's Dark Modern: soft greys and its token colours, rather than near-black and white. */ + --bg: #1f1f1f; + --surface: #252526; + --text: #cccccc; + --muted: #9d9d9d; + --border: #3c3c3c; + --accent: #4daafc; + --accent-soft: #263445; + --code-bg: #2d2d2d; + --kind-guide: #73c991; + --kind-experiment: #c586c0; + --kind-project: #4daafc; + --kind-news: #ce9178; color-scheme: dark; }