Skip to content

Commit 4cab7c2

Browse files
sametbasbugclaude
andcommitted
Put the type on a scale instead of on instinct
There were 52 distinct font sizes across 190 declarations, thirty of them crowded between 0.5 and 1rem: 0.64, 0.65, 0.66, 0.67. Nobody chose those apart; they accumulated. Every new component meant guessing which of six near-identical smalls it belonged to. Measuring them turned out to be the whole argument. The hand-written values already tracked a 1.125 ratio off a 1rem base -- with noise on top. So the scale isn't imposed, it's the shape that was already there: --text-3xs through --text-7xl, fourteen steps, 188 declarations mapped to their nearest one. Rendered drift is at most 1.18px, line-height included, since unitless line-heights resolve against font-size. 178 of 188 declarations moved less than a pixel; the rest are display headings where a pixel is under half a percent. Two things stay off the scale on purpose: clamp()'d hero headings, which interpolate continuously rather than picking a step, and the giant monogram watermarks, which are graphics wearing a font. The colour snapshot tool grew a second property group for this and is now orbit-style-snapshot.mjs. Its diff reports pixel drift, because here the goal was never zero difference -- it was difference below threshold. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent dc5ce87 commit 4cab7c2

7 files changed

Lines changed: 267 additions & 207 deletions

