docs(read-diagrams): make crow's-foot ER diagrams dark-mode adaptive - #269
docs(read-diagrams): make crow's-foot ER diagrams dark-mode adaptive#269dimitri-yatsenko wants to merge 2 commits into
Conversation
The four er-*.svg crow's-foot diagrams (Mermaid erDiagram exports) had baked-in light-only colors and no prefers-color-scheme block, so they stayed light on a dark page — unlike the dj.Diagram SVGs, which adapt. Inject a @media (prefers-color-scheme: dark) block into each (same mechanism as the dj.Diagram outputs), remapping panels/rows/strokes/text to a brand-family dark palette (navy-tinted panels, grey rules, light text) per dj-brand V1.0. Light mode is unchanged.
MilagrosMarin
left a comment
There was a problem hiding this comment.
Verified the mechanism and the claims against main; the diagnosis is right and the approach is the correct one. One thing got missed in the enumeration.
Checks that hold:
- The four ER SVGs carry no
prefers-color-schemeblock; the notebook's 19 inlinedj.Diagramoutputs carry exactly one each. The stated cause is the actual cause. - Light mode is untouched — all four files are a clean pure-insertion of the identical 610-byte block, every surrounding byte unchanged. (Minor: it's inserted at the end of the
<style>element, not appended to the file — which is the right place; only the description says "appended.") prefers-color-schemeis the only mechanism available, since these are<img src="/images/…">and can't see the page'sdata-md-color-scheme. The note about the manual toggle is accurate.- Hues line up with the brand: grey 216° against
--dj-grey216°, navy 226–227° against--dj-navy231°. - Against the slate background (
hsl(225,15%,14%)=#1e2129): border 5.19:1, text 11.73:1, edge labels 7.87:1.
The crow's-foot markers keep their light-mode fill
Light mode sets both channels:
#my-svg .marker{fill:#666;stroke:#666;}The dark block overrides only stroke. That would be harmless if the markers were stroke-only, but the crow's foot is a closed shape:
<marker class="marker oneOrMore er"><path d="M9,18 Q27,0 45,18 Q27,36 9,18"/></marker>
Two quadratics returning to the start point — a filled lens. The path carries no inline fill, so it inherits #666 from the marker element. In dark mode it renders as a #666 interior inside a #aeb6c2 outline, where light mode has the two matching.
Measured against #1e2129:
| contrast | |
|---|---|
marker fill #666 (unchanged) |
2.80:1 — below the 3:1 in WCAG 1.4.11 for graphical objects |
marker stroke #aeb6c2 (new) |
7.87:1 |
| fill against its own outline | 2.81:1 |
#666 is one of the enumerable colors in all four files, so this is the gap in "remapping every color the four files use." It also happens to land on the notation the page exists to explain.
One declaration fixes it:
#my-svg .marker{fill:#aeb6c2;stroke:#aeb6c2!important;}The optionality circles are unaffected — <circle fill="white"> still resolves to #161a21, because [fill="white"] matches the circle directly and beats inheritance from the parent <marker>.
Two nits
- "Match the sibling
dj.Diagramdark theme" is true by family but not by value — the siblings use#242832/#9DA0A4/#C9CFD9where this uses#242a3d/#8a93a1/#aeb6c2. Fine as-is; worth knowing the two sets can drift apart. - The
!importantonstrokelooks unnecessary: the dark block is later in the same stylesheet at equal specificity, so it already wins.
|
Careful review, and the mechanism checks you ran are the right ones. Two of the three findings do not survive a look at the full cascade, and the reason is the same rule in both cases. The markers are already unfilled — in both modesMermaid emits two #my-svg .marker{fill:#666;stroke:#666;} /* first */
#my-svg .marker{fill:none!important;stroke:#666!important;stroke-width:1;} /* second */
Adding The
|
Fixes the crow's-foot ER diagrams on how-to/read-diagrams not adapting to dark mode. (The
dj.Diagramoutputs on that page already adapt — this is only the four traditional-ERD comparison figures.)Cause
er-one-to-one.svg,er-one-to-many.svg,er-reference.svg,er-many-to-many.svgare MermaiderDiagramexports with baked-in light-only colors (fill:#eee/#f4f4f4/white,stroke:#999/#666, black text) and noprefers-color-schemeblock — so they stayed light on a dark page, while thedj.DiagramSVGs adapt because they carry that block.Fix
Inject a
@media (prefers-color-scheme: dark)block into each SVG — the same mechanism thedj.Diagramoutputs use — remapping every color the four files use (enumerated to be complete): entity panels and rows to navy-tinted darks, rules/relationship lines/crow's-foot markers to grey, text to light. Colors follow dj-brand V1.0 (navy structure, grey secondary) and match the siblingdj.Diagramdark theme. Light mode is byte-for-byte unchanged (block only inserted at the end of the<style>element).Note
Like the
dj.DiagramSVGs, this follows the OSprefers-color-scheme. The site's palette auto-selects the dark (slate) scheme under OS-dark, so they move together. A manual palette toggle that overrides the OS setting is a pre-existing limitation shared by all embedded SVGs here, out of scope for this fix.Revised after review (@MilagrosMarin):
dj-brand's ratified dark diagram table rather than being picked by eye: panel#242832, rules and borders#9DA0A4, lines, markers and edge labels#C9CFD9, body#E8EAF0. This keeps these four figures on the same dark theme as thedj.Diagramsiblings instead of a second one that could drift. Thresholds all hold or improve: border 6.13:1 (was 5.19), text 10.28:1 on the slate and 9.41:1 on the panel, panel 1.09:1 against the page so it still reads as a panel.#20263a,#1b2136) stay as they are — they sit between the panel and the page and have no ratified equivalent.!importanton the darkstrokeis kept deliberately: mermaid's own light rule isstroke:#666!important, so removing it would revert the markers to#666at 2.80:1 in dark mode.filladded to.marker: mermaid's second.markerrule setsfill:none!important, so the crow's foot is an unfilled outline in both themes and the#666fill declaration never renders.