-
Notifications
You must be signed in to change notification settings - Fork 99
fix(ui): make mermaid diagrams readable in dark mode #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ced895a
6ecc579
de040a3
2a26995
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,12 +67,10 @@ graph TD | |
| POD --> SCHED --> INJECT --> WEBHOOK --> CONTAINER --> ENFORCE | ||
| DAEMON -. "加载 libvgpu.so" .-> CONTAINER | ||
|
|
||
| style SCHED fill:#d9f99d,stroke:#4f7d00,stroke-width:2px,color:#1f2937 | ||
| style INJECT fill:#d9f99d,stroke:#4f7d00,stroke-width:2px,color:#1f2937 | ||
| style WEBHOOK fill:#dbeafe,stroke:#1a5fb4,stroke-width:2px,color:#1f2937 | ||
| style DAEMON fill:#dbeafe,stroke:#1a5fb4,stroke-width:2px,color:#1f2937 | ||
| style CONTAINER fill:#fef3c7,stroke:#b45309,stroke-width:2px,color:#1f2937 | ||
| style ENFORCE fill:#dcfce7,stroke:#0b6b3c,stroke-width:2px,color:#1f2937 | ||
| class SCHED,INJECT kai | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, |
||
| class WEBHOOK,DAEMON info | ||
| class CONTAINER run | ||
| class ENFORCE ok | ||
| ``` | ||
|
|
||
| 工作流程分为四个阶段: | ||
|
|
@@ -92,8 +90,8 @@ graph TD | |
| B2 --> B3["无法超额<br/>硬隔离"] | ||
|
|
||
| A3 ~~~ B1 | ||
| style A3 fill:#fee2e2,stroke:#b3261e,stroke-width:2px,color:#1f2937 | ||
| style B3 fill:#dcfce7,stroke:#0b6b3c,stroke-width:2px,color:#1f2937 | ||
| class A3 bad | ||
| class B3 ok | ||
| ``` | ||
|
|
||
| ### 部署方式 | ||
|
|
@@ -199,8 +197,8 @@ graph TD | |
| HAMI --> Kueue | ||
| HAMI --> Koordinator | ||
|
|
||
| style HAMI fill:#dbeafe,stroke:#1a5fb4,stroke-width:2px,color:#1f2937 | ||
| style KAI fill:#d9f99d,stroke:#4f7d00,stroke-width:2px,color:#1f2937 | ||
| class HAMI info | ||
| class KAI accent | ||
| ``` | ||
|
|
||
| ### 为用户创造实际价值 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,6 +145,23 @@ | |
| rgba(241, 246, 250, 0.95) | ||
| ); | ||
| --hami-diagram-outcome-bg: rgba(255, 255, 255, 0.62); | ||
|
|
||
| /* mermaid class roles: accent, info, run, ok, bad */ | ||
| --hami-mermaid-accent-fill: #d9f99d; | ||
| --hami-mermaid-accent-stroke: #4f7d00; | ||
| --hami-mermaid-accent-text: #1f2937; | ||
| --hami-mermaid-info-fill: #dbeafe; | ||
| --hami-mermaid-info-stroke: #1a5fb4; | ||
| --hami-mermaid-info-text: #1f2937; | ||
| --hami-mermaid-run-fill: #fef3c7; | ||
| --hami-mermaid-run-stroke: #b45309; | ||
| --hami-mermaid-run-text: #1f2937; | ||
| --hami-mermaid-ok-fill: #dcfce7; | ||
| --hami-mermaid-ok-stroke: #0b6b3c; | ||
| --hami-mermaid-ok-text: #1f2937; | ||
| --hami-mermaid-bad-fill: #fee2e2; | ||
| --hami-mermaid-bad-stroke: #b3261e; | ||
| --hami-mermaid-bad-text: #1f2937; | ||
| } | ||
|
|
||
| :root[data-theme="dark"] { | ||
|
|
@@ -247,6 +264,22 @@ | |
| ); | ||
| --hami-diagram-outcome-bg: rgba(255, 255, 255, 0.04); | ||
|
|
||
| --hami-mermaid-accent-fill: #365314; | ||
| --hami-mermaid-accent-stroke: #a3e635; | ||
| --hami-mermaid-accent-text: #ecfccb; | ||
| --hami-mermaid-info-fill: #1e3a5f; | ||
| --hami-mermaid-info-stroke: #60a5fa; | ||
| --hami-mermaid-info-text: #dbeafe; | ||
| --hami-mermaid-run-fill: #78350f; | ||
| --hami-mermaid-run-stroke: #fbbf24; | ||
| --hami-mermaid-run-text: #fef3c7; | ||
| --hami-mermaid-ok-fill: #14532d; | ||
| --hami-mermaid-ok-stroke: #4ade80; | ||
| --hami-mermaid-ok-text: #dcfce7; | ||
| --hami-mermaid-bad-fill: #7f1d1d; | ||
| --hami-mermaid-bad-stroke: #f87171; | ||
| --hami-mermaid-bad-text: #fee2e2; | ||
|
|
||
| --ifm-navbar-search-input-icon: url("data:image/svg+xml;utf8,<svg fill='rgba(255,255,255,0.5)' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' height='16px' width='16px'><path d='M6.02945,10.20327a4.17382,4.17382,0,1,1,4.17382-4.17382A4.15609,4.15609,0,0,1,6.02945,10.20327Zm9.69195,4.2199L10.8989,9.59979A5.88021,5.88021,0,0,0,12.058,6.02856,6.00467,6.00467,0,1,0,9.59979,10.8989l4.82338,4.82338a.89729.89729,0,0,0,1.29912,0,.89749.89749,0,0,0-.00087-1.29909Z'/></svg>"); | ||
| } | ||
|
|
||
|
|
@@ -408,24 +441,96 @@ body.hami-lightbox-open { | |
| align-items: center; | ||
| justify-content: center; | ||
| overflow: hidden; | ||
| background: #ffffff; | ||
| background: var(--ifm-background-color); | ||
| border-radius: 12px; | ||
| box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45); | ||
| padding: 16px; | ||
| cursor: zoom-out; | ||
| } | ||
|
|
||
| /* Mermaid renders a dark-theme variant in dark mode (light text, dark | ||
| fills), so the zoom card must follow the color mode or contrast breaks. */ | ||
| html[data-theme="dark"] .hami-lightbox__svg { | ||
| background: var(--ifm-background-surface-color); | ||
| .hami-lightbox__svg .docusaurus-mermaid-container { | ||
| width: 100%; | ||
| height: 100%; | ||
| cursor: zoom-out; | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container { | ||
| cursor: zoom-in; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container svg { | ||
| background: transparent !important; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nothing stops a new diagram from using an unknown class name and silently getting no fill. would a classDef in the diagram, or a lint rule, catch that earlier? |
||
| } | ||
|
|
||
| /* mermaid leaves subgraph titles / edge labels dark even on the dark theme */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. checked the targets: docusaurus-mermaid-container is theme-mermaid's own wrapper and nodeLabel, cluster-label, edgeLabel and labelBkg all exist in the mermaid bundle, so these selectors are real. |
||
| .docusaurus-mermaid-container .cluster-label, | ||
| .docusaurus-mermaid-container .cluster-label span, | ||
| .docusaurus-mermaid-container .cluster span, | ||
| .docusaurus-mermaid-container .edgeLabel, | ||
| .docusaurus-mermaid-container .edgeLabel span, | ||
| .docusaurus-mermaid-container .edgeLabel p { | ||
| color: var(--ifm-font-color-base) !important; | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container .cluster-label text, | ||
| .docusaurus-mermaid-container .edgeLabel text { | ||
| fill: var(--ifm-font-color-base) !important; | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container .edgeLabel, | ||
| .docusaurus-mermaid-container .edgeLabel p, | ||
| .docusaurus-mermaid-container .labelBkg { | ||
| background-color: var(--ifm-background-color) !important; | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container .edgeLabel rect { | ||
| background-color: var(--ifm-background-color) !important; | ||
| fill: var(--ifm-background-color) !important; | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container .accent { | ||
| --hami-mermaid-node-fill: var(--hami-mermaid-accent-fill); | ||
| --hami-mermaid-node-stroke: var(--hami-mermaid-accent-stroke); | ||
| --hami-mermaid-node-text: var(--hami-mermaid-accent-text); | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container .info { | ||
| --hami-mermaid-node-fill: var(--hami-mermaid-info-fill); | ||
| --hami-mermaid-node-stroke: var(--hami-mermaid-info-stroke); | ||
| --hami-mermaid-node-text: var(--hami-mermaid-info-text); | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container .run { | ||
| --hami-mermaid-node-fill: var(--hami-mermaid-run-fill); | ||
| --hami-mermaid-node-stroke: var(--hami-mermaid-run-stroke); | ||
| --hami-mermaid-node-text: var(--hami-mermaid-run-text); | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container .ok { | ||
| --hami-mermaid-node-fill: var(--hami-mermaid-ok-fill); | ||
| --hami-mermaid-node-stroke: var(--hami-mermaid-ok-stroke); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the child combinator needs the shape to sit directly under the classed g. the site is on mermaid 11.17, where some shapes gain an extra wrapper g. did you check this on every shape the diagrams use, or only the default rect? |
||
| --hami-mermaid-node-text: var(--hami-mermaid-ok-text); | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container .bad { | ||
| --hami-mermaid-node-fill: var(--hami-mermaid-bad-fill); | ||
| --hami-mermaid-node-stroke: var(--hami-mermaid-bad-stroke); | ||
| --hami-mermaid-node-text: var(--hami-mermaid-bad-text); | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container | ||
| :is(.accent, .info, .run, .ok, .bad) | ||
| > :is(rect, polygon, circle, ellipse, path) { | ||
| fill: var(--hami-mermaid-node-fill) !important; | ||
| stroke: var(--hami-mermaid-node-stroke) !important; | ||
| stroke-width: 2px !important; | ||
| } | ||
|
|
||
| .docusaurus-mermaid-container :is(.accent, .info, .run, .ok, .bad) :is(.nodeLabel, span) { | ||
| color: var(--hami-mermaid-node-text) !important; | ||
| } | ||
|
|
||
| .mermaid-figure { | ||
| margin: 0 0 1.5rem; | ||
| text-align: center; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the css only defines accent, info, run, ok and bad. there is no
.kairule, so these two nodes lose the green fill they had before. should this beaccent?