File tree

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/**
2-
* Renk regresyon aracı.
2+
* Görünüm regresyon aracı.
33
*
4-
* Semantik token refactor'ünün görünümü değiştirmediğini kanıtlamak için
5-
* kullanılıyor: belirlenen sayfalarda, iki temada, her elemanın hesaplanmış
6-
* renk özelliklerini toplar ve dosyaya yazar. Refactor öncesi/sonrası iki
7-
* anlık görüntü diff'lenir.
4+
* Token refactor'ünün görünümü değiştirmediğini kanıtlamak için kullanılıyor:
5+
* belirlenen sayfalarda, iki temada, her elemanın hesaplanmış özelliklerini
6+
* toplar ve dosyaya yazar. Refactor öncesi/sonrası iki anlık görüntü diff'lenir.
87
*
9-
* node scripts/orbit-color-snapshot.mjs <cikti.json>
10-
* node scripts/orbit-color-snapshot.mjs --diff <once.json> <sonra.json>
8+
* node scripts/orbit-style-snapshot.mjs [--group renk|tip] <cikti.json>
9+
* node scripts/orbit-style-snapshot.mjs --diff <once.json> <sonra.json>
10+
*
11+
* Tip grubunda diff, px cinsinden kaymayı da yazar; skala refactor'ünde amaç
12+
* sıfır fark değil, farkın eşiğin altında kaldığını görmek.
1113
*/
1214
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
1315
import { chromium } from 'playwright-core';
@@ -27,9 +29,13 @@ function chromeExecutable() {
2729
const BASE = process.env.ORBIT_SNAPSHOT_BASE ?? 'http://localhost:4321';
2830
const PAGES = ['/', '/agents', '/agents/nyx', '/posts/katki-kime-ait', '/topics', '/about', '/search', '/saved'];
2931
const THEMES = ['light', 'dark'];
30-
const PROPS = ['color', 'backgroundColor', 'borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'outlineColor', 'boxShadow', 'backgroundImage'];
32+
const GROUPS = {
33+
renk: ['color', 'backgroundColor', 'borderTopColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'outlineColor', 'boxShadow', 'backgroundImage'],
34+
tip: ['fontSize', 'fontWeight', 'letterSpacing', 'lineHeight', 'textTransform', 'fontFamily'],
35+
};
3136

32-
async function capture(outputPath) {
37+
async function capture(outputPath, group) {
38+
const PROPS = GROUPS[group];
3339
const executablePath = chromeExecutable();
3440
if (!executablePath) throw new Error('Desteklenen Chrome/Chromium executable bulunamadı.');
3541
const browser = await chromium.launch({ executablePath, headless: true });
@@ -57,20 +63,37 @@ async function capture(outputPath) {
5763
}
5864

5965
await browser.close();
60-
writeFileSync(outputPath, JSON.stringify(snapshot, null, 1));
66+
writeFileSync(outputPath, JSON.stringify({ group, pages: snapshot }, null, 1));
6167
const count = Object.values(snapshot).reduce((total, page) => total + Object.keys(page).length, 0);
62-
console.log(`${Object.keys(snapshot).length} sayfa-tema, ${count} eleman yazıldı: ${outputPath}`);
68+
console.log(`${group}: ${Object.keys(snapshot).length} sayfa-tema, ${count} eleman yazıldı: ${outputPath}`);
69+
}
70+
71+
/** "13.6px|750|0.08em|..." içindeki px değerlerini çıkar. */
72+
function pixels(value) {
73+
return [...value.matchAll(/(-?[\d.]+)px/gu)].map((match) => Number(match[1]));
74+
}
75+
76+
/** İki kaydın px alanları arasındaki en büyük mutlak fark; px yoksa null. */
77+
function drift(before, after) {
78+
const a = pixels(before);
79+
const b = pixels(after);
80+
if (a.length === 0 || a.length !== b.length) return null;
81+
return Math.max(...a.map((value, index) => Math.abs(value - b[index])));
6382
}
6483

6584
function diff(beforePath, afterPath) {
6685
const before = JSON.parse(readFileSync(beforePath, 'utf8'));
6786
const after = JSON.parse(readFileSync(afterPath, 'utf8'));
87+
if (before.group !== after.group) {
88+
throw new Error(`Farklı gruplar karşılaştırılamaz: ${before.group} ve ${after.group}`);
89+
}
6890
let changed = 0;
6991
let compared = 0;
92+
let worst = 0;
7093

71-
for (const scope of Object.keys(before)) {
72-
const a = before[scope];
73-
const b = after[scope] ?? {};
94+
for (const scope of Object.keys(before.pages)) {
95+
const a = before.pages[scope];
96+
const b = after.pages[scope] ?? {};
7497
for (const [key, value] of Object.entries(a)) {
7598
compared += 1;
7699
if (b[key] === undefined) {
@@ -79,16 +102,24 @@ function diff(beforePath, afterPath) {
79102
continue;
80103
}
81104
if (b[key] !== value) {
82-
console.log(`[değişti] ${scope} ${key}\n önce: ${value}\n sonra: ${b[key]}`);
105+
const shift = drift(value, b[key]);
106+
if (shift !== null) worst = Math.max(worst, shift);
107+
console.log(`[değişti] ${scope} ${key}${shift === null ? '' : ` (${shift.toFixed(2)}px)`}\n önce: ${value}\n sonra: ${b[key]}`);
83108
changed += 1;
84109
}
85110
}
86111
}
87112

88-
console.log(`\n${compared} eleman karşılaştırıldı, ${changed} fark.`);
113+
console.log(`\n${compared} eleman karşılaştırıldı, ${changed} fark.${worst ? ` En büyük kayma ${worst.toFixed(2)}px.` : ''}`);
89114
process.exitCode = changed === 0 ? 0 : 1;
90115
}
91116

92-
const [first, ...rest] = process.argv.slice(2);
93-
if (first === '--diff') diff(rest[0], rest[1]);
94-
else await capture(first);
117+
const args = process.argv.slice(2);
118+
if (args[0] === '--diff') {
119+
diff(args[1], args[2]);
120+
} else {
121+
const group = args[0] === '--group' ? args[1] : 'renk';
122+
const output = args[0] === '--group' ? args[2] : args[0];
123+
if (!GROUPS[group]) throw new Error(`Bilinmeyen grup: ${group}. Seçenekler: ${Object.keys(GROUPS).join(', ')}`);
124+
await capture(output, group);
125+
}

‎src/styles/base.css‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ main {
7474
.section-label {
7575
margin: 0 0 0.65rem;
7676
color: var(--muted);
77-
font-size: 0.66rem;
77+
font-size: var(--text-2xs);
7878
font-weight: 700;
7979
letter-spacing: 0.09em;
8080
text-transform: uppercase;
@@ -84,7 +84,7 @@ main {
8484
display: inline-block;
8585
margin-top: 1rem;
8686
color: var(--link);
87-
font-size: 0.75rem;
87+
font-size: var(--text-sm);
8888
font-weight: 600;
8989
text-underline-offset: 0.2rem;
9090
}
@@ -96,7 +96,7 @@ main {
9696
justify-content: center;
9797
padding: 0 1rem;
9898
border: 1px solid var(--ink);
99-
font-size: 0.75rem;
99+
font-size: var(--text-sm);
100100
font-weight: 700;
101101
text-decoration: none;
102102
}
@@ -137,7 +137,7 @@ main {
137137
border-radius: 0.7rem;
138138
color: #fff;
139139
background: #27345f;
140-
font-size: 0.76rem;
140+
font-size: var(--text-sm);
141141
font-weight: 800;
142142
text-decoration: none;
143143
transform: translateY(-180%);

0 commit comments

Comments
 (0)