mermaidの配色をダーク基調+水色アクセントに刷新 - #184
Closed
riiimparm wants to merge 10 commits into
Closed
Conversation
デフォルトの水色/グレー基調からサイトのダークネイビー系配色に変更し、 フォントもInter Variable / Noto Sans JP Variableに揃えた。
サイト自体はライトテーマのため、mermaid図だけをダークネイビー背景 (#0f172a)+水色(#38bdf8/#22d3ee)アクセントのコードエディタ風配色にし、 周囲の白背景と馴染むようカード状のコンテナで囲んだ。 あわせて、mermaid描画スクリプトが生成するTailwindユーティリティクラス (min-h-[100px]など)がcontent globの対象外(.mjs)でパージされ、 背景色などが効いていなかった問題をインラインstyleに切り替えて修正。
flowchart/sequence/stateの3種のmermaid図を含み、ダーク背景+水色 アクセント配色の見た目を確認するための証跡として残す。
デスクトップでコンテナに80vwのmax-widthを、SVGにwidth/height:auto + max-width:100% + max-height:90vhを適用し、アスペクト比を保ったまま ビューポートに収まるようスケールダウンさせる(feature/d2-codeblockと同じ方式)。
pieはthemeVariablesにpie/git系の専用変数が無かったため、pie1-12が ほぼ同一のダークネイビーになりスライスの見分けがつかなかった。 gitGraphもブランチラベルのチップがmermaidデフォルトの薄い色のまま 浮いていた。pie1-12・git0-7とその関連ラベル色を既存のダーク基調+ 水色アクセントに合わせて追加。
developにマージされたastro-expressive-code対応(PR #177)により、 生HTMLとして埋め込んだmermaidのpre/codeも1行ずつ.ec-line divで ラップされるようになった。code.textContentだけでは行間の改行が 失われて1行に潰れてしまい、flowchart/class diagram/gitGraph/ mindmapなどインデントや改行に依存する構文でパースエラーになる ことを確認した。.ec-lineがあれば行ごとのtextContentを改行で 結合し直すことで解消し、12種類のダイアグラム全てで再検証した。
Member
There was a problem hiding this comment.
@riiimparm
style src/layouts/BlogLayout.astro の <style> で指定できないかなあ
変数定期済みのマージンなど使い回せるからこっちに記載しても良いかなと思いました!
Collaborator
Author
|
レイアウトやレンダリング統合のため #185 にて変更するためクローズ |
riiimparm
added a commit
that referenced
this pull request
Aug 29, 2026
クライアント側でCDNからmermaid.jsを読み込んでレンダリングしていたのを廃止し、 puppeteer経由の@mermaid-js/mermaid-cli(renderMermaid)でビルド時にSVGへ変換して public/images/blog/<slug>/に保存する方式に変更。d2と同じくthemeはmermaidの デフォルトテーマを使用する。 d2/mermaid共通で使うコンテナ用CSS(サイジング・中央寄せ)は各remarkプラグインの per-article style注入から、src/layouts/BlogLayout.astroのグローバルCSSに寄せ、 クラス名も.d2-container/.d2-diagramから.diagram-container/.diagram-frameへ 統一した。
riiimparm
added a commit
that referenced
this pull request
Aug 29, 2026
mermaid本体のlook:'handDrawn'は図種によって効かないものがあった(gantt/pie等) ため、レンダリング後のSVGをsvg2roughjs(rough.js)で後処理する方式に変更。 図種によらず一様に手描き風の揺らぎ・ハッチングが適用されるようになった。 mermaidはデフォルトでラベルをforeignObject(HTML)で描画しており、 svg2roughjsがそれを正しく手描き変換できず日本語ラベルが文字化けしていた。 htmlLabels:falseでネイティブSVGの<text>を強制することで解決した。 あわせてsvg2roughjsの出力(viewBoxを持たずwidth/height属性のみ)に 対応するようextractSize()にフォールバックを追加。
riiimparm
added a commit
that referenced
this pull request
Aug 29, 2026
theme:'base'+themeVariablesで、mermaidの配色をD2の実際のパレット値 (fill-B4:#E3E9FD、stroke-B1:#0D32B2、fill-N1:#0A0F25等)に合わせた。 mermaid公式のtheming docsに載っている変数を参照し、フローチャート/ シーケンス図/ノート/円グラフ/状態遷移図など今回使用する図種に関連する 項目を網羅的に設定している。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
変更内容
mermaidのデフォルト配色をダーク基調+水色アクセントに変更
フォントを本文と同じInter/Noto Sans JPに統一
図コンテナのスタイルをTailwindクラス文字列からインラインstyleに変更(
.mjsはTailwindのcontentスキャン対象外)デスクトップ:
max-width:80vwスマホ:
width/height:auto+max-width:100%+max-height:90vhテスト用md