Skip to content

Commit

Permalink
Styling changes, Mermaid sequence diagrams styling
Browse files Browse the repository at this point in the history
Update Mermaid to v11.3.0 (gotten from https://unpkg.com/[email protected]/dist/mermaid.min.js)

Styles are now compiled into one CSS file with Sass.

Added theming for Mermaid sequence diagrams, works great on both light and dark modes.
  • Loading branch information
PJB3005 committed Oct 13, 2024
1 parent 1d53286 commit 65dacc5
Show file tree
Hide file tree
Showing 9 changed files with 1,925 additions and 711 deletions.
2 changes: 1 addition & 1 deletion book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ before = ["mermaid","admonish","emojicodes"] # templates can include these so we

[output.html]
additional-js = ['scripts/mermaid.min.js', 'scripts/mermaid-init.js', 'scripts/nav-additions.js']
additional-css = ['theme/mdbook-admonish.css', 'theme/ss14.css', 'theme/nav-style.css']
additional-css = ['theme/compiled/ss14.css']
default-theme = "navy"
preferred-dark-theme = "navy"

Expand Down
1,997 changes: 1,287 additions & 710 deletions scripts/mermaid.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions scss/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Build with
// sass ./scss/main.scss ./theme/compiled/ss14.css
// Get sass with "npm install -g sass"

@use "ss14";
@use "ss14-mermaid.scss";
@use "mdbook-admonish";
@use "nav-style";

File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions scss/ss14-mermaid.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// These all have to be !important because Mermaid sets all of them based on ID matches, which sucks.

html {
--mermaid-sequence-actor-bg: #2d4c5a;
--mermaid-sequence-actor-stroke: #2a3355;

--mermaid-sequence-note-bg: #2d5a44;
--mermaid-sequence-note-stroke: #253d31;

--mermaid-sequence-rect-bg: #21273C;
}

// Light themes.
.light, .rust {
--mermaid-sequence-actor-bg: #cde498;
--mermaid-sequence-actor-stroke: #a6cf47;

--mermaid-sequence-note-bg: #fff5ad;
--mermaid-sequence-note-stroke: #aaaa33;

--mermaid-sequence-rect-bg: #abe5f3;
}

pre.mermaid svg[aria-roledescription="sequence"] {
defs > #arrowhead > path {
fill: var(--fg) !important;
stroke: var(--fg) !important;
}
.actor {
fill: var(--mermaid-sequence-actor-bg) !important;
stroke: var(--mermaid-sequence-actor-stroke) !important;
}

.actor > tspan, .messageText, .loopText, .loopText > tspan, .noteText > tspan {
fill: var(--fg) !important;
}

.actor-line, .messageLine0, .messageLine1, .loopLine {
stroke: var(--fg) !important;
}

.note {
fill: var(--mermaid-sequence-note-bg) !important;
stroke: var(--mermaid-sequence-note-stroke) !important;
}

.rect {
fill: var(--mermaid-sequence-rect-bg) !important;
}
}
File renamed without changes.
Loading

0 comments on commit 65dacc5

Please sign in to comment.