Skip to content

feat(server): bake a snippet kit into every snippet doc#6

Merged
benvinegar merged 1 commit into
mainfrom
feat/snippet-kit
Jun 11, 2026
Merged

feat(server): bake a snippet kit into every snippet doc#6
benvinegar merged 1 commit into
mainfrom
feat/snippet-kit

Conversation

@benvinegar

Copy link
Copy Markdown
Member

What

Bakes a "snippet kit" into every snippet document so agents publish compact markup instead of hand-writing inline CSS for every button, slider, and diagram label — fewer output tokens means faster publishes, and snippets get a consistent look for free.

  • Element defaults: bare button, input, select, textarea are pre-styled to match the viewer (hover/focus included); checkboxes, radios, ranges, and progress bars are themed via accent-color. color-scheme: light dark makes native controls render dark automatically.
  • SVG utility classes: t/ts/th text presets, box (neutral rect, rx: 8 via CSS), arr (1.2px connector), leader (dashed guide), node (cursor + hover dim), and c-blue|teal|amber|coral|green|red|gray color ramps that set fill+stroke on shapes (or a whole <g>, including descendant .box rects) and auto-switch child <text> to readable ink in light and dark. Blue/amber/green/red/gray alias the existing semantic tokens; teal and coral get their own light/dark variable pairs.
  • Shared arrow marker: a <marker id="arrow"> is injected into every doc; fill="context-stroke" makes the arrowhead inherit each line's stroke, so one marker replaces per-color marker defs.
  • The design guide gains a "Built-in kit" reference table (+ Tabler icons one-liner) and the theming prose is trimmed to "for anything the kit doesn't cover"; the skill doc points at the kit first.
  • Validation: the demo JWT diagram rewritten with the kit drops from 2,893 to 1,555 bytes (−46%) and renders identically in light and dark.

Reviewer notes

  • CSS rules override SVG presentation attributes, so the kit deliberately never styles bare svg text (fill/font-size) — that would silently break existing snippets that use fill="..." or font-size="..." attributes. There's a comment in snippetPage.ts pinning this constraint.
  • context-stroke needs Chrome 119+ / Safari 18+; older browsers would render a black arrowhead.
  • Verified in the browser on the demo content: light + dark screenshots of the JWT diagram and the backoff explainer's form controls. npm test (49), both typecheck programs, lint, format, and e2e (10/10, chromium + webkit) all pass.

🤖 Generated with Claude Code

Element defaults (button/input/select/textarea matching the viewer,
accent-color on toggles), SVG utility classes (t/ts/th presets, box,
arr, leader, node, c-* color ramps with dark-aware text), and a shared
context-stroke arrow marker injected into every doc. The design guide
documents it as a compact reference table; the demo JWT diagram
rewritten with the kit is 46% smaller.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@benvinegar benvinegar merged commit 22984f4 into main Jun 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant