mermaid darkmode (#299)

Co-authored-by: panoshu <panos.hu@outlook.com>
This commit is contained in:
panoshu 2023-06-16 15:17:58 +08:00 committed by GitHub
parent d1657cb69b
commit 6516b2a68e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 108 additions and 4 deletions

View File

@ -4,7 +4,11 @@
<script> <script>
var mermaid_config = { var mermaid_config = {
startOnLoad: true, startOnLoad: true,
theme: '<%- theme.plugins.mermaid.theme %>', theme:
"<%- theme.style.darkmode %>" == "auto" &&
window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "<%- theme.plugins.mermaid.theme %>",
logLevel: 3, logLevel: 3,
themeVariables: { themeVariables: {
darkMode: true darkMode: true
@ -12,10 +16,10 @@
flowchart: { flowchart: {
useMaxWidth: false, useMaxWidth: false,
htmlLabels: true, htmlLabels: true,
curve: 'linear' curve: "linear"
}, },
gantt: { gantt: {
axisFormat: '%m/%d/%Y' axisFormat: "%Y/%m/%d"
}, },
sequence: { sequence: {
actorMargin: 50 actorMargin: 50

View File

@ -8,3 +8,103 @@ pre.mermaid {
width: 100%; width: 100%;
display: inline-block; display: inline-block;
} }
set_mermaid_darkmode()
.mermaid {
fill: #ccc !important;
}
.mermaid .error-icon {
fill: #a44141 !important;
}
.mermaid .error-text {
fill: #ddd !important;
stroke: #ddd !important;
}
.mermaid .marker {
fill: lightgrey !important;
stroke: lightgrey !important;
}
.mermaid .marker.cross {
stroke: lightgrey !important;
}
.mermaid .label {
color: #ccc !important;
}
.mermaid .cluster-label text {
fill: #F9FFFE !important;
}
.mermaid .cluster-label span {
color: #F9FFFE !important;
}
.mermaid .label text,
.mermaid span {
fill: #ccc !important;
color: #ccc !important;
}
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon,
.mermaid .node path {
fill: #1f2020 !important;
stroke: #81B1DB !important;
}
.mermaid .arrowheadPath {
fill: lightgrey !important;
}
.mermaid .edgePath .path {
stroke: lightgrey !important;
}
.mermaid .flowchart-link {
stroke: lightgrey !important;
}
.mermaid .edgeLabel {
background-color: hsl(0, 0%, 34.4117647059%) !important;
}
.mermaid .edgeLabel rect {
background-color: hsl(0, 0%, 34.4117647059%) !important;
fill: hsl(0, 0%, 34.4117647059%) !important;
}
.mermaid .cluster rect {
fill: hsl(180, 1.5873015873%, 28.3529411765%) !important;
stroke: rgba(255, 255, 255, 0.25) !important;
}
.mermaid .cluster text {
fill: #F9FFFE !important;
}
.mermaid .cluster span {
color: #F9FFFE !important;
}
.mermaid div.mermaidTooltip {
background: hsl(20, 1.5873015873%, 12.3529411765%) !important;
border: 1px solid rgba(255, 255, 255, 0.25) !important;
}
.mermaid .flowchartTitleText {
fill: #ccc;
}
if hexo-config('style.darkmode') == 'auto'
@media (prefers-color-scheme: dark)
set_mermaid_darkmode()
if hexo-config('style.darkmode') == 'always'
set_mermaid_darkmode()