Skip to content

Commit af4fccb

Browse files
authored
Merge pull request #1172 from oasisprotocol/xz/1070-mermaid-dark-mode
docs: Add dark mode CSS to Mermaid SVGs
2 parents 87529e2 + 70fc61c commit af4fccb

File tree

9 files changed

+113
-13
lines changed

9 files changed

+113
-13
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ There are three kinds of image assets used in the docs.
206206
diagram source will be stored along in the .svg file and you will
207207
be able to edit it in the future.
208208

209+
#### Dark Mode
210+
211+
We aim to support dark mode when introducing new assets. We prefer to include
212+
assets with dark mode friendly CSS using `@media (prefers-color-scheme: dark)`
213+
when possible. We generate Mermaid diagrams with dark mode CSS injected, and
214+
export [diagrams.net](https://diagrams.net) diagrams with a transparent
215+
background and "Automatic" appearance.
216+
209217
## Vocabulary
210218

211219
The following is a consistent case-sensitive collection of Oasis-related terms,

docs/build/diagrams/opl-contract-flow.mmd.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/build/diagrams/opl-hyperlane-flow.mmd.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/build/diagrams/opl-hyperlane-pingpong-flow.mmd.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/build/diagrams/opl-router-pingpong-flow.mmd.svg

Lines changed: 1 addition & 1 deletion
Loading

mermaid-theme.css

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
.actor, .labelBox {
2+
stroke: black !important;
3+
stroke-width: 1.5px !important;
4+
fill: #007bff !important;
5+
}
6+
7+
.note {
8+
fill: #007bff !important;
9+
stroke-width: 1px !important;
10+
stroke: black !important;
11+
}
12+
13+
.noteText tspan, .actor tspan, .labelText {
14+
fill: white !important;
15+
}
16+
17+
.loopText, .loopText tspan {
18+
fill: #007bff !important;
19+
}
20+
21+
.actor-line {
22+
stroke: #007bff !important;
23+
stroke-width: 1px;
24+
}
25+
26+
.messageText, .loopText, .labelText, .noteText {
27+
font-size: 15px !important;
28+
stroke: none !important;
29+
background: white !important;
30+
}
31+
32+
.loopLine, line {
33+
stroke: #333 !important;
34+
stroke-width: 1px;
35+
fill: none !important;
36+
}
37+
38+
.activation0 {
39+
fill: #eaecef;
40+
stroke: #333;
41+
}
42+
43+
@media (prefers-color-scheme: dark) {
44+
background-color: #1b1b1d !important;
45+
46+
#arrowhead path{fill:white !important;stroke:white !important;}
47+
48+
.actor, .labelBox {
49+
stroke: white !important;
50+
stroke-width: 1.5px !important;
51+
fill: #1E88E5 !important;
52+
}
53+
54+
.note {
55+
fill: #1E88E5 !important;
56+
stroke-width: 1px !important;
57+
}
58+
59+
.noteText tspan, .actor tspan, .labelText {
60+
fill: white !important;
61+
}
62+
63+
.actor-line {
64+
stroke: white !important;
65+
stroke-width: 1px;
66+
}
67+
68+
.messageLine0, line {
69+
stroke: white !important;
70+
}
71+
72+
.messageText, .labelText, .noteText {
73+
font-size: 15px !important;
74+
fill: white !important;
75+
}
76+
77+
.loopText, .loopText tspan {
78+
font-size: 15px !important;
79+
fill: #1E88E5 !important;
80+
}
81+
82+
.loopLine, line {
83+
stroke: white !important;
84+
stroke-width: 1px;
85+
}
86+
87+
.activation0 {
88+
fill: #666666 !important;
89+
stroke: white;
90+
}
91+
}

mermaid.config.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"themeCSS": ".actor, .labelBox { stroke: black !important; stroke-width: 1.5px !important; fill: #007bff !important } .note { fill: #007bff !important; stroke-width: 1px !important; stroke: black !important; } .noteText tspan, .actor tspan, .labelText { fill: white !important; } .loopText, .loopText tspan { fill: #007bff !important; } .actor-line { stroke: #007bff !important; stroke-width: 1px; } .messageText, .loopText, .labelText, .noteText { font-size: 15px !important; stroke: none !important; background: white !important; } .loopLine, line { stroke: #333 !important; stroke-width: 1px; fill: none !important; } .activation0 { fill: #eaecef; stroke: #333; }",
3-
"deterministicIds": true,
4-
"fontFamily": "Noto Sans",
5-
"actorFontFamily": "Noto Sans",
6-
"noteFontFamily": "Noto Sans",
7-
"messageFontFamily": "Noto Sans",
8-
"personFontFamily": "Noto Sans"
2+
"themeCSS": ".actor, .labelBox { stroke: black !important; stroke-width: 1.5px !important; fill: #007bff !important;}.note { fill: #007bff !important; stroke-width: 1px !important; stroke: black !important;}.noteText tspan, .actor tspan, .labelText { fill: white !important;}.loopText, .loopText tspan { fill: #007bff !important;}.actor-line { stroke: #007bff !important; stroke-width: 1px;}.messageText, .loopText, .labelText, .noteText { font-size: 15px !important; stroke: none !important; background: white !important;}.loopLine, line { stroke: #333 !important; stroke-width: 1px; fill: none !important; }.activation0 { fill: #eaecef; stroke: #333;}@media (prefers-color-scheme: dark) { background-color: #1b1b1d !important; #arrowhead path{fill:white !important;stroke:white !important;} .actor, .labelBox { stroke: white !important; stroke-width: 1.5px !important; fill: #1E88E5 !important; } .note { fill: #1E88E5 !important; stroke-width: 1px !important; } .noteText tspan, .actor tspan, .labelText { fill: white !important; } .actor-line { stroke: white !important; stroke-width: 1px; } .messageLine0, line { stroke: white !important; } .messageText, .labelText, .noteText { font-size: 15px !important; fill: white !important; } .loopText, .loopText tspan { font-size: 15px !important; fill: #1E88E5 !important; } .loopLine, line { stroke: white !important; stroke-width: 1px; } .activation0 { fill: #666666 !important; stroke: white; }}",
3+
"deterministicIds": true,
4+
"fontFamily": "Noto Sans",
5+
"actorFontFamily": "Noto Sans",
6+
"noteFontFamily": "Noto Sans",
7+
"messageFontFamily": "Noto Sans",
8+
"personFontFamily": "Noto Sans"
99
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"docusaurus": "docusaurus",
77
"start": "docusaurus start --no-open",
88
"build": "docusaurus build",
9-
"diagrams": "find -L docs -name '*.mmd' -exec mmdc -i {} -p puppeteer-config.json -c mermaid.config.json ';'",
9+
"mermaid:theme": "CSS_STRING=$(tr -s ' ' < mermaid-theme.css | tr -d '\n') && jq --arg themeCSS \"$CSS_STRING\" '.themeCSS = $themeCSS' mermaid.config.json > mermaid.config.json.temp && mv mermaid.config.json.temp mermaid.config.json",
10+
"diagrams": "yarn mermaid:theme && find -L docs -name '*.mmd' -exec mmdc -i {} -p puppeteer-config.json -c mermaid.config.json ';'",
1011
"swizzle": "docusaurus swizzle",
1112
"deploy": "docusaurus deploy",
1213
"clear": "docusaurus clear",

0 commit comments

Comments
 (0)