Editorial diagram design for Claude Code, Codex, GitHub Copilot, Cursor, Factory Droid, Qoder, and Pi. 45 diagram types. Self-contained HTML + SVG. No shadows. No Mermaid slop.
fix(templates): give every template a local scroller and a viewBox-matched min-width (#245)
HunterKK14240953f12d6e53
diff --git a/scripts/lint-render.py b/scripts/lint-render.pyindex d3d5630..3d03333 100755--- a/scripts/lint-render.py+++ b/scripts/lint-render.py@@ -61,6 +61,12 @@ layer. ``--fonts`` excludes exactly the two Google Fonts hostnames from theresolver block and allows them only over HTTPS on an exact hostname match.``--self-test`` proves the isolation against a local listener.+One check sits outside that browser: ``--all`` and ``--self-test`` run the PNG+rasterize snippet from ``references/export.md`` in a subprocess, the way the doc+tells a user to, on local fixtures (the shipped templates re-drawn at a wide+preset, with every remote ``<link>`` removed). That subprocess's Chromium is not+under the resolver block, which is why the fixtures carry no remote references.+Because the oracle is pixels, CI must pin Playwright and its bundled Chromiumrather than taking whatever is newest; see ``.github/workflows/ci.yml``.@@ -76,7 +82,9 @@ Requires Playwright (same dev dependency the PNG export uses):import argparseimport base64import os+import reimport socket+import subprocessimport sysimport tempfileimport threading@@ -85,6 +93,7 @@ from urllib.parse import urlparseROOT = Path(__file__).resolve().parent.parentASSET_DIR = ROOT / "skills/diagram-design/assets"+EXPORT_DOC = ROOT / "skills/diagram-design/references/export.md"VIEWPORT = {"width": 1600, "height": 1000}TOLERANCE = 1.0 # px of slop before page overflow counts, absorbs subpixel layout@@ -884,6 +893,249 @@ def marimekko_mobile_failures(context, marimekko_paths=None):return failures+def template_mobile_failures(context, template_paths=None):+ """Every template must survive a phone, because every diagram starts as one.++ Two defects, both invisible on a desktop:++ * An SVG whose ``min-width`` exceeds the viewport with no local scroller+ drags the whole document sideways, and the nodes on the right are simply+ gone unless the reader thinks to scroll the page.+ * When an ancestor is ``overflow: hidden`` (the terminal template's window+ chrome), the same SVG is clipped instead: no scrollbar, no page overflow,+ nothing for a page-overflow check to see. The content is unreachable and+ the linter reports the file clean.++ ``min-width`` must also equal the viewBox width. Anything smaller scales the+ whole drawing down and silently takes the type ramp with it - a 12px node+ name on a 1280 viewBox pinned at 900 draws at 8.4px, under every floor the+ style guide sets.+ """+ paths = template_paths or sorted(ASSET_DIR.glob("template*.html"))+ failures = []+ for path in paths:+ page = context.new_page()+ page.set_viewport_size({"width": 390, "height": 844})+ try:+ page.goto(path.as_uri(), wait_until="load")+ facts = page.evaluate(+ """+ () => {+ const doc = document.documentElement;+ const svg = document.querySelector('svg');+ if (!svg) return { missingSvg: true };+ let ancestor = svg.parentElement;+ let localScroller = false, clipped = false;+ while (ancestor && ancestor !== document.body) {+ const overflow = getComputedStyle(ancestor).overflowX;+ const overflows = ancestor.scrollWidth > ancestor.clientWidth + 1;+ if ((overflow === 'auto' || overflow === 'scroll') && overflows) {+ localScroller = true;+ break;+ }+ if (overflow === 'hidden' && overflows) clipped = true;+ ancestor = ancestor.parentElement;+ }+ const viewBox = (svg.getAttribute('viewBox') || '').trim().split(/[ ,]+/);+ return {+ missingSvg: false,+ pageOverflow: doc.scrollWidth - doc.clientWidth,+ svgWidth: svg.getBoundingClientRect().width,+ minWidth: parseFloat(getComputedStyle(svg).minWidth) || 0,+ viewBoxWidth: viewBox.length === 4 ? parseFloat(viewBox[2]) : 0,+ localScroller,+ clipped,+ };+ }+ """+ )+ finally:+ page.close()++ shown_path = display_path(path)+ if facts["missingSvg"]:+ failures.append(f"{shown_path}: template-mobile-svg: no SVG found")+ continue+ if facts["pageOverflow"] > TOLERANCE:+ failures.append(+ f"{shown_path}: template-mobile-page-overflow: page extends "+ f"{facts['pageOverflow']:.1f}px past the 390px viewport"+ )+ if facts["clipped"] and not facts["localScroller"]:+ failures.append(+ f"{shown_path}: template-mobile-clipped: an overflow:hidden ancestor cuts the "+ f"{facts['svgWidth']:.0f}px SVG off with no scroller - the content is unreachable"+ )+ if facts["minWidth"] > TOLERANCE and not facts["localScroller"]:+ failures.append(+ f"{shown_path}: template-mobile-containment: wide SVG needs a local horizontal scroller"+ )+ if facts["minWidth"] <= TOLERANCE and facts["viewBoxWidth"] > TOLERANCE:+ # An absent min-width is not a pass: the SVG then shrinks into the+ # phone and the type ramp shrinks with it, which is the same defect+ # the type-ramp check below reports - it just reads as 0 instead of+ # a wrong number, and would otherwise skip both checks silently.+ drawn = facts["svgWidth"]+ failures.append(+ f"{shown_path}: template-mobile-type-ramp: no min-width, so the SVG shrinks to "+ f"{drawn:.0f}px against a {facts['viewBoxWidth']:.0f} viewBox and a 12px node name "+ f"lands at {12 * drawn / facts['viewBoxWidth']:.1f}px; pin min-width to the viewBox width"+ )+ if (+ facts["minWidth"] > TOLERANCE+ and facts["viewBoxWidth"] > TOLERANCE+ and abs(facts["minWidth"] - facts["viewBoxWidth"]) > TOLERANCE+ ):+ ratio = facts["minWidth"] / facts["viewBoxWidth"]+ failures.append(+ f"{shown_path}: template-mobile-type-ramp: min-width {facts['minWidth']:.0f}px "+ f"!= viewBox width {facts['viewBoxWidth']:.0f}px, so everything draws at "+ f"{ratio:.3f} scale and a 12px node name lands at {12 * ratio:.1f}px"+ )+ return failures+++OUTPUT_SPEC_DOC = ROOT / "skills/diagram-design/references/output-spec.md"+++def output_spec_widest_preset():+ """The widest fixed viewBox in the output-spec.md size table, or None."""+ text = OUTPUT_SPEC_DOC.read_text(encoding="utf-8")+ sizes = re.findall(r"^\| `[a-z0-9-]+` \| `0 0 (\d+) (\d+)`", text, re.M)+ return max((int(w), int(h)) for w, h in sizes) if sizes else None+++# The export check re-draws each template at the widest fixed preset in+# output-spec.md (print-a3-landscape, 1584 wide, at the time of writing). With+# min-width pinned to the viewBox width, every preset from 1280 up is wider than+# the templates' 1200px frame; the widest is the hardest to capture whole. The+# self-test fails if this falls back or drifts from the table.+WIDE_PRESET = output_spec_widest_preset() or (1280, 720)+# A node in the rightmost 100 units of the wide preset; the PNG must paint it.+EXPORT_PROBE = {"x": WIDE_PRESET[0] - 100, "y": WIDE_PRESET[1] // 2 - 32, "width": 80, "height": 60}+EXPORT_PROBE_MARKUP = (+ '<rect id="export-probe" x="{x}" y="{y}" width="{width}" height="{height}" '+ 'fill="#ff00ff"/>'.format(**EXPORT_PROBE)+)+EXPORT_TIMEOUT = 120 # seconds for one run of the recipe, browser launch included++PNG_PROBE_JS = """+async ([src, probe, viewBoxWidth]) => {+ const img = new Image();+ img.src = src;+ await img.decode();+ const canvas = document.createElement('canvas');+ canvas.width = img.naturalWidth;+ canvas.height = img.naturalHeight;+ const ctx = canvas.getContext('2d');+ ctx.drawImage(img, 0, 0);+ const k = img.naturalWidth / viewBoxWidth;+ const y = probe.y + probe.height / 2;+ const xs = [probe.x + 4, probe.x + probe.width / 2, probe.x + probe.width - 4];+ const pixels = xs.map((x) => Array.from(ctx.getImageData(Math.floor(x * k), Math.floor(y * k), 1, 1).data));+ return { width: img.naturalWidth, height: img.naturalHeight, pixels };+}+"""+++def export_recipe():+ """The PNG rasterize snippet from export.md, found by heading, not position."""+ text = EXPORT_DOC.read_text(encoding="utf-8")+ match = re.search(r"^### Rasterize[ \t]*\n(.*?)^```python\n(.*?)^```", text, re.M | re.S)+ if match is None or re.search(r"^#{1,3} ", match.group(1), re.M):+ return None+ return match.group(2)+++def wide_preset_fixture(html):+ """Re-draw a template at the widest preset the way output-spec.md says:+ viewBox and min-width both at the preset width, plus a probe node at the+ right edge.+ Remote <link>s are dropped so the recipe runs without a network."""+ match = re.search(r'<svg\b[^>]*\bviewBox="0 0 (\d+) (\d+)"', html)+ if match is None:+ return None+ width = match.group(1)+ html = html[: match.start(1)] + f"{WIDE_PRESET[0]} {WIDE_PRESET[1]}" + html[match.end(2) :]+ html, pinned = re.subn(rf"min-width:\s*{width}px", f"min-width: {WIDE_PRESET[0]}px", html)+ if pinned != 1 or "</svg>" not in html:+ return None+ html = html.replace("</svg>", EXPORT_PROBE_MARKUP + "</svg>", 1)+ return re.sub(r"<link\b[^>]*\bhref=\"https?://[^>]*>", "", html)+++def export_png_failures(context, label, html, recipe):+ """Run export.md's rasterize recipe on ``html`` exactly as the doc says+ (snippet in a temp file, ``python <tmp.py> <src.html> <out.png> 1``) and+ report a PNG that is not the full viewBox width or does not paint the probe."""+ with tempfile.TemporaryDirectory() as directory:+ directory_path = Path(directory)+ script = directory_path / "rasterize.py"+ source = directory_path / "wide-preset.html"+ out = directory_path / "wide-preset.png"+ script.write_text(recipe, encoding="utf-8")+ source.write_text(html, encoding="utf-8")+ try:+ run = subprocess.run(+ [sys.executable, str(script), str(source), str(out), "1"],+ capture_output=True, text=True, timeout=EXPORT_TIMEOUT,+ )+ except subprocess.TimeoutExpired:+ return [f"{label}: template-export: the export.md recipe did not finish in {EXPORT_TIMEOUT}s"]+ if run.returncode != 0 or not out.is_file():+ tail = (run.stderr.strip().splitlines() or ["no output"])[-1]+ return [f"{label}: template-export: the export.md recipe failed: {tail}"]+ png = out.read_bytes()+ page = context.new_page()+ try:+ facts = page.evaluate(PNG_PROBE_JS, [data_url(png), EXPORT_PROBE, WIDE_PRESET[0]])+ finally:+ page.close()+ failures = []+ if facts["width"] != WIDE_PRESET[0]:+ failures.append(+ f"{label}: template-export: PNG is {facts['width']}px wide at scale 1, "+ f"expected the viewBox width {WIDE_PRESET[0]}px"+ )+ painted = [r > 200 and g < 60 and b > 200 and a > 200 for r, g, b, a in facts["pixels"]]+ if not all(painted):+ failures.append(+ f"{label}: template-export: the node at x={EXPORT_PROBE['x']}-"+ f"{EXPORT_PROBE['x'] + EXPORT_PROBE['width']} of a {WIDE_PRESET[0]}-wide preset is "+ f"missing from the PNG (sampled {facts['pixels']}); an ancestor clipped the SVG "+ f"during capture"+ )+ return failures+++def template_export_failures(context, template_paths=None):+ """A template re-drawn at doc-wide or slide-16x9 must export to a whole PNG.++ min-width equal to the viewBox width makes a 1280 SVG wider than the 1200px+ frame, so the local scroller (and the terminal's overflow:hidden chrome)+ clips it on screen. The rasterize recipe screenshots the SVG's box, and+ whatever an ancestor clipped is simply not in the PNG: full size, blank on+ the right, no error. This runs the recipe from export.md itself, so the+ check follows the doc rather than a copy of it.+ """+ recipe = export_recipe()+ if recipe is None:+ return [f"{display_path(EXPORT_DOC)}: template-export: no ```python block under ### Rasterize"]+ paths = template_paths or sorted(ASSET_DIR.glob("template*.html"))+ failures = []+ for path in paths:+ shown_path = display_path(path)+ fixture = wide_preset_fixture(path.read_text(encoding="utf-8"))+ if fixture is None:+ failures.append(+ f"{shown_path}: template-export: could not re-draw at the {WIDE_PRESET[0]} preset "+ "(needs one viewBox=\"0 0 W H\" and one `min-width: Wpx`)"+ )+ continue+ failures += export_png_failures(context, shown_path, fixture, recipe)+ return failures++def self_test(context):page = context.new_page()failures = []@@ -1042,6 +1294,121 @@ def self_test(context):+ "; ".join(contained_failures))+ # Templates: three polarities, because the clipped case is the one a+ # page-overflow check cannot see - it reports clean precisely because the+ # content was destroyed instead of overflowing.+ checks += 5+ with tempfile.TemporaryDirectory() as directory:+ directory_path = Path(directory)++ overflowing = directory_path / "template-overflow.html"+ overflowing.write_text(+ '<!DOCTYPE html><html><style>body{margin:0}'+ 'svg{width:100%;min-width:1000px;display:block}</style>'+ '<body><div class="frame"><svg viewBox="0 0 1000 600"></svg></div></body></html>',+ encoding="utf-8",+ )+ overflow_failures = template_mobile_failures(context, [overflowing])+ if not any("template-mobile-page-overflow" in f for f in overflow_failures):+ failures.append("template-overflow-fixture: page overflow was not reported")+ if not any("template-mobile-containment" in f for f in overflow_failures):+ failures.append("template-overflow-fixture: missing local scroller was not reported")++ clipped = directory_path / "template-clipped.html"+ clipped.write_text(+ '<!DOCTYPE html><html><style>body{margin:0}.chrome{overflow:hidden}'+ 'svg{width:100%;min-width:1000px;display:block}</style>'+ '<body><div class="chrome"><svg viewBox="0 0 1000 600"></svg></div></body></html>',+ encoding="utf-8",+ )+ clipped_failures = template_mobile_failures(context, [clipped])+ if not any("template-mobile-clipped" in f for f in clipped_failures):+ failures.append("template-clipped-fixture: unreachable clipped SVG was not reported")++ contained = directory_path / "template-contained.html"+ contained.write_text(+ '<!DOCTYPE html><html><style>body{margin:0}.diagram-container{width:100%;overflow-x:auto}'+ 'svg{width:100%;min-width:1000px;display:block}</style><body><div class="frame">'+ '<div class="diagram-container"><svg viewBox="0 0 1000 600"></svg></div>'+ '</div></body></html>',+ encoding="utf-8",+ )+ contained_failures = template_mobile_failures(context, [contained])+ if contained_failures:+ failures.append(+ "template-contained-fixture: false finding: " + "; ".join(contained_failures)+ )++ ramp = directory_path / "template-ramp.html"+ ramp.write_text(+ '<!DOCTYPE html><html><style>body{margin:0}.diagram-container{width:100%;overflow-x:auto}'+ 'svg{width:100%;min-width:900px;display:block}</style><body><div class="frame">'+ '<div class="diagram-container"><svg viewBox="0 0 1280 720"></svg></div>'+ '</div></body></html>',+ encoding="utf-8",+ )+ if not any("template-mobile-type-ramp" in f for f in template_mobile_failures(context, [ramp])):+ failures.append("template-ramp-fixture: min-width below the viewBox width was not reported")++ absent = directory_path / "template-no-min-width.html"+ absent.write_text(+ '<!DOCTYPE html><html><style>body{margin:0}.diagram-container{width:100%;overflow-x:auto}'+ 'svg{width:100%;display:block}</style><body><div class="frame">'+ '<div class="diagram-container"><svg viewBox="0 0 1280 720"></svg></div>'+ '</div></body></html>',+ encoding="utf-8",+ )+ if not any("template-mobile-type-ramp" in f for f in template_mobile_failures(context, [absent])):+ failures.append("template-no-min-width-fixture: absent min-width was treated as a pass")++ # The export check must cover the widest preset output-spec.md offers, or+ # clipping that only a wider preset hits goes untested.+ checks += 1+ widest = output_spec_widest_preset()+ if widest is None:+ failures.append("template-export-widest-preset: no viewBox rows in the output-spec.md size table")+ elif WIDE_PRESET != widest:+ failures.append(+ f"template-export-widest-preset: the export check uses {WIDE_PRESET[0]}x{WIDE_PRESET[1]}, "+ f"but the widest output-spec.md preset is {widest[0]}x{widest[1]}"+ )++ # Export of the wide preset, both polarities: an SVG wider than the 1200px+ # frame, held in a local scroller, must come out whole, and a probe node that+ # really is cut off (clip-path, which export does not release) must be reported.+ checks += 2+ recipe = export_recipe()+ if recipe is None:+ failures.append("template-export: no python snippet under ### Rasterize in export.md")+ else:+ wide_page = (+ '<!DOCTYPE html><html><style>body{{margin:0;padding:32px;background:#f5f5f5}}'+ '.frame{{max-width:1200px;width:100%}}.diagram-container{{width:100%;overflow-x:auto}}'+ 'svg{{width:100%;min-width:' + str(WIDE_PRESET[0]) + 'px;display:block}}</style>'+ '<body><div class="frame"><div class="diagram-container"{clip}>'+ '<svg viewBox="0 0 ' + f"{WIDE_PRESET[0]} {WIDE_PRESET[1]}" + '" '+ 'xmlns="http://www.w3.org/2000/svg"><rect width="' + str(WIDE_PRESET[0])+ + '" height="' + str(WIDE_PRESET[1]) + '" fill="#f5f5f5"/>'+ + EXPORT_PROBE_MARKUP+ + "</svg></div></div></body></html>"+ )+ scroller_failures = export_png_failures(+ context, "template-export-scroller-fixture", wide_page.format(clip=""), recipe+ )+ if scroller_failures:+ failures.append(+ f"template-export-scroller-fixture: the recipe clipped a {WIDE_PRESET[0]}-wide SVG held in a "+ "local scroller: " + "; ".join(scroller_failures)+ )+ clipped_failures = export_png_failures(+ context,+ "template-export-clipped-fixture",+ wide_page.format(clip=' style="clip-path:inset(0 160px 0 0)"'),+ recipe,+ )+ if not any("is missing from the PNG" in f for f in clipped_failures):+ failures.append("template-export-clipped-fixture: a cut-off probe node was not reported")+# A broken route should be a targeted failure, not a delayed Playwright# timeout or traceback that escapes the self-test report.checks += 1@@ -1130,6 +1497,8 @@ def main():mobile_failures = waterfall_mobile_failures(context)mobile_failures += excalidraw_mobile_failures(context)mobile_failures += marimekko_mobile_failures(context)+ mobile_failures += template_mobile_failures(context)+ mobile_failures += template_export_failures(context)total_findings += len(mobile_failures)if not args.quiet:for failure in mobile_failures:diff --git a/skills/diagram-design/SKILL.md b/skills/diagram-design/SKILL.mdindex 56c3176..e2b7200 100644--- a/skills/diagram-design/SKILL.md+++ b/skills/diagram-design/SKILL.md@@ -289,6 +289,7 @@ Run before producing any diagram.- [ ] Legend is a horizontal bottom strip, not floating?- [ ] No vertical `writing-mode` text?- [ ] `viewBox` expanded for the legend strip (~60px)?+- [ ] **`min-width` equals the viewBox width, and the SVG sits in a local `overflow-x: auto` wrapper? (Otherwise a phone scrolls the whole page — or an `overflow: hidden` ancestor clips the diagram with no scrollbar at all. See [output-spec.md](references/output-spec.md).)**- [ ] Node origins, dimensions, gaps, padding on the 4px grid; type sizes on the role ramp?- [ ] From the installed skill directory, did `python3 scripts/self_check.py <file>` pass? (Accessible-SVG contract, single-file safety, motion basics.)- [ ] If animated, does the complete static/no-JS frame work, does reduced motion hide/disable playback, and is the controller copied verbatim from `assets/template-motion.html`? From a repository checkout, also run `python3 <repo-root>/scripts/verify-motion.py path/to/generated.html` plus the skin linter; from an installed skill, manually check print and static-query states on top of the self-check.diff --git a/skills/diagram-design/assets/template-dark.html b/skills/diagram-design/assets/template-dark.htmlindex be75e5c..4e731db 100644--- a/skills/diagram-design/assets/template-dark.html+++ b/skills/diagram-design/assets/template-dark.html@@ -29,6 +29,10 @@}.frame { max-width: 1200px; width: 100%; }+ /* The SVG holds its readable width (min-width == the viewBox width, so the+ type ramp is never silently scaled down). This wrapper lets a narrow+ screen scroll the diagram instead of the whole page. */+ .diagram-container { width: 100%; overflow-x: auto; }.eyebrow {font-family: var(--font-mono);@@ -50,7 +54,15 @@margin-bottom: 1.5rem;}- svg { width: 100%; min-width: 900px; display: block; }+ svg { width: 100%; min-width: 1000px; display: block; }+ /* Paper has no scrollbar, so the local scroller would clip instead of+ scroll. Let the diagram scale down to the sheet: smaller but whole+ beats sharp but cut off. Must come after the svg rule above - a media+ query adds no specificity, so a later plain rule would win. */+ @media print {+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }+ }</style></head><body>@@ -59,27 +71,29 @@<h1>[Diagram title]</h1><!-- Replace [diagram-slug] with a unique slug for this diagram before export. -->- <svg viewBox="0 0 1000 600" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="[diagram-slug]-title [diagram-slug]-desc">- <title id="[diagram-slug]-title">[Diagram title]</title>- <desc id="[diagram-slug]-desc">[One sentence describing what the diagram shows]</desc>- <defs>- <marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#bfc0c0"/></marker>- <marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#f08a59"/></marker>- <marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#6a95d8"/></marker>+ <div class="diagram-container">+ <svg viewBox="0 0 1000 600" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="[diagram-slug]-title [diagram-slug]-desc">+ <title id="[diagram-slug]-title">[Diagram title]</title>+ <desc id="[diagram-slug]-desc">[One sentence describing what the diagram shows]</desc>+ <defs>+ <marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#bfc0c0"/></marker>+ <marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#f08a59"/></marker>+ <marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#6a95d8"/></marker>- <!-- OPTIONAL: dot-pattern background. Uncomment and add <rect fill="url(#dots)"/> after the paper rect to enable. -->- <!--- <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">- <circle cx="1" cy="1" r="0.9" fill="rgba(245,245,245,0.08)"/>- </pattern>- -->- </defs>+ <!-- OPTIONAL: dot-pattern background. Uncomment and add <rect fill="url(#dots)"/> after the paper rect to enable. -->+ <!--+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">+ <circle cx="1" cy="1" r="0.9" fill="rgba(245,245,245,0.08)"/>+ </pattern>+ -->+ </defs>- <rect width="100%" height="100%" fill="#2d3142"/>+ <rect width="100%" height="100%" fill="#2d3142"/>- <!-- Draw arrows first, then nodes. Replace with your content. -->+ <!-- Draw arrows first, then nodes. Replace with your content. -->- </svg>+ </svg>+ </div></div></body></html>diff --git a/skills/diagram-design/assets/template-full.html b/skills/diagram-design/assets/template-full.htmlindex 66b27d0..00d33a7 100644--- a/skills/diagram-design/assets/template-full.html+++ b/skills/diagram-design/assets/template-full.html@@ -80,7 +80,15 @@/* padding: 1.5rem; */}- svg { width: 100%; min-width: 900px; display: block; }+ svg { width: 100%; min-width: 1000px; display: block; } /* == viewBox width: never scale the type ramp down */+ /* Paper has no scrollbar, so the local scroller would clip instead of+ scroll. Let the diagram scale down to the sheet: smaller but whole+ beats sharp but cut off. Must come after the svg rule above - a media+ query adds no specificity, so a later plain rule would win. */+ @media print {+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }+ }/* ── Info cards ───────────────────────────────────────────────── */.cards {diff --git a/skills/diagram-design/assets/template-motion.html b/skills/diagram-design/assets/template-motion.htmlindex 7a4646c..f94003a 100644--- a/skills/diagram-design/assets/template-motion.html+++ b/skills/diagram-design/assets/template-motion.html@@ -42,7 +42,14 @@text-transform: uppercase;}h1 { margin: 0 0 24px; font: 400 32px/1.15 var(--font-serif); }- svg { display: block; width: 100%; min-width: 720px; }+ svg { display: block; width: 100%; min-width: 960px; }+ /* The SVG holds its readable width (min-width == the viewBox width, so the+ type ramp is never silently scaled down). This wrapper lets a narrow+ screen scroll the diagram instead of the whole page. body is a centred+ grid, so the root needs max-width/min-width to stop the grid item from+ sizing itself to the SVG's max-content width. */+ [data-motion-root] { max-width: 100%; min-width: 0; }+ .diagram-container { width: 100%; overflow-x: auto; }/* Static source is complete. Only an initialized enhancement hides items. */.motion-ready [data-motion-item] {@@ -160,6 +167,11 @@[data-motion-controls] { display: none !important; }}@media print {+ /* Paper has no scrollbar, so the local scroller would clip instead of+ scroll. Let the diagram scale down to the sheet: smaller but whole+ beats sharp but cut off. */+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }[data-motion-controls], [data-motion-decorative] { display: none !important; }[data-motion-item] {opacity: 1 !important;@@ -176,50 +188,52 @@<p class="eyebrow">Process · Optional motion</p><h1>Request evaluation</h1>- <svg viewBox="0 0 960 480" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="template-motion-title template-motion-desc">- <title id="template-motion-title">Request evaluation</title>- <desc id="template-motion-desc">A request is validated, evaluated against a policy, queued, and appended to an audit log.</desc>- <defs>- <marker id="template-motion-arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">- <polygon points="0 0, 8 3, 0 6" fill="#4f5d75"/>- </marker>- </defs>- <rect width="960" height="480" fill="#f5f5f5"/>+ <div class="diagram-container">+ <svg viewBox="0 0 960 480" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="template-motion-title template-motion-desc">+ <title id="template-motion-title">Request evaluation</title>+ <desc id="template-motion-desc">A request is validated, evaluated against a policy, queued, and appended to an audit log.</desc>+ <defs>+ <marker id="template-motion-arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto">+ <polygon points="0 0, 8 3, 0 6" fill="#4f5d75"/>+ </marker>+ </defs>+ <rect width="960" height="480" fill="#f5f5f5"/>- <!-- Persistent connectors carry the static meaning. -->- <path d="M248 180 H356" fill="none" stroke="#4f5d75" marker-end="url(#template-motion-arrow)"/>- <path d="M556 180 H664" fill="none" stroke="#4f5d75" marker-end="url(#template-motion-arrow)"/>- <path d="M764 232 V328" fill="none" stroke="#4f5d75" marker-end="url(#template-motion-arrow)"/>+ <!-- Persistent connectors carry the static meaning. -->+ <path d="M248 180 H356" fill="none" stroke="#4f5d75" marker-end="url(#template-motion-arrow)"/>+ <path d="M556 180 H664" fill="none" stroke="#4f5d75" marker-end="url(#template-motion-arrow)"/>+ <path d="M764 232 V328" fill="none" stroke="#4f5d75" marker-end="url(#template-motion-arrow)"/>- <g data-motion-item data-step="1" aria-label="Step 1: Request received">- <rect x="48" y="128" width="200" height="104" rx="8" fill="#f5f5f5" stroke="#2d3142"/>- <text x="148" y="172" text-anchor="middle" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Request</text>- <text x="148" y="196" text-anchor="middle" fill="#4f5d75" font-family="Geist Mono, monospace" font-size="12">fields complete</text>- </g>- <g data-motion-item data-step="2" aria-label="Step 2: Policy passed">- <rect x="356" y="128" width="200" height="104" rx="8" fill="rgba(235,108,54,0.08)" stroke="#eb6c36"/>- <text x="456" y="168" text-anchor="middle" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Policy</text>- <text x="456" y="196" text-anchor="middle" fill="#4f5d75" font-family="Geist Mono, monospace" font-size="12">✓ PASS · rule 2</text>- </g>- <g data-motion-item data-step="3" aria-label="Step 3: Three items queued">- <rect x="664" y="128" width="200" height="104" rx="8" fill="#f5f5f5" stroke="#2d3142"/>- <text x="764" y="164" text-anchor="middle" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Queue</text>- <rect x="700" y="184" width="16" height="16" fill="#4f5d75"/><rect x="724" y="184" width="16" height="16" fill="#4f5d75"/><rect x="748" y="184" width="16" height="16" fill="#4f5d75"/>- <text x="796" y="196" fill="#4f5d75" font-family="Geist Mono, monospace" font-size="12">3 queued</text>- </g>- <g data-motion-item data-step="4" aria-label="Step 4: Audit entry appended">- <rect x="664" y="328" width="200" height="88" rx="8" fill="#f5f5f5" stroke="#2d3142"/>- <text x="764" y="364" text-anchor="middle" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Audit log</text>- <text x="764" y="388" text-anchor="middle" fill="#4f5d75" font-family="Geist Mono, monospace" font-size="12">0042 · appended</text>- </g>- <g data-motion-item data-step="5" aria-label="Step 5: Evaluation complete">- <text x="48" y="376" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Outcome: accepted and recorded</text>- </g>+ <g data-motion-item data-step="1" aria-label="Step 1: Request received">+ <rect x="48" y="128" width="200" height="104" rx="8" fill="#f5f5f5" stroke="#2d3142"/>+ <text x="148" y="172" text-anchor="middle" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Request</text>+ <text x="148" y="196" text-anchor="middle" fill="#4f5d75" font-family="Geist Mono, monospace" font-size="12">fields complete</text>+ </g>+ <g data-motion-item data-step="2" aria-label="Step 2: Policy passed">+ <rect x="356" y="128" width="200" height="104" rx="8" fill="rgba(235,108,54,0.08)" stroke="#eb6c36"/>+ <text x="456" y="168" text-anchor="middle" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Policy</text>+ <text x="456" y="196" text-anchor="middle" fill="#4f5d75" font-family="Geist Mono, monospace" font-size="12">✓ PASS · rule 2</text>+ </g>+ <g data-motion-item data-step="3" aria-label="Step 3: Three items queued">+ <rect x="664" y="128" width="200" height="104" rx="8" fill="#f5f5f5" stroke="#2d3142"/>+ <text x="764" y="164" text-anchor="middle" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Queue</text>+ <rect x="700" y="184" width="16" height="16" fill="#4f5d75"/><rect x="724" y="184" width="16" height="16" fill="#4f5d75"/><rect x="748" y="184" width="16" height="16" fill="#4f5d75"/>+ <text x="796" y="196" fill="#4f5d75" font-family="Geist Mono, monospace" font-size="12">3 queued</text>+ </g>+ <g data-motion-item data-step="4" aria-label="Step 4: Audit entry appended">+ <rect x="664" y="328" width="200" height="88" rx="8" fill="#f5f5f5" stroke="#2d3142"/>+ <text x="764" y="364" text-anchor="middle" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Audit log</text>+ <text x="764" y="388" text-anchor="middle" fill="#4f5d75" font-family="Geist Mono, monospace" font-size="12">0042 · appended</text>+ </g>+ <g data-motion-item data-step="5" aria-label="Step 5: Evaluation complete">+ <text x="48" y="376" fill="#2d3142" font-family="Geist, sans-serif" font-size="16" font-weight="600">Outcome: accepted and recorded</text>+ </g>- <!-- Decorative duplicate path and token never carry unique meaning. -->- <path data-motion-item data-step="2" data-motion-decorative aria-hidden="true" focusable="false" pathLength="1" class="draw-path" d="M248 180 H356"/>- <circle data-motion-item data-step="3" data-motion-decorative aria-hidden="true" focusable="false" class="flow-token" cx="556" cy="180" r="6" fill="#eb6c36"/>- </svg>+ <!-- Decorative duplicate path and token never carry unique meaning. -->+ <path data-motion-item data-step="2" data-motion-decorative aria-hidden="true" focusable="false" pathLength="1" class="draw-path" d="M248 180 H356"/>+ <circle data-motion-item data-step="3" data-motion-decorative aria-hidden="true" focusable="false" class="flow-token" cx="556" cy="180" r="6" fill="#eb6c36"/>+ </svg>+ </div><div data-motion-controls role="group" aria-label="Diagram playback controls"><button type="button" data-motion-action="prev">Previous</button>diff --git a/skills/diagram-design/assets/template-terminal.html b/skills/diagram-design/assets/template-terminal.htmlindex efc271d..dfd9384 100644--- a/skills/diagram-design/assets/template-terminal.html+++ b/skills/diagram-design/assets/template-terminal.html@@ -109,9 +109,22 @@svg {width: 100%;- min-width: 900px;+ min-width: 1000px;display: block;}++ /* .terminal is overflow:hidden for the window chrome, so without this+ wrapper a narrow screen clips the diagram with no way to reach it:+ no scrollbar, no page overflow, nothing for a linter to see. */+ .diagram-container {+ width: 100%;+ overflow-x: auto;+ }++ @media print {+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }+ }</style></head><body>@@ -129,44 +142,46 @@<h1>[Diagram title]</h1><!-- Replace [diagram-slug] with a unique slug for this diagram before export. -->- <svg viewBox="0 0 1000 600" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="[diagram-slug]-title [diagram-slug]-desc">- <title id="[diagram-slug]-title">[Diagram title]</title>- <desc id="[diagram-slug]-desc">[One sentence describing what the diagram shows]</desc>- <defs>- <marker- id="arrow"- markerWidth="8"- markerHeight="6"- refX="7"- refY="3"- orient="auto"- >- <polygon points="0 0, 8 3, 0 6" fill="#9a9a9a" />- </marker>- <marker- id="arrow-accent"- markerWidth="8"- markerHeight="6"- refX="7"- refY="3"- orient="auto"- >- <polygon points="0 0, 8 3, 0 6" fill="#ff5a36" />- </marker>+ <div class="diagram-container">+ <svg viewBox="0 0 1000 600" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="[diagram-slug]-title [diagram-slug]-desc">+ <title id="[diagram-slug]-title">[Diagram title]</title>+ <desc id="[diagram-slug]-desc">[One sentence describing what the diagram shows]</desc>+ <defs>+ <marker+ id="arrow"+ markerWidth="8"+ markerHeight="6"+ refX="7"+ refY="3"+ orient="auto"+ >+ <polygon points="0 0, 8 3, 0 6" fill="#9a9a9a" />+ </marker>+ <marker+ id="arrow-accent"+ markerWidth="8"+ markerHeight="6"+ refX="7"+ refY="3"+ orient="auto"+ >+ <polygon points="0 0, 8 3, 0 6" fill="#ff5a36" />+ </marker>- <!-- OPTIONAL: dot-pattern background. Uncomment and add <rect fill="url(#dots)"/> after the paper rect to enable. -->- <!--- <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">- <circle cx="1" cy="1" r="0.9" fill="rgba(255,255,255,0.08)"/>- </pattern>- --></defs>+ <!-- OPTIONAL: dot-pattern background. Uncomment and add <rect fill="url(#dots)"/> after the paper rect to enable. -->+ <!--+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">+ <circle cx="1" cy="1" r="0.9" fill="rgba(255,255,255,0.08)"/>+ </pattern>+ --></defs>- <rect width="100%" height="100%" fill="#141414" />+ <rect width="100%" height="100%" fill="#141414" />- <!-- Draw arrows first, then nodes. Replace with your content.- Text sizes run ~1-2px above the default scale: node-name 14px,- sublabel/arrow-label 9-10px, hub label 18px. See primitive-terminal.md. -->- </svg>+ <!-- Draw arrows first, then nodes. Replace with your content.+ Text sizes run ~1-2px above the default scale: node-name 14px,+ sublabel/arrow-label 9-10px, hub label 18px. See primitive-terminal.md. -->+ </svg>+ </div></main></div></body>diff --git a/skills/diagram-design/assets/template.html b/skills/diagram-design/assets/template.htmlindex d617652..686b835 100644--- a/skills/diagram-design/assets/template.html+++ b/skills/diagram-design/assets/template.html@@ -29,6 +29,10 @@}.frame { max-width: 1200px; width: 100%; }+ /* The SVG holds its readable width (min-width == the viewBox width, so the+ type ramp is never silently scaled down). This wrapper lets a narrow+ screen scroll the diagram instead of the whole page. */+ .diagram-container { width: 100%; overflow-x: auto; }.eyebrow {font-family: var(--font-mono);@@ -50,7 +54,15 @@margin-bottom: 1.5rem;}- svg { width: 100%; min-width: 900px; display: block; }+ svg { width: 100%; min-width: 1000px; display: block; }+ /* Paper has no scrollbar, so the local scroller would clip instead of+ scroll. Let the diagram scale down to the sheet: smaller but whole+ beats sharp but cut off. Must come after the svg rule above - a media+ query adds no specificity, so a later plain rule would win. */+ @media print {+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }+ }</style></head><body>@@ -59,28 +71,30 @@<h1>[Diagram title]</h1><!-- Replace [diagram-slug] with a unique slug for this diagram before export. -->- <svg viewBox="0 0 1000 600" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="[diagram-slug]-title [diagram-slug]-desc">- <title id="[diagram-slug]-title">[Diagram title]</title>- <desc id="[diagram-slug]-desc">[One sentence describing what the diagram shows]</desc>- <defs>- <marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#4f5d75"/></marker>- <marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#eb6c36"/></marker>- <marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#2e5aa8"/></marker>+ <div class="diagram-container">+ <svg viewBox="0 0 1000 600" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="[diagram-slug]-title [diagram-slug]-desc">+ <title id="[diagram-slug]-title">[Diagram title]</title>+ <desc id="[diagram-slug]-desc">[One sentence describing what the diagram shows]</desc>+ <defs>+ <marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#4f5d75"/></marker>+ <marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#eb6c36"/></marker>+ <marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="#2e5aa8"/></marker>- <!-- OPTIONAL: dot-pattern background. Uncomment the <pattern> and the second <rect> below if you want the dotted paper look. -->- <!--- <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">- <circle cx="1" cy="1" r="0.9" fill="rgba(45,49,66,0.10)"/>- </pattern>- -->- </defs>+ <!-- OPTIONAL: dot-pattern background. Uncomment the <pattern> and the second <rect> below if you want the dotted paper look. -->+ <!--+ <pattern id="dots" width="22" height="22" patternUnits="userSpaceOnUse">+ <circle cx="1" cy="1" r="0.9" fill="rgba(45,49,66,0.10)"/>+ </pattern>+ -->+ </defs>- <rect width="100%" height="100%" fill="#f5f5f5"/>- <!-- <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/> -->+ <rect width="100%" height="100%" fill="#f5f5f5"/>+ <!-- <rect width="100%" height="100%" fill="url(#dots)" opacity="0.55"/> -->- <!-- Draw arrows first, then nodes. Replace with your content. -->+ <!-- Draw arrows first, then nodes. Replace with your content. -->- </svg>+ </svg>+ </div></div></body></html>diff --git a/skills/diagram-design/references/export.md b/skills/diagram-design/references/export.mdindex 73b9159..20e2077 100644--- a/skills/diagram-design/references/export.md+++ b/skills/diagram-design/references/export.md@@ -99,12 +99,18 @@ with sync_playwright() as p:page = browser.new_page(device_scale_factor=scale)page.goto(f"file://{pathlib.Path(src).resolve()}")page.wait_for_load_state("networkidle")- page.locator("svg").first.screenshot(path=out, omit_background=True)+ svg = page.locator("svg").first+ # Release every clipping ancestor (local scroller, overflow:hidden chrome)+ # so an SVG wider than its frame is captured whole.+ svg.evaluate("el => { for (let a = el.parentElement; a; a = a.parentElement) a.style.setProperty('overflow', 'visible', 'important'); }")+ svg.screenshot(path=out, omit_background=True)browser.close()```Default `device_scale_factor=2` for crisp output. Accept `1` for compact assets or `3` for print/retina hero use, passed as a third CLI arg.+The overflow release matters for the wide presets. `min-width` equals the viewBox width (see [`output-spec.md`](output-spec.md)), so a `doc-wide` or `slide-16x9` SVG is 1280px inside a 1200px frame, and its `.diagram-container` scroller clips the last 80px on screen. The screenshot covers the SVG's box but not what an ancestor clipped, so without the release the PNG comes out full size with a blank right edge. This is the screen-side counterpart of the templates' `@media print` rule.+### Output naming`example-architecture.html` → `example-architecture.png`, written next to the source. Honour explicit user-provided paths.diff --git a/skills/diagram-design/references/output-spec.md b/skills/diagram-design/references/output-spec.mdindex 29b79ed..c0f2cb5 100644--- a/skills/diagram-design/references/output-spec.md+++ b/skills/diagram-design/references/output-spec.md@@ -54,6 +54,54 @@ The preset sets the SVG `viewBox`. Every value below is divisible by 4, so the g| `print-letter-landscape` | `0 0 1056 816` | ~1.29:1 | @3 → 3168×2448 | print | US Letter landscape || `fit` | derived from content | any | @2 | standard | Vector hand-off; no fixed frame |+### Holding the canvas on a narrow screen++The SVG keeps its readable width on a phone instead of shrinking into it, so+`min-width` is **the viewBox width of the preset in use** — not a fixed number.+Pin it lower and the whole drawing scales down and takes the type ramp with it:+a 12px node name on a `doc-wide` 1280 viewBox pinned at 900 draws at 8.4px,+under every floor this spec sets, and nothing on screen says so.++A canvas that wide has to scroll somewhere. Put it in a wrapper that scrolls on+its own, or the document scrolls sideways and the right-hand nodes are gone+unless the reader thinks to look for them:++```html+<div class="diagram-container">+ <svg viewBox="0 0 960 600" …> … </svg>+</div>+```++```css+.diagram-container { width: 100%; overflow-x: auto; }+svg { width: 100%; min-width: 960px; display: block; }+```++Two shapes need extra care. A centred grid or flex item sizes itself to the+SVG's max-content width, so the wrapper's `width: 100%` resolves against the+wide item and never scrolls — give that item `max-width: 100%; min-width: 0`.+And when an ancestor is `overflow: hidden` (window chrome, a clipped card), the+SVG is cut off instead of scrolled: no scrollbar, no page overflow, and a+page-overflow check reports the file clean because the content was destroyed+rather than spilled. The wrapper has to sit **inside** that ancestor.++Paper has no scrollbar, so on a sheet the same wrapper clips instead of+scrolls. Release both in print and let the drawing scale to fit — smaller but+whole beats sharp but cut off. The rule has to come **after** the `svg` rule,+because a media query adds no specificity and a later plain rule would win:++```css+@media print {+ .diagram-container { overflow-x: visible; }+ svg { min-width: 0; }+}+```++`scripts/lint-render.py --all` renders every template at 390px and fails on+page overflow, an unreachable clipped SVG, a missing local scroller, or a+`min-width` that disagrees with the viewBox — including an absent one, which+lets the SVG shrink into the phone and takes the type ramp with it.+### Deriving `fit`Round the content bounding box **up** to the next multiple of 4, then add the fixed chrome: 40px outer margin on every side, plus 60px at the bottom for the legend strip. Never let the content touch the viewBox edge.@@ -214,6 +262,8 @@ Run alongside the SKILL.md §9 taste gate.- [ ] All four dials set — explicitly requested, inferred from the destination, or defaulted and stated?- [ ] `viewBox` matches the size preset exactly, values divisible by 4?+- [ ] `min-width` equals the preset's viewBox width, and the SVG sits in a local `overflow-x: auto` wrapper (inside any `overflow: hidden` ancestor)?+- [ ] `@media print` releases `min-width` and `overflow-x`, placed after the `svg` rule?- [ ] Type ramp matches the size class — not the standard ramp on a slide?- [ ] 40px outer margin honoured (64px for `social-og`)?- [ ] Node count inside the detail level's ceiling?