Files
claude-howto/scripts/website_templates/site.css
Luong NGUYEN 0e0115935d refactor(scripts): replace Mermaid.js with Pele for diagrams (#197)
* refactor(website): render diagrams with pinned pele bundle (#195)

* refactor(ci): validate diagrams with pele and fail when missing (#195)

* refactor(epub): render diagrams as flattened pele svg (#195)

* docs: document pele diagram rendering and node 20 setup (#195)

* test(epub): assert numbered labels reach pele unescaped (#195)

* fix(scripts): address review feedback (#195)

* fix(website): keep pele zoom controls off diagram labels (#195)

Pele (zoom: 'auto') draws an opaque zoom box over the top-right corner
of every diagram it shrinks to fit, which hid labels. When that box is
shown, div.mermaid now gets top padding so the diagram starts below it.
Top room rather than side room: Pele lays diagrams out to the content
width, so side padding would shrink them further and re-lay them out.

Zoom also makes each shrunk diagram a tab stop, but the SVG had no
accessible name. Name every SVG Pele draws after the nearest heading
plus its diagram kind ("Architecture - flowchart"). Pele draws a new
<svg> on resize and font load, so the name is set in onRender. SVGs
named by accTitle keep their own name.

* fix(scripts): load the cached pele bundle as ESM on node 20 (#195)

pele_render.mjs imports Pele's ES module build, dist/pele.js, which was
cached as a bare pele.js with no package.json "type": "module" beside
it. Node.js 20.0-20.18 and 22.0-22.6 have no ESM syntax detection, so
they load that file as CommonJS and crash on `export`, failing
check_mermaid.py and build_epub.py on a supported Node.

Cache dist/pele.js as pele.mjs (the same sha256-pinned file) and hand
that path to the helper, so every Node.js >= 20 loads it as an ES
module. A cache holding only pele.js downloads and verifies pele.mjs
once. A test turns off syntax detection to reproduce the old Node
behaviour on newer Node.
2026-10-19 14:17:01 +02:00

152 lines
4.6 KiB
CSS

/* Site-specific styles layered on top of Tailwind. */
html {
font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
}
code,
pre,
kbd,
samp {
font-family: 'JetBrains Mono', ui-monospace, monospace;
}
/* Mermaid diagrams (rendered by Pele). Pele draws with the --pele-* custom
properties below, so the light/dark toggle on <html> restyles diagrams
without re-rendering them. Borders keep >= 3:1 against the page and the
node surface in both themes (WCAG 1.4.11). */
.mermaid {
--pele-font: 'Inter', ui-sans-serif, system-ui, sans-serif;
--pele-font-mono: 'JetBrains Mono', ui-monospace, monospace;
--pele-bg: #f8fafc;
--pele-fg: #0f172a;
--pele-muted: #475569;
--pele-line: #475569;
--pele-surface: #ffffff;
--pele-surface-alt: #f1f5f9;
--pele-border: #64748b;
--pele-accent: #0284c7;
}
.dark .mermaid {
--pele-bg: #020617;
--pele-fg: #e2e8f0;
--pele-muted: #94a3b8;
--pele-line: #94a3b8;
--pele-surface: #0f172a;
--pele-surface-alt: #1e293b;
--pele-border: #64748b;
--pele-accent: #38bdf8;
}
/* Layout applies to the mounted diagram only: a <pre class="mermaid"> left
in place (no JavaScript, or a diagram Pele cannot render) stays a normal,
readable dark code block. Centre and constrain width so diagrams read on
mobile. */
div.mermaid {
background: transparent !important;
padding: 1rem 0;
margin: 1.5rem 0;
text-align: center;
overflow-x: auto;
}
.mermaid svg {
max-width: 100%;
height: auto;
}
/* Pele puts its zoom buttons (a box 56px tall, 8px below the top edge) over
a diagram it shrank to fit, and sets [hidden] on the box when the diagram
fits. Start the diagram below the box so the buttons never cover a label.
Room on top, not on the side: Pele lays the diagram out to the content
width, so side padding would shrink it further and re-lay it out. */
div.mermaid:has(> .pele-zoom:not([hidden])) {
padding-top: calc(8px + 56px + 0.5rem);
}
/* Dark mode: a node whose Mermaid source sets a fill but no text colour
(`style A fill:#e1f5ff`) gets a light fill, so its label would inherit the
light --pele-fg. Give such labels dark text, as in light mode. */
.dark .mermaid .pele-node:has(> [style*="fill:"]) > .pele-label:not([style*="fill:"]) {
fill: #0f172a;
}
/* Prevent prose pre/code from inheriting the Tailwind dark prose background
which can clash with our slate-900 preference. */
.prose pre {
border-radius: 0.5rem;
padding: 1rem 1.25rem;
overflow-x: auto;
line-height: 1.55;
font-size: 0.875rem;
}
.prose pre code {
background: transparent;
padding: 0;
color: inherit;
font-size: inherit;
}
/* Inline code gets a softer treatment than fenced blocks. */
.prose :where(p, li, h1, h2, h3, h4) code {
font-size: 0.875em;
font-weight: 500;
}
/* Tables wrap on mobile rather than forcing horizontal scroll on every page. */
.prose table {
display: block;
overflow-x: auto;
white-space: nowrap;
}
@media (min-width: 768px) {
.prose table {
display: table;
white-space: normal;
}
}
/* Anchor offset so sticky header doesn't cover heading targets. */
.prose :where(h1, h2, h3, h4, h5, h6) {
scroll-margin-top: 6rem;
}
/* Hide focus rings on mouse, keep for keyboard. */
:focus:not(:focus-visible) {
outline: none;
}
/* Pygments syntax highlighting (paired with `markdown` codehilite extension). */
.codehilite { background: transparent; }
.codehilite .hll { background-color: #ffffcc }
.codehilite .c, .codehilite .c1, .codehilite .cm { color: #999988; font-style: italic }
.codehilite .k, .codehilite .kc, .codehilite .kd, .codehilite .kn, .codehilite .kp,
.codehilite .kr, .codehilite .kt { color: #f0883e; font-weight: 600 }
.codehilite .s, .codehilite .s1, .codehilite .s2 { color: #a5d6ff }
.codehilite .nb { color: #79c0ff }
.codehilite .nf { color: #d2a8ff }
.codehilite .o, .codehilite .p { color: #ff7b72 }
.codehilite .m, .codehilite .mi, .codehilite .mf { color: #79c0ff }
.codehilite .nv, .codehilite .vc, .codehilite .vg, .codehilite .vi { color: #ffa657 }
.codehilite .err { color: inherit }
/* Light-theme readability tweaks for code colours. */
:root:not(.dark) .codehilite .k,
:root:not(.dark) .codehilite .kc,
:root:not(.dark) .codehilite .kd,
:root:not(.dark) .codehilite .kn,
:root:not(.dark) .codehilite .kp,
:root:not(.dark) .codehilite .kr,
:root:not(.dark) .codehilite .kt { color: #cf222e; }
:root:not(.dark) .codehilite .s,
:root:not(.dark) .codehilite .s1,
:root:not(.dark) .codehilite .s2 { color: #0a3069; }
:root:not(.dark) .codehilite .nb { color: #0550ae; }
:root:not(.dark) .codehilite .nf { color: #6f42c1; }
:root:not(.dark) .codehilite .m,
:root:not(.dark) .codehilite .mi,
:root:not(.dark) .codehilite .mf { color: #0550ae; }