designlang 5.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +62 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +28 -0
- package/CHANGELOG.md +43 -0
- package/README.md +177 -6
- package/bin/design-extract.js +302 -92
- package/docs/superpowers/plans/2026-04-18-designlang-v7.md +1121 -0
- package/docs/superpowers/specs/2026-04-18-designlang-v7-design.md +150 -0
- package/package.json +13 -7
- package/src/config.js +59 -0
- package/src/crawler.js +297 -95
- package/src/extractors/a11y-remediation.js +47 -0
- package/src/extractors/animations.js +37 -5
- package/src/extractors/borders.js +40 -5
- package/src/extractors/component-clusters.js +39 -0
- package/src/extractors/components.js +77 -1
- package/src/extractors/css-health.js +151 -0
- package/src/extractors/gradients.js +25 -5
- package/src/extractors/scoring.js +20 -1
- package/src/extractors/semantic-regions.js +44 -0
- package/src/extractors/shadows.js +60 -17
- package/src/extractors/spacing.js +31 -2
- package/src/extractors/stack-fingerprint.js +88 -0
- package/src/extractors/variables.js +20 -1
- package/src/formatters/_token-ref.js +44 -0
- package/src/formatters/agent-rules.js +116 -0
- package/src/formatters/android-compose.js +164 -0
- package/src/formatters/dtcg-tokens.js +175 -0
- package/src/formatters/figma.js +66 -47
- package/src/formatters/flutter-dart.js +130 -0
- package/src/formatters/ios-swiftui.js +161 -0
- package/src/formatters/markdown.js +25 -0
- package/src/formatters/preview.js +65 -22
- package/src/formatters/svelte-theme.js +40 -0
- package/src/formatters/tailwind.js +57 -4
- package/src/formatters/theme.js +134 -0
- package/src/formatters/vue-theme.js +44 -0
- package/src/formatters/wordpress.js +267 -0
- package/src/history.js +8 -1
- package/src/index.js +76 -20
- package/src/mcp/resources.js +64 -0
- package/src/mcp/server.js +110 -0
- package/src/mcp/tools.js +149 -0
- package/src/utils.js +68 -0
- package/tests/cli.test.js +84 -0
- package/tests/extractors.test.js +792 -0
- package/tests/formatters.test.js +709 -0
- package/tests/mcp.test.js +68 -0
- package/tests/utils.test.js +413 -0
- package/website/app/globals.css +11 -11
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { buildResources } from '../src/mcp/resources.js';
|
|
4
|
+
import { buildTools } from '../src/mcp/tools.js';
|
|
5
|
+
|
|
6
|
+
const tokens = {
|
|
7
|
+
$metadata: { source: 'https://x.com' },
|
|
8
|
+
primitive: { color: { brand: { primary: { $value: '#3b82f6', $type: 'color' } } } },
|
|
9
|
+
semantic: { color: { action: { primary: { $value: '{primitive.color.brand.primary}', $type: 'color' } } } },
|
|
10
|
+
};
|
|
11
|
+
const design = {
|
|
12
|
+
colors: { all: ['#000', '#111', '#555', '#fff'] },
|
|
13
|
+
regions: [{ role: 'hero', bounds: { x:0,y:0,w:1280,h:600 }, heading: 'Build' }],
|
|
14
|
+
componentClusters: [{ kind: 'button', instanceCount: 5, variants: [{ css: { bg: '#3b82f6' }, instanceCount: 3 }] }],
|
|
15
|
+
accessibility: { remediation: [{ fg:'#eee', bg:'#fff', ratio:1.1, rule:'AA-normal', suggestion:{replace:'fg',color:'#000',newRatio:21}}] },
|
|
16
|
+
cssHealth: null,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe('MCP resources', () => {
|
|
20
|
+
it('lists five URIs', () => {
|
|
21
|
+
const r = buildResources({ design, tokens });
|
|
22
|
+
assert.equal(r.list().length, 5);
|
|
23
|
+
assert.ok(r.list().find(x => x.uri === 'designlang://tokens/semantic'));
|
|
24
|
+
});
|
|
25
|
+
it('reads semantic tokens', () => {
|
|
26
|
+
const r = buildResources({ design, tokens });
|
|
27
|
+
const out = r.read('designlang://tokens/semantic');
|
|
28
|
+
const body = JSON.parse(out.text);
|
|
29
|
+
assert.ok(body.color?.action?.primary);
|
|
30
|
+
});
|
|
31
|
+
it('throws for unknown uri', () => {
|
|
32
|
+
const r = buildResources({ design, tokens });
|
|
33
|
+
assert.throws(() => r.read('designlang://nope'));
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('MCP tools', () => {
|
|
38
|
+
it('search_tokens finds semantic token by substring', async () => {
|
|
39
|
+
const t = buildTools({ design, tokens });
|
|
40
|
+
const res = await t.call('search_tokens', { query: 'action.primary' });
|
|
41
|
+
assert.ok(JSON.stringify(res.matches).includes('action.primary'));
|
|
42
|
+
});
|
|
43
|
+
it('find_nearest_color returns a palette color passing AA', async () => {
|
|
44
|
+
const t = buildTools({ design, tokens });
|
|
45
|
+
const res = await t.call('find_nearest_color', { hex: '#ffffff', level: 'AA-normal' });
|
|
46
|
+
assert.ok(res.color);
|
|
47
|
+
assert.ok(res.newRatio >= 4.5);
|
|
48
|
+
});
|
|
49
|
+
it('get_region returns hero', async () => {
|
|
50
|
+
const t = buildTools({ design, tokens });
|
|
51
|
+
const res = await t.call('get_region', { name: 'hero' });
|
|
52
|
+
assert.equal(res.role, 'hero');
|
|
53
|
+
});
|
|
54
|
+
it('get_component returns button cluster', async () => {
|
|
55
|
+
const t = buildTools({ design, tokens });
|
|
56
|
+
const res = await t.call('get_component', { name: 'button' });
|
|
57
|
+
assert.equal(res.kind, 'button');
|
|
58
|
+
});
|
|
59
|
+
it('list_failing_contrast_pairs returns remediation array', async () => {
|
|
60
|
+
const t = buildTools({ design, tokens });
|
|
61
|
+
const res = await t.call('list_failing_contrast_pairs');
|
|
62
|
+
assert.equal(res.length, 1);
|
|
63
|
+
});
|
|
64
|
+
it('throws on unknown tool', async () => {
|
|
65
|
+
const t = buildTools({ design, tokens });
|
|
66
|
+
await assert.rejects(() => t.call('nope', {}));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import {
|
|
4
|
+
parseColor,
|
|
5
|
+
rgbToHex,
|
|
6
|
+
rgbToHsl,
|
|
7
|
+
colorDistance,
|
|
8
|
+
clusterColors,
|
|
9
|
+
clusterValues,
|
|
10
|
+
parseCSSValue,
|
|
11
|
+
detectScale,
|
|
12
|
+
nameFromUrl,
|
|
13
|
+
isSaturated,
|
|
14
|
+
safeName,
|
|
15
|
+
remToPx,
|
|
16
|
+
pxToRem,
|
|
17
|
+
} from '../src/utils.js';
|
|
18
|
+
|
|
19
|
+
// ── parseColor ──────────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
describe('parseColor', () => {
|
|
22
|
+
it('returns null for null/undefined/empty/none/inherit', () => {
|
|
23
|
+
assert.equal(parseColor(null), null);
|
|
24
|
+
assert.equal(parseColor(undefined), null);
|
|
25
|
+
assert.equal(parseColor(''), null);
|
|
26
|
+
assert.equal(parseColor('none'), null);
|
|
27
|
+
assert.equal(parseColor('inherit'), null);
|
|
28
|
+
assert.equal(parseColor('initial'), null);
|
|
29
|
+
assert.equal(parseColor('currentcolor'), null);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('parses 3-digit hex (#RGB)', () => {
|
|
33
|
+
const c = parseColor('#f00');
|
|
34
|
+
assert.deepEqual(c, { r: 255, g: 0, b: 0, a: 1 });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('parses 6-digit hex (#RRGGBB)', () => {
|
|
38
|
+
const c = parseColor('#0066cc');
|
|
39
|
+
assert.deepEqual(c, { r: 0, g: 102, b: 204, a: 1 });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('parses 8-digit hex (#RRGGBBAA)', () => {
|
|
43
|
+
const c = parseColor('#0066cc80');
|
|
44
|
+
assert.equal(c.r, 0);
|
|
45
|
+
assert.equal(c.g, 102);
|
|
46
|
+
assert.equal(c.b, 204);
|
|
47
|
+
assert.ok(Math.abs(c.a - 128 / 255) < 0.01);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('parses 4-digit hex (#RGBA)', () => {
|
|
51
|
+
const c = parseColor('#f008');
|
|
52
|
+
assert.equal(c.r, 255);
|
|
53
|
+
assert.equal(c.g, 0);
|
|
54
|
+
assert.equal(c.b, 0);
|
|
55
|
+
assert.ok(Math.abs(c.a - 0x88 / 255) < 0.01);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('parses rgb(r, g, b)', () => {
|
|
59
|
+
const c = parseColor('rgb(100, 200, 50)');
|
|
60
|
+
assert.deepEqual(c, { r: 100, g: 200, b: 50, a: 1 });
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('parses rgba(r, g, b, a)', () => {
|
|
64
|
+
const c = parseColor('rgba(100, 200, 50, 0.5)');
|
|
65
|
+
assert.deepEqual(c, { r: 100, g: 200, b: 50, a: 0.5 });
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('parses hsl(h, s%, l%)', () => {
|
|
69
|
+
const c = parseColor('hsl(0, 100%, 50%)');
|
|
70
|
+
assert.equal(c.r, 255);
|
|
71
|
+
assert.equal(c.g, 0);
|
|
72
|
+
assert.equal(c.b, 0);
|
|
73
|
+
assert.equal(c.a, 1);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('parses hsla(h, s%, l%, a)', () => {
|
|
77
|
+
const c = parseColor('hsla(0, 100%, 50%, 0.5)');
|
|
78
|
+
assert.equal(c.r, 255);
|
|
79
|
+
assert.equal(c.a, 0.5);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('parses modern hsl syntax: hsl(210 50% 40%)', () => {
|
|
83
|
+
const c = parseColor('hsl(210 50% 40%)');
|
|
84
|
+
assert.ok(c);
|
|
85
|
+
assert.equal(c.a, 1);
|
|
86
|
+
// hsl(210, 50%, 40%) -> some shade of blue
|
|
87
|
+
assert.ok(c.b > c.r);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('parses modern hsl syntax with alpha: hsl(210 50% 40% / 0.5)', () => {
|
|
91
|
+
const c = parseColor('hsl(210 50% 40% / 0.5)');
|
|
92
|
+
assert.ok(c);
|
|
93
|
+
assert.equal(c.a, 0.5);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('parses oklch(L C H)', () => {
|
|
97
|
+
const c = parseColor('oklch(0.5 0.2 270)');
|
|
98
|
+
assert.ok(c);
|
|
99
|
+
assert.equal(c.a, 1);
|
|
100
|
+
assert.ok(c.r >= 0 && c.r <= 255);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('parses oklch with alpha', () => {
|
|
104
|
+
const c = parseColor('oklch(0.5 0.2 270 / 0.8)');
|
|
105
|
+
assert.ok(c);
|
|
106
|
+
assert.equal(c.a, 0.8);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('parses oklab(L a b)', () => {
|
|
110
|
+
const c = parseColor('oklab(0.5 0.1 -0.1)');
|
|
111
|
+
assert.ok(c);
|
|
112
|
+
assert.equal(c.a, 1);
|
|
113
|
+
assert.ok(c.r >= 0 && c.r <= 255);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('parses color-mix(in srgb, ...)', () => {
|
|
117
|
+
const c = parseColor('color-mix(in srgb, #ff0000 50%, #0000ff)');
|
|
118
|
+
assert.ok(c);
|
|
119
|
+
// Should be roughly halfway between red and blue
|
|
120
|
+
assert.ok(c.r > 100);
|
|
121
|
+
assert.ok(c.b > 100);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('parses named colors', () => {
|
|
125
|
+
const c = parseColor('red');
|
|
126
|
+
assert.deepEqual(c, { r: 255, g: 0, b: 0, a: 1 });
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('parses named color white', () => {
|
|
130
|
+
const c = parseColor('white');
|
|
131
|
+
assert.deepEqual(c, { r: 255, g: 255, b: 255, a: 1 });
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('parses named colors case-insensitively', () => {
|
|
135
|
+
const c = parseColor('RED');
|
|
136
|
+
assert.deepEqual(c, { r: 255, g: 0, b: 0, a: 1 });
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('returns null for unrecognized strings', () => {
|
|
140
|
+
assert.equal(parseColor('not-a-color'), null);
|
|
141
|
+
assert.equal(parseColor('blahblah'), null);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// ── rgbToHex ────────────────────────────────────────────────────
|
|
146
|
+
|
|
147
|
+
describe('rgbToHex', () => {
|
|
148
|
+
it('converts black', () => {
|
|
149
|
+
assert.equal(rgbToHex({ r: 0, g: 0, b: 0 }), '#000000');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('converts white', () => {
|
|
153
|
+
assert.equal(rgbToHex({ r: 255, g: 255, b: 255 }), '#ffffff');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('converts a mid color', () => {
|
|
157
|
+
assert.equal(rgbToHex({ r: 0, g: 102, b: 204 }), '#0066cc');
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// ── rgbToHsl ────────────────────────────────────────────────────
|
|
162
|
+
|
|
163
|
+
describe('rgbToHsl', () => {
|
|
164
|
+
it('converts pure red', () => {
|
|
165
|
+
const hsl = rgbToHsl({ r: 255, g: 0, b: 0 });
|
|
166
|
+
assert.equal(hsl.h, 0);
|
|
167
|
+
assert.equal(hsl.s, 100);
|
|
168
|
+
assert.equal(hsl.l, 50);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('converts pure green (CSS green = 0,128,0)', () => {
|
|
172
|
+
const hsl = rgbToHsl({ r: 0, g: 128, b: 0 });
|
|
173
|
+
assert.equal(hsl.h, 120);
|
|
174
|
+
assert.equal(hsl.l, 25);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('converts gray (achromatic)', () => {
|
|
178
|
+
const hsl = rgbToHsl({ r: 128, g: 128, b: 128 });
|
|
179
|
+
assert.equal(hsl.h, 0);
|
|
180
|
+
assert.equal(hsl.s, 0);
|
|
181
|
+
assert.equal(hsl.l, 50);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('converts white', () => {
|
|
185
|
+
const hsl = rgbToHsl({ r: 255, g: 255, b: 255 });
|
|
186
|
+
assert.equal(hsl.l, 100);
|
|
187
|
+
assert.equal(hsl.s, 0);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// ── colorDistance ────────────────────────────────────────────────
|
|
192
|
+
|
|
193
|
+
describe('colorDistance', () => {
|
|
194
|
+
it('returns 0 for identical colors', () => {
|
|
195
|
+
assert.equal(colorDistance({ r: 100, g: 100, b: 100 }, { r: 100, g: 100, b: 100 }), 0);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('returns correct Euclidean distance', () => {
|
|
199
|
+
const d = colorDistance({ r: 0, g: 0, b: 0 }, { r: 255, g: 255, b: 255 });
|
|
200
|
+
assert.ok(Math.abs(d - Math.sqrt(3 * 255 * 255)) < 0.01);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('returns small distance for similar colors', () => {
|
|
204
|
+
const d = colorDistance({ r: 100, g: 100, b: 100 }, { r: 105, g: 100, b: 100 });
|
|
205
|
+
assert.ok(d < 10);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// ── clusterColors ───────────────────────────────────────────────
|
|
210
|
+
|
|
211
|
+
describe('clusterColors', () => {
|
|
212
|
+
it('groups similar colors together', () => {
|
|
213
|
+
const colors = [
|
|
214
|
+
{ hex: '#ff0000', parsed: { r: 255, g: 0, b: 0 }, count: 10 },
|
|
215
|
+
{ hex: '#ff0505', parsed: { r: 255, g: 5, b: 5 }, count: 5 },
|
|
216
|
+
{ hex: '#0000ff', parsed: { r: 0, g: 0, b: 255 }, count: 3 },
|
|
217
|
+
];
|
|
218
|
+
const clusters = clusterColors(colors, 15);
|
|
219
|
+
// Red shades should be grouped, blue separate
|
|
220
|
+
assert.equal(clusters.length, 2);
|
|
221
|
+
assert.equal(clusters[0].count, 15); // red cluster total
|
|
222
|
+
assert.equal(clusters[1].count, 3); // blue cluster
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('returns each color as its own cluster when threshold is 0', () => {
|
|
226
|
+
const colors = [
|
|
227
|
+
{ hex: '#ff0000', parsed: { r: 255, g: 0, b: 0 }, count: 10 },
|
|
228
|
+
{ hex: '#ff0505', parsed: { r: 255, g: 5, b: 5 }, count: 5 },
|
|
229
|
+
];
|
|
230
|
+
const clusters = clusterColors(colors, 0);
|
|
231
|
+
assert.equal(clusters.length, 2);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('sorts clusters by count descending', () => {
|
|
235
|
+
const colors = [
|
|
236
|
+
{ hex: '#0000ff', parsed: { r: 0, g: 0, b: 255 }, count: 3 },
|
|
237
|
+
{ hex: '#ff0000', parsed: { r: 255, g: 0, b: 0 }, count: 10 },
|
|
238
|
+
];
|
|
239
|
+
const clusters = clusterColors(colors, 15);
|
|
240
|
+
assert.ok(clusters[0].count >= clusters[clusters.length - 1].count);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// ── clusterValues ───────────────────────────────────────────────
|
|
245
|
+
|
|
246
|
+
describe('clusterValues', () => {
|
|
247
|
+
it('groups nearby numbers', () => {
|
|
248
|
+
const result = clusterValues([4, 5, 8, 16, 17, 32], 2);
|
|
249
|
+
// 4 and 5 cluster -> 4; 8 standalone; 16 and 17 cluster -> 16; 32 standalone
|
|
250
|
+
assert.ok(result.includes(4));
|
|
251
|
+
assert.ok(result.includes(8));
|
|
252
|
+
assert.ok(result.includes(16));
|
|
253
|
+
assert.ok(result.includes(32));
|
|
254
|
+
assert.ok(!result.includes(5));
|
|
255
|
+
assert.ok(!result.includes(17));
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it('returns all values when threshold is 0', () => {
|
|
259
|
+
const result = clusterValues([1, 2, 3], 0);
|
|
260
|
+
assert.deepEqual(result, [1, 2, 3]);
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// ── parseCSSValue ───────────────────────────────────────────────
|
|
265
|
+
|
|
266
|
+
describe('parseCSSValue', () => {
|
|
267
|
+
it('parses px values', () => {
|
|
268
|
+
const r = parseCSSValue('16px');
|
|
269
|
+
assert.deepEqual(r, { value: 16, unit: 'px' });
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('parses rem values', () => {
|
|
273
|
+
const r = parseCSSValue('1.5rem');
|
|
274
|
+
assert.deepEqual(r, { value: 1.5, unit: 'rem' });
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('parses em values', () => {
|
|
278
|
+
const r = parseCSSValue('2em');
|
|
279
|
+
assert.deepEqual(r, { value: 2, unit: 'em' });
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('parses percentage values', () => {
|
|
283
|
+
const r = parseCSSValue('100%');
|
|
284
|
+
assert.deepEqual(r, { value: 100, unit: '%' });
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('parses unitless numbers', () => {
|
|
288
|
+
const r = parseCSSValue('1.5');
|
|
289
|
+
assert.deepEqual(r, { value: 1.5, unit: '' });
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('returns null for normal/auto/none', () => {
|
|
293
|
+
assert.equal(parseCSSValue('normal'), null);
|
|
294
|
+
assert.equal(parseCSSValue('auto'), null);
|
|
295
|
+
assert.equal(parseCSSValue('none'), null);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('returns null for null/undefined', () => {
|
|
299
|
+
assert.equal(parseCSSValue(null), null);
|
|
300
|
+
assert.equal(parseCSSValue(undefined), null);
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
// ── detectScale ─────────────────────────────────────────────────
|
|
305
|
+
|
|
306
|
+
describe('detectScale', () => {
|
|
307
|
+
it('detects a base unit for multiples-of-4 scale', () => {
|
|
308
|
+
// All values are divisible by 2 and 4; the algorithm picks the first
|
|
309
|
+
// candidate (2) that reaches the 60% threshold, so base is 2.
|
|
310
|
+
const result = detectScale([4, 8, 12, 16, 24, 32, 48, 64]);
|
|
311
|
+
assert.ok(result.base !== null);
|
|
312
|
+
assert.ok([2, 4].includes(result.base));
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('detects a base unit for multiples-of-8 scale', () => {
|
|
316
|
+
const result = detectScale([8, 16, 24, 32, 40, 48, 56, 64]);
|
|
317
|
+
assert.ok(result.base !== null);
|
|
318
|
+
assert.ok([2, 4, 8].includes(result.base));
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('returns null base for fewer than 3 values', () => {
|
|
322
|
+
const result = detectScale([10, 20]);
|
|
323
|
+
assert.equal(result.base, null);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('returns null base for arbitrary values', () => {
|
|
327
|
+
const result = detectScale([3, 7, 11, 19, 37, 53]);
|
|
328
|
+
assert.equal(result.base, null);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// ── nameFromUrl ─────────────────────────────────────────────────
|
|
333
|
+
|
|
334
|
+
describe('nameFromUrl', () => {
|
|
335
|
+
it('extracts hostname and makes it safe', () => {
|
|
336
|
+
// safeName replaces dots with hyphens
|
|
337
|
+
assert.equal(nameFromUrl('https://www.example.com/page'), 'example-com');
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('strips www prefix', () => {
|
|
341
|
+
const name = nameFromUrl('https://www.google.com');
|
|
342
|
+
assert.ok(!name.startsWith('www'));
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it('returns unknown-site for invalid URLs', () => {
|
|
346
|
+
assert.equal(nameFromUrl('not a url'), 'unknown-site');
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it('handles complex domains', () => {
|
|
350
|
+
const name = nameFromUrl('https://my-app.vercel.app/dashboard');
|
|
351
|
+
assert.equal(name, 'my-app-vercel-app');
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// ── isSaturated ─────────────────────────────────────────────────
|
|
356
|
+
|
|
357
|
+
describe('isSaturated', () => {
|
|
358
|
+
it('returns true for a saturated color', () => {
|
|
359
|
+
assert.equal(isSaturated({ r: 255, g: 0, b: 0 }), true);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('returns false for gray', () => {
|
|
363
|
+
assert.equal(isSaturated({ r: 128, g: 128, b: 128 }), false);
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it('returns false for white', () => {
|
|
367
|
+
assert.equal(isSaturated({ r: 255, g: 255, b: 255 }), false);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('returns false for black', () => {
|
|
371
|
+
assert.equal(isSaturated({ r: 0, g: 0, b: 0 }), false);
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// ── safeName ────────────────────────────────────────────────────
|
|
376
|
+
|
|
377
|
+
describe('safeName', () => {
|
|
378
|
+
it('replaces special characters with hyphens', () => {
|
|
379
|
+
assert.equal(safeName('Hello World!'), 'hello-world');
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('collapses multiple hyphens', () => {
|
|
383
|
+
assert.equal(safeName('a--b---c'), 'a-b-c');
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('trims leading/trailing hyphens', () => {
|
|
387
|
+
assert.equal(safeName('--test--'), 'test');
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// ── remToPx / pxToRem ──────────────────────────────────────────
|
|
392
|
+
|
|
393
|
+
describe('remToPx', () => {
|
|
394
|
+
it('converts with default base 16', () => {
|
|
395
|
+
assert.equal(remToPx(1), 16);
|
|
396
|
+
assert.equal(remToPx(2), 32);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('converts with custom base', () => {
|
|
400
|
+
assert.equal(remToPx(1, 10), 10);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
describe('pxToRem', () => {
|
|
405
|
+
it('converts with default base 16', () => {
|
|
406
|
+
assert.equal(pxToRem(16), 1);
|
|
407
|
+
assert.equal(pxToRem(32), 2);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it('converts with custom base', () => {
|
|
411
|
+
assert.equal(pxToRem(10, 10), 1);
|
|
412
|
+
});
|
|
413
|
+
});
|
package/website/app/globals.css
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
:root {
|
|
2
|
-
--red: #
|
|
2
|
+
--red: #ffffff;
|
|
3
3
|
--black: #0a0a0a;
|
|
4
|
-
--white: #
|
|
5
|
-
--cream: #
|
|
6
|
-
--yellow: #
|
|
4
|
+
--white: #ffffff;
|
|
5
|
+
--cream: #ffffff;
|
|
6
|
+
--yellow: #ffffff;
|
|
7
7
|
--gray: #333;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -47,7 +47,7 @@ a { color: inherit; }
|
|
|
47
47
|
font-family: 'Unbounded', sans-serif;
|
|
48
48
|
font-size: 14vw;
|
|
49
49
|
font-weight: 900;
|
|
50
|
-
color: rgba(255,
|
|
50
|
+
color: rgba(255, 255, 255, 0.03);
|
|
51
51
|
white-space: nowrap;
|
|
52
52
|
pointer-events: none;
|
|
53
53
|
animation: scroll-text 20s linear infinite;
|
|
@@ -216,7 +216,7 @@ section {
|
|
|
216
216
|
font-family: 'Unbounded', sans-serif;
|
|
217
217
|
font-size: 80px;
|
|
218
218
|
font-weight: 900;
|
|
219
|
-
color: rgba(255,
|
|
219
|
+
color: rgba(255, 255, 255, 0.06);
|
|
220
220
|
line-height: 1;
|
|
221
221
|
}
|
|
222
222
|
|
|
@@ -302,13 +302,13 @@ section {
|
|
|
302
302
|
.command-card {
|
|
303
303
|
background: var(--black);
|
|
304
304
|
padding: 32px;
|
|
305
|
-
border: 2px solid rgba(255,
|
|
305
|
+
border: 2px solid rgba(255,255,255,0.3);
|
|
306
306
|
transition: all 0.15s;
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
.command-card:hover {
|
|
310
310
|
border-color: var(--red);
|
|
311
|
-
background: rgba(255,
|
|
311
|
+
background: rgba(255, 255, 255, 0.05);
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
.command-name {
|
|
@@ -668,9 +668,9 @@ footer a:hover {
|
|
|
668
668
|
font-weight: 700;
|
|
669
669
|
}
|
|
670
670
|
|
|
671
|
-
.extractor-a11y-score.good { color: #
|
|
672
|
-
.extractor-a11y-score.ok { color:
|
|
673
|
-
.extractor-a11y-score.bad { color:
|
|
671
|
+
.extractor-a11y-score.good { color: #ffffff; }
|
|
672
|
+
.extractor-a11y-score.ok { color: #aaaaaa; }
|
|
673
|
+
.extractor-a11y-score.bad { color: #666666; }
|
|
674
674
|
|
|
675
675
|
.extractor-a11y-fails {
|
|
676
676
|
font-family: 'JetBrains Mono', monospace;
|