Файли
openidea/src/styles/spacingScale.test.ts
T
Mr0Bread 9a518e734b refactor(styles): put gap on the spacing scale (#3562)
Extends the 4px-grid spacing scale with --space-0-5 (2px), --space-1 (4px) and --space-1-5 (6px) and replaces the literal 2/4/6/8/12/16px gap, row-gap and column-gap values with the tokens; computed values are unchanged. src/styles/spacingScale.test.ts flags an on-scale literal gap.

Co-authored-by: Mr0Bread <[email protected]>
2026-11-15 23:59:47 +08:00

19 рядки
682 B
TypeScript

import { globSync, readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
// `gap` takes the spacing scale in tokens.css; these literals have a token.
const SCALED = /(?:^|[;{\s])(?:row-|column-)?gap\s*:\s*[^;}]*\b(?:2|4|6|8|12|16)px\b/g;
describe("spacing scale", () => {
it("gap uses --space-* tokens for on-scale values", () => {
const offenders: string[] = [];
for (const file of globSync("src/**/*.css")) {
if (file.endsWith("styles/tokens.css")) continue;
for (const m of readFileSync(file, "utf8").matchAll(SCALED)) {
offenders.push(`${file}: ${m[0].trim()}`);
}
}
expect(offenders).toEqual([]);
});
});