vfunc.js

Design: tokens and DESIGN.md

Whenever the design arrives, the logic should not change. Example 19 puts three skins on one app without changing a line of JavaScript.

Separation rules

  1. Behaviour on data-action · data-ref · id; looks on classes (<block>__<element>).
  2. State as aria-* or data-state; CSS styles those attributes.
  3. No colors, fonts, spacing or shadows in JavaScript.
  4. CSS reads only var(--vf-*) tokens; raw values live only in the token file.
  5. DESIGN.md is the source; the token file is derived from it.
  6. A design task never changes logic.

Tokens — css/vfunc.tokens.css

An optional, neutral skin with light and dark themes. Token names are public API.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vfunc@1.2.0/css/vfunc.tokens.css">
<link rel="stylesheet" href="./brand.css">   <!-- override tokens here -->
GroupExamples
Colors--vf-color-primary, --vf-color-surface, --vf-color-text-muted, --vf-color-danger-soft
Charts--vf-chart-1 … --vf-chart-8
Shape--vf-space-1..7, --vf-radius-md, --vf-shadow-2
Type--vf-font-body, --vf-font-size-md, --vf-font-weight-strong

The DESIGN.md workflow

SituationDo
Design material in any formatprompt-design-normalize → a standard DESIGN.md
New app with a designprompt-new-app-with-design: tokens and CSS first, then code
Design arrives laterprompt-apply-design: tokens and CSS only, confirm no JS change, --scope per screen
Published HTML arrives for finished screensprompt-merge-published-html: replace only the render markup, with a hook mapping table

The prompts and the DESIGN.md template are in Working with AI. With Tailwind, map @theme onto the tokens (example 13).

Design check — design-check

The starter's tools/design-check.mjs checks the rules above with no build and no dependency (optional). It exits with code 1 when something is wrong, so it fits before a commit or in CI.

node tools/design-check.mjs          # this project
node tools/design-check.mjs ../other --tokens css/vfunc.tokens.css