Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a6264f4
fix(site-tokens): record redirects and skip pages that land on one al…
ZaredRogers Nov 9, 2026
cca79c4
fix(site-tokens): pair each action's text with the buttons that have …
ZaredRogers Nov 9, 2026
feba001
Merge branch 'chore/git-2763-site-tokens-setup-notes' into fix/git-27…
ZaredRogers Nov 9, 2026
3dd352b
Merge branch 'fix/git-2767-site-tokens-crawl-redirects' into fix/git-…
ZaredRogers Nov 9, 2026
6d3c3f6
fix(site-tokens): keep mobile spacing values in order up the ladder
ZaredRogers Nov 9, 2026
8b0a557
Merge branch 'chore/git-2763-site-tokens-setup-notes' into fix/git-27…
ZaredRogers Nov 9, 2026
95f7deb
Merge branch 'fix/git-2767-site-tokens-crawl-redirects' into fix/git-…
ZaredRogers Nov 9, 2026
69490d7
Merge branch 'fix/git-2765-site-tokens-action-text-pairing' into fix/…
ZaredRogers Nov 9, 2026
98a7cb7
Merge branch 'chore/git-2763-site-tokens-setup-notes' into fix/git-27…
ZaredRogers Nov 9, 2026
cadb225
Merge branch 'fix/git-2765-site-tokens-action-text-pairing' into fix/…
ZaredRogers Nov 9, 2026
b72c8e8
Merge branch 'fix/git-2767-site-tokens-crawl-redirects' into fix/git-…
ZaredRogers Nov 9, 2026
2fc479d
fix(figma-tokens): start font stacks with the clean family name
ZaredRogers Nov 10, 2026
79aa6e7
fix(figma-tokens): keep the declared system stack for a generic family
ZaredRogers Nov 10, 2026
ce00aa6
fix(figma-tokens): map content and wide width to settings.layout
ZaredRogers Nov 10, 2026
5fc2814
fix(site-tokens): export the palette ramps in the LightSpeed order
ZaredRogers Nov 10, 2026
39aab34
fix(orphaned-refs): skip dependency folders and check border-radius p…
ZaredRogers Nov 10, 2026
c377002
refactor(orphaned-refs): convert the scan script and its tests to Typ…
ZaredRogers Nov 10, 2026
6ac7772
Merge pull request #4037 from lightspeedwp/fix/git-2774-orphaned-refs…
ZaredRogers Nov 11, 2026
f2c273a
Merge pull request #4035 from lightspeedwp/fix/git-2773-site-tokens-p…
ZaredRogers Nov 11, 2026
958d605
Merge pull request #4034 from lightspeedwp/fix/git-2772-figma-tokens-…
ZaredRogers Nov 11, 2026
5b77b17
Merge pull request #4033 from lightspeedwp/fix/git-2771-figma-tokens-…
ZaredRogers Nov 11, 2026
0083328
Merge pull request #4032 from lightspeedwp/fix/git-2770-figma-tokens-…
ZaredRogers Nov 11, 2026
4f42458
Merge pull request #4024 from lightspeedwp/fix/git-2766-site-tokens-s…
ZaredRogers Nov 11, 2026
20f0fc4
Merge pull request #4023 from lightspeedwp/fix/git-2765-site-tokens-a…
ZaredRogers Nov 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- **Orphaned Refs Scan Scope** — `theme-orphaned-refs` skips dependency, build and agent folders (with `--exclude` for more), checks `border-radius` presets, suggests the nearest step for numeric ladders, and is now TypeScript with Jest tests (`find-orphaned-presets.ts`). ([GIT-2774](https://linear.app/lightspeedwp/issue/GIT-2774))
- **Site Tokens Palette Order** — `site-to-design-tokens` exports the colour ramps in the LightSpeed order (neutral, primary, brand, cta), so the theme palette follows the convention. ([GIT-2773](https://linear.app/lightspeedwp/issue/GIT-2773))
- **Figma Tokens Layout Widths** — `figma-to-block-theme` maps the content and wide width variables to `settings.layout` in px, instead of unitless values in `settings.custom.layout`, so the theme gets the design's widths. ([GIT-2772](https://linear.app/lightspeedwp/issue/GIT-2772))
- **Figma Tokens Monospace Stack** — `figma-to-block-theme` keeps the declared system stack for a generic family such as Monospace, and falls back to `monospace` for the monospace role, instead of writing `Monospace, sans-serif`. ([GIT-2771](https://linear.app/lightspeedwp/issue/GIT-2771))
- **Figma Tokens Font Stacks** — `figma-to-block-theme` starts each font stack with the clean family name and keeps the declared fallbacks, instead of the live site's own `@font-face` name, so the stack matches the theme's `fontFace` entries. ([GIT-2770](https://linear.app/lightspeedwp/issue/GIT-2770))
- **Site Tokens Spacing Minimums** — `site-to-design-tokens` keeps mobile spacing values in order up the ladder, raising a step that would shrink below the one before and listing it for the reviewer. ([GIT-2766](https://linear.app/lightspeedwp/issue/GIT-2766))
- **Site Tokens Action Text** — `site-to-design-tokens` takes each action's text colour from the buttons that have its fill, so text and fill are a pair the site really shows. ([GIT-2765](https://linear.app/lightspeedwp/issue/GIT-2765))
- **Site Tokens Crawl Redirects** — `site-to-design-tokens` records where each page landed, warns about redirects, and leaves out pages that land on one already captured. ([GIT-2767](https://linear.app/lightspeedwp/issue/GIT-2767))
- **Site Tokens Action Colours** — `site-to-design-tokens` uses the live button colour for action backgrounds (hover one step darker) and moves defaults that fail contrast to the nearest passing step, recording each move in the report. ([#4008](https://github.com/lightspeedwp/.github/issues/4008))
- **Site Tokens Font Roles** — `site-to-design-tokens` cleans font names (`argesta_displayregular` becomes Argesta Display), keeps the exact CSS stack, and outputs the `heading`, `body` and `monospace` roles (plus `accent` only when the site uses a third font), marking each as live or default. `figma-to-block-theme` uses the stack. ([#4007](https://github.com/lightspeedwp/.github/issues/4007))
- **Site Tokens Content Width** — `site-to-design-tokens` measures the content width from running text, one vote per page with blog posts first, takes a `--layout` override, and flags widths under 480px or near the wide width. ([#4006](https://github.com/lightspeedwp/.github/issues/4006))
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
"test:js": "jest --config .jest.config.cjs --coverage --forceExit --detectOpenHandles",
"test:figma-to-block-theme": "jest --config skills/figma-to-block-theme/scripts/jest.config.cjs",
"test:site-to-design-tokens": "jest --config skills/site-to-design-tokens/scripts/jest.config.cjs",
"test:theme-orphaned-refs": "jest --config skills/theme-orphaned-refs/scripts/jest.config.cjs",
"test:theme-orphaned-refs": "jest --config skills/theme-orphaned-refs/scripts/jest.config.cjs",
"test:site-to-figma-components": "jest --config skills/site-to-figma-components/scripts/jest.config.cjs",
"test:agent-spec-validation": "node .github/scripts/__tests__/validate-agent-specs.test.js",
"test:index-generator": "node .github/scripts/__tests__/generate-agent-index.test.js",
Expand Down
4 changes: 4 additions & 0 deletions skills/figma-to-block-theme/references/tokens-spacing.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ Use `--min-viewport` and `--max-viewport` only when the design's frames differ f
- Replace `settings.spacing.spacingSizes`, and set `defaultSpacingSizes: false`. Core's default sizes use the slugs `20` to `80`, and when they are on they override theme sizes with the same slugs, so the theme's values never reach the page. Keep `units`, `padding`, `margin` and `blockGap`.
- Compare the count with the mapper's `counts.spacing`.
- Slugs used in `styles` and patterns (`var:preset|spacing|<slug>`) must still exist. `theme-orphaned-refs` checks this.

## Layout widths

Variables whose code syntax is `--wp--custom--layout--content-size` or `--wp--custom--layout--wide-size` (the form `site-to-design-tokens` writes), or core's `--wp--style--global--content-size` and `--wide-size`, go to `settings.layout.contentSize` and `wideSize`, not to `settings.custom`. Numbers become px (`848` gives `"848px"`), and a string keeps its unit. Compare the widths with the theme's current `settings.layout` in the plan, and note `counts.layout` in the report.
5 changes: 3 additions & 2 deletions skills/figma-to-block-theme/references/tokens-typography.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ After replacing the sizes, update every reference in `styles`, `styles.blocks`,
Variables whose code syntax is `--wp--preset--font-family--<slug>` (`heading`, `body`, `monospace`, and `accent` only when the site has a third font) become `{ slug, name, fontFamily }`:

- `name` is the font name (for example "Nunito Sans"), not the slug.
- If the variable description holds a `CSS stack: <stack>` line (written by `site-to-design-tokens`) and its first family is the font named by the value, `fontFamily` is that exact stack.
- Otherwise `fontFamily` quotes names that contain spaces and adds a fallback: `sans-serif` by default, or `--font-fallback serif` for serif families. Confirm the fallback with the user.
- If the variable description holds a `CSS stack: <stack>` line (written by `site-to-design-tokens`) and its first family is the font named by the value, `fontFamily` is the font name followed by that stack's fallbacks. The first family is the live site's own `@font-face` name (for example `argesta_displayregular, serif` gives `"Argesta Display", serif`), which the theme's `fontFace` entries won't declare.
- A generic family name such as "Monospace" names no font of its own, so its declared stack is kept as it is (for example `ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace`).
- Otherwise `fontFamily` quotes names that contain spaces and adds a fallback: `monospace` for the `monospace` role, otherwise `sans-serif` by default, or `--font-fallback serif` for serif families. Confirm the fallback with the user.

### Font files

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ describe('FigmaVariablesMapper', () => {
);
});

it('keeps the exact CSS stack declared in a font variable description', () => {
it('keeps the fallbacks of the CSS stack declared in a font variable description', () => {
const font = (value: string, description?: string) =>
new FigmaVariablesMapper().map({
collections: [
Expand All @@ -415,13 +415,48 @@ describe('FigmaVariablesMapper', () => {
(mapped.theme.settings as Json).typography.fontFamilies[0].fontFamily;
const description = 'Headings (live). CSS stack: moret, Georgia, serif';

expect(stack(font('Moret', description))).toBe('moret, Georgia, serif');
// The live @font-face name gives way to the clean family name.
expect(stack(font('Moret', description))).toBe('Moret, Georgia, serif');
expect(
stack(font('Argesta Display', 'Body text (live). CSS stack: argesta_displayregular, serif'))
).toBe('"Argesta Display", serif');
expect(stack(font('Moret', 'CSS stack: moret'))).toBe('Moret');
// A stack for another font is ignored.
expect(stack(font('Lora', description))).toBe('Lora, sans-serif');
expect(stack(font('Moret'))).toBe('Moret, sans-serif');
expect(stack(font('Moret', 'Headings only'))).toBe('Moret, sans-serif');
});

it('keeps the system stack of a generic family such as Monospace', () => {
const family = (slug: string, value: string, description?: string) =>
(
new FigmaVariablesMapper().map({
collections: [
{
name: 'Typography',
modes: [{ id: 'm', name: 'Value' }],
variables: [
{
id: slug,
name: `Font-Families/${value}`,
type: 'STRING',
codeSyntax: { WEB: `var(--wp--preset--font-family--${slug})` },
description,
valuesByMode: { m: value },
},
],
},
],
} as never).theme.settings as Json
).typography.fontFamilies[0].fontFamily;
const system = 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace';

expect(family('monospace', 'Monospace', `Code (default). CSS stack: ${system}`)).toBe(system);
// With no declared stack, a generic name is the stack, and a named mono font falls back to monospace.
expect(family('monospace', 'Monospace')).toBe('monospace');
expect(family('monospace', 'Fira Code')).toBe('"Fira Code", monospace');
});

it('writes only the font roles that exist, with no accent when there is none', () => {
const role = (slug: string, value: string) => ({
id: slug,
Expand Down Expand Up @@ -519,6 +554,56 @@ describe('FigmaVariablesMapper', () => {
);
});

it('maps content and wide width to settings.layout in px', () => {
const width = (id: string, syntax: string, value: unknown, type = 'FLOAT') => ({
id,
name: `Desktop/${id}`,
type,
codeSyntax: { WEB: `var(${syntax})` },
valuesByMode: { m: value },
});
const layout = (...variables: ReturnType<typeof width>[]) =>
new FigmaVariablesMapper().map({
collections: [{ name: 'Theme - Layout', modes: [{ id: 'm', name: 'Mode 1' }], variables }],
} as never);

// The form site-to-design-tokens writes.
const custom = layout(
width('content', '--wp--custom--layout--content-size', 848),
width('wide', '--wp--custom--layout--wide-size', 1232)
);
expect((custom.theme.settings as Json).layout).toEqual({
contentSize: '848px',
wideSize: '1232px',
});
expect((custom.theme.settings as Json).custom).toBeUndefined();
expect(custom.report.counts.layout).toBe(2);

// Core's own variable names, and string values with and without a unit.
const core = layout(
width('content', '--wp--style--global--content-size', '48rem', 'STRING'),
width('wide', '--wp--style--global--wide-size', '1200', 'STRING')
);
expect((core.theme.settings as Json).layout).toEqual({
contentSize: '48rem',
wideSize: '1200px',
});

// A layout width that isn't a length is reported, not written.
const bad = layout(width('content', '--wp--custom--layout--content-size', true, 'BOOLEAN'));
expect((bad.theme.settings as Json).layout).toBeUndefined();
expect(bad.report.warnings.join('\n')).toContain('"Desktop/content" is BOOLEAN');

// A custom value that aliases a width refers to core's variable.
const alias = layout(width('content', '--wp--custom--layout--content-size', 848), {
...width('gutter', '--wp--custom--max-text', 0),
valuesByMode: { m: { type: 'VARIABLE_ALIAS', id: 'content' } },
});
expect((alias.theme.settings as Json).custom['max-text']).toBe(
'var(--wp--style--global--content-size)'
);
});

it('gives custom lengths a unit and refuses unsafe or clashing paths', () => {
const variable = (id: string, syntax: string, value: number) => ({
id,
Expand Down
100 changes: 90 additions & 10 deletions skills/figma-to-block-theme/scripts/figma-variables-to-theme-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,38 @@ interface CustomTarget {
path: string[];
}

/** Content and wide width, which belong in `settings.layout`. */
interface LayoutTarget {
kind: 'layout';
key: 'contentSize' | 'wideSize';
}

type Target = PresetTarget | CustomTarget | LayoutTarget;

/** Keys that would reach Object.prototype if written as plain properties. */
const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype']);

const PRESET_PATTERN =
/--wp--preset--(color|spacing|font-size|font-family|border-radius|shadow)--([a-z0-9-]+)/;
const CUSTOM_PATTERN = /--wp--custom--([a-z0-9-]+(?:--[a-z0-9-]+)*)/;
/** `site-to-design-tokens` writes the custom form; core's own variables are the style form. */
const LAYOUT_PATTERN = /--wp--(?:custom--layout|style--global)--(content|wide)-size(?![a-z0-9-])/;
/** CSS generic font families, which name no font of their own. */
const GENERIC_FAMILIES = new Set([
'serif',
'sans-serif',
'monospace',
'cursive',
'fantasy',
'system-ui',
'ui-serif',
'ui-sans-serif',
'ui-monospace',
'ui-rounded',
'math',
'emoji',
'fangsong',
]);
const MIN_MODE_PATTERN = /^(mobile|min|small|sm)$/i;
const MAX_MODE_PATTERN = /^(desktop|max|large|lg)$/i;

Expand Down Expand Up @@ -134,6 +160,8 @@ export class FigmaVariablesMapper {
private warnings: string[] = [];
/** Variation keys that come from colour modes. */
private readonly colourModes = new Set<string>();
/** `settings.layout` widths found while mapping. */
private layout: JsonObject = {};

constructor(options: MapperOptions = {}) {
this.options = options;
Expand All @@ -142,6 +170,7 @@ export class FigmaVariablesMapper {

map(data: VariablesExport): MappingResult {
this.warnings = [];
this.layout = {};
this.colourModes.clear();
this.byId.clear();
for (const collection of data.collections) {
Expand Down Expand Up @@ -200,13 +229,17 @@ export class FigmaVariablesMapper {
this.assign(settings, ['shadow', 'defaultPresets'], false);
this.assign(settings, ['shadow', 'presets'], presets.shadow);
}
if (Object.keys(this.layout).length) {
settings.layout = this.layout;
}
if (Object.keys(custom).length) {
settings.custom = custom;
}

for (const [family, entries] of Object.entries(presets)) {
counts[family] = entries.length;
}
counts.layout = Object.keys(this.layout).length;
counts.custom = this.countLeaves(custom);
counts.variations = Object.keys(variations).length;

Expand Down Expand Up @@ -245,6 +278,11 @@ export class FigmaVariablesMapper {
continue;
}

if (target.kind === 'layout') {
this.mapLayout(variable, target, baseMode.id);
continue;
}

if (target.kind === 'custom') {
this.assign(custom, target.path, this.customValue(variable, baseMode.id, target.path));
if (target.path[0] === 'color') {
Expand Down Expand Up @@ -358,7 +396,7 @@ export class FigmaVariablesMapper {
return {
slug: target.slug,
name: value,
fontFamily: this.declaredStack(variable, value) ?? this.fontStack(value),
fontFamily: this.declaredStack(variable, value) ?? this.fontStack(value, target.slug),
};
case 'border-radius':
if (typeof value !== 'number') {
Expand All @@ -378,6 +416,19 @@ export class FigmaVariablesMapper {
}
}

/** Content and wide width go to `settings.layout` as CSS lengths. */
private mapLayout(variable: ExportedVariable, target: LayoutTarget, modeId: string): void {
const value = this.resolve(variable, modeId);
if (typeof value === 'number') {
this.layout[target.key] = this.px(value);
} else if (typeof value === 'string' && value.trim()) {
// A string such as "48rem" already has its unit; a bare number gets px.
this.layout[target.key] = /^\d+(\.\d+)?$/.test(value.trim()) ? `${value.trim()}px` : value;
} else {
this.typeMismatch(variable, 'FLOAT');
}
}

private customValue(variable: ExportedVariable, modeId: string, path: string[]): unknown {
const raw = variable.valuesByMode[modeId];

Expand All @@ -390,6 +441,10 @@ export class FigmaVariablesMapper {
if (presetTarget && presetTarget.kind === 'custom') {
return `var(--wp--custom--${presetTarget.path.join('--')})`;
}
if (presetTarget && presetTarget.kind === 'layout') {
const width = presetTarget.key === 'contentSize' ? 'content' : 'wide';
return `var(--wp--style--global--${width}-size)`;
}
}

const value = this.resolve(variable, modeId);
Expand Down Expand Up @@ -461,15 +516,16 @@ export class FigmaVariablesMapper {
return presets;
}

private parseTarget(
variable: ExportedVariable,
report = true
): PresetTarget | CustomTarget | undefined {
private parseTarget(variable: ExportedVariable, report = true): Target | undefined {
const syntax = variable.codeSyntax?.WEB;
const preset = syntax?.match(PRESET_PATTERN);
if (preset) {
return { kind: 'preset', family: preset[1], slug: preset[2] };
}
const layout = syntax?.match(LAYOUT_PATTERN);
if (layout) {
return { kind: 'layout', key: layout[1] === 'content' ? 'contentSize' : 'wideSize' };
}
const customMatch = syntax?.match(CUSTOM_PATTERN);
if (customMatch) {
return { kind: 'custom', path: customMatch[1].split('--') };
Expand Down Expand Up @@ -560,20 +616,44 @@ export class FigmaVariablesMapper {
* The exact CSS stack from a `CSS stack: ...` line in the variable description, used
* only when its first family is the font the mode's value names (other modes differ).
*/
/**
* Uses the fallbacks from a "CSS stack: …" description. The declared stack starts
* with the live site's own `@font-face` name (such as `argesta_displayregular`),
* which the new theme's `fontFace` entries won't declare, so the clean family name
* replaces it.
*/
private declaredStack(variable: ExportedVariable, name: string): string | undefined {
const stack = variable.description?.match(/CSS stack:\s*(.+)$/m)?.[1].trim();
if (!stack) {
return undefined;
}
// A generic name such as "Monospace" has no font of its own: the declared system stack is the font.
if (GENERIC_FAMILIES.has(name.trim().toLowerCase())) {
return stack;
}
const [first, ...fallbacks] = stack.split(',').map((part) => part.trim());
const plain = (text: string) => text.toLowerCase().replace(/[^a-z0-9]/g, '');
const first = plain(stack.split(',')[0]);
const face = plain(first);
const wanted = plain(name);
return first.startsWith(wanted) || wanted.startsWith(first) ? stack : undefined;
if (!face.startsWith(wanted) && !wanted.startsWith(face)) {
return undefined;
}
return [this.quoteFamily(name), ...fallbacks.filter(Boolean)].join(', ');
}

/** A stack with no declaration: the family, then the generic family for its role. */
private fontStack(family: string, slug: string): string {
const generic = family.trim().toLowerCase();
if (GENERIC_FAMILIES.has(generic)) {
return generic;
}
const fallback =
slug === 'monospace' ? 'monospace' : (this.options.fontFallback ?? 'sans-serif');
return `${this.quoteFamily(family)}, ${fallback}`;
}

private fontStack(family: string): string {
const quoted = /\s/.test(family) ? `"${family}"` : family;
return `${quoted}, ${this.options.fontFallback ?? 'sans-serif'}`;
private quoteFamily(family: string): string {
return /\s/.test(family) ? `"${family}"` : family;
}

private typeMismatch(variable: ExportedVariable, expected: string): undefined {
Expand Down
Loading
Loading