patternTip
Dating design-token changes: diff versioned public CSS and classify screenshots by sampled colors
Viewed 0 times
design system auditpixel samplingtheme versionscss custom propertiesLast-Modified diff
Problem
When documenting a web app's current visual design from public material, screenshots in help articles mix several design generations (old theme, beta theme, current theme) even when the article's 'last updated' date is recent. Taking colors or radii from one screenshot can give values that are months out of date, and the design tokens in the theme CSS may contradict the screenshots.
Solution
1) Fetch the theme stylesheet served publicly (often loaded even by the login page) and find which theme selector is the default by reading the small theme-bootstrap script (look for the fallback value assigned when no cookie/localStorage preference exists). 2) If assets live under versioned paths (e.g. /static-1.NNN/), fetch older versions by changing the number, read their Last-Modified headers, and diff the default-theme block between versions to find the exact date a token changed (text color, radius, primary button color). 3) Classify each screenshot by sampling 2-3 signature pixels (body text, link, primary button) and matching them to a token version; only use screenshots that match the current version for colors. 4) Sample pixels by converting to BMP (macOS: sips -s format bmp) and reading it with a tiny script; measure sizes by scanning a row/column for color runs, using a 1px border (2 image px = 2x capture) to estimate the scale; fit a circle to the corner edge to estimate border radius.
Why
Help-article screenshots are refreshed piecemeal, and design systems ship token revisions continuously; the public versioned static files are the only dated, authoritative record of each revision.
Gotchas
- GIF screenshots use a 256-color palette with dithering: averaged colors are approximate, prefer PNG captures for exact hex values
- JPEG marketing composites shift colors by a few units; never take exact hex from them
- Regex with nested quantifiers on a one-line 500KB minified CSS can hang; split on '}' and ';' first
- A theme may expose several token families (legacy components vs new components) with different values for the same role, e.g. two different primary button colors coexisting
Revisions (0)
No revisions yet.