@nxds/core 0.13.0 → 0.14.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/README.md +2 -2
- package/dist/runtime/catalogue.cjs +1195 -898
- package/dist/runtime/catalogue.cjs.map +1 -1
- package/dist/runtime/catalogue.d.cts +28 -18
- package/dist/runtime/catalogue.d.ts +28 -18
- package/dist/runtime/catalogue.js +1195 -898
- package/dist/runtime/catalogue.js.map +1 -1
- package/dist/runtime/index.cjs +142 -412
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +5 -5
- package/dist/runtime/index.d.ts +5 -5
- package/dist/runtime/index.js +139 -412
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/palette.cjs.map +1 -1
- package/dist/runtime/palette.js.map +1 -1
- package/dist/runtime/{surface-ladder-Cqo5DfZW.d.ts → surface-ladder-B8LyPHC_.d.ts} +61 -2
- package/dist/runtime/{surface-ladder-DZQFqJvm.d.cts → surface-ladder-DQ9Yfwie.d.cts} +61 -2
- package/package.json +1 -1
package/dist/runtime/index.js
CHANGED
|
@@ -1889,6 +1889,60 @@ function apcaLc(foreground, background) {
|
|
|
1889
1889
|
);
|
|
1890
1890
|
}
|
|
1891
1891
|
|
|
1892
|
+
// src/lib/token-scales.generated.ts
|
|
1893
|
+
var PRIMITIVE_PALETTE_NAMES = [
|
|
1894
|
+
"green",
|
|
1895
|
+
"emerald",
|
|
1896
|
+
"teal",
|
|
1897
|
+
"cyan",
|
|
1898
|
+
"sky",
|
|
1899
|
+
"indigo",
|
|
1900
|
+
"violet",
|
|
1901
|
+
"purple",
|
|
1902
|
+
"fuchsia",
|
|
1903
|
+
"pink",
|
|
1904
|
+
"slate",
|
|
1905
|
+
"rose",
|
|
1906
|
+
"lime",
|
|
1907
|
+
"yellow",
|
|
1908
|
+
"blue",
|
|
1909
|
+
"gray",
|
|
1910
|
+
"zinc",
|
|
1911
|
+
"neutral",
|
|
1912
|
+
"stone",
|
|
1913
|
+
"red",
|
|
1914
|
+
"orange",
|
|
1915
|
+
"amber"
|
|
1916
|
+
];
|
|
1917
|
+
|
|
1918
|
+
// src/token-source/ui-scale.ts
|
|
1919
|
+
var UI_SCALES = {
|
|
1920
|
+
small: { spacing: 0.9, text: 12 / 14, icon: 14 / 16 },
|
|
1921
|
+
default: { spacing: 1, text: 1, icon: 1 },
|
|
1922
|
+
large: { spacing: 1.1, text: 16 / 14, icon: 18 / 16 },
|
|
1923
|
+
larger: { spacing: 1.25, text: 18 / 14, icon: 20 / 16 }
|
|
1924
|
+
};
|
|
1925
|
+
var NON_DEFAULT_UI_SCALES = Object.keys(UI_SCALES).filter((scale) => scale !== "default");
|
|
1926
|
+
var uiScaleSelector = (scale) => `[data-ui-scale='${scale}']`;
|
|
1927
|
+
var TEXT_SIZES = [12, 13, 14, 15, 16];
|
|
1928
|
+
var DEFAULT_TEXT_SIZE = 14;
|
|
1929
|
+
function textSizeAttr(scale, textSize) {
|
|
1930
|
+
const sizeAttr = `[data-text-size='${textSize}']`;
|
|
1931
|
+
return scale === "default" ? sizeAttr : `${uiScaleSelector(scale)}${sizeAttr}`;
|
|
1932
|
+
}
|
|
1933
|
+
function textSizeSelector(scale, textSize) {
|
|
1934
|
+
if (textSize !== DEFAULT_TEXT_SIZE) return textSizeAttr(scale, textSize);
|
|
1935
|
+
return scale === "default" ? null : uiScaleSelector(scale);
|
|
1936
|
+
}
|
|
1937
|
+
var MIN_TEXT_PX = 8;
|
|
1938
|
+
var textFactor = (scale, textSize) => UI_SCALES[scale].text * (textSize / DEFAULT_TEXT_SIZE);
|
|
1939
|
+
function scaleText(size, scale, textSize = DEFAULT_TEXT_SIZE) {
|
|
1940
|
+
return Math.max(MIN_TEXT_PX, Math.round(size * textFactor(scale, textSize)));
|
|
1941
|
+
}
|
|
1942
|
+
function textSizePx(textSize, scale) {
|
|
1943
|
+
return scaleText(DEFAULT_TEXT_SIZE, scale, textSize);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1892
1946
|
// src/lib/contrast.ts
|
|
1893
1947
|
import { APCAcontrast as APCAcontrast3, sRGBtoY as sRGBtoY3 } from "apca-w3";
|
|
1894
1948
|
import { clampChroma as clampChroma5 } from "culori";
|
|
@@ -2204,361 +2258,6 @@ ${css}
|
|
|
2204
2258
|
`;
|
|
2205
2259
|
}
|
|
2206
2260
|
|
|
2207
|
-
// tokens/primitives/typography/typography-default.json
|
|
2208
|
-
var typography_default_default = {
|
|
2209
|
-
family: {
|
|
2210
|
-
"font-sans": {
|
|
2211
|
-
$value: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
2212
|
-
$type: "fontFamily",
|
|
2213
|
-
$extensions: {
|
|
2214
|
-
"nx-font-source": {
|
|
2215
|
-
type: "system"
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
},
|
|
2219
|
-
"font-heading": {
|
|
2220
|
-
$value: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
2221
|
-
$type: "fontFamily",
|
|
2222
|
-
$extensions: {
|
|
2223
|
-
"nx-font-source": {
|
|
2224
|
-
type: "system"
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
|
-
},
|
|
2228
|
-
"font-serif": {
|
|
2229
|
-
$value: "Georgia",
|
|
2230
|
-
$type: "fontFamily",
|
|
2231
|
-
$extensions: {
|
|
2232
|
-
"nx-font-source": {
|
|
2233
|
-
type: "system"
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
},
|
|
2237
|
-
"font-mono": {
|
|
2238
|
-
$value: "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",
|
|
2239
|
-
$type: "fontFamily",
|
|
2240
|
-
$extensions: {
|
|
2241
|
-
"nx-font-source": {
|
|
2242
|
-
type: "system"
|
|
2243
|
-
}
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
},
|
|
2247
|
-
size: {
|
|
2248
|
-
xxs: {
|
|
2249
|
-
$value: {
|
|
2250
|
-
value: 11,
|
|
2251
|
-
unit: "px"
|
|
2252
|
-
},
|
|
2253
|
-
$type: "dimension"
|
|
2254
|
-
},
|
|
2255
|
-
xs: {
|
|
2256
|
-
$value: {
|
|
2257
|
-
value: 12,
|
|
2258
|
-
unit: "px"
|
|
2259
|
-
},
|
|
2260
|
-
$type: "dimension"
|
|
2261
|
-
},
|
|
2262
|
-
sm: {
|
|
2263
|
-
$value: {
|
|
2264
|
-
value: 14,
|
|
2265
|
-
unit: "px"
|
|
2266
|
-
},
|
|
2267
|
-
$type: "dimension"
|
|
2268
|
-
},
|
|
2269
|
-
base: {
|
|
2270
|
-
$value: {
|
|
2271
|
-
value: 16,
|
|
2272
|
-
unit: "px"
|
|
2273
|
-
},
|
|
2274
|
-
$type: "dimension"
|
|
2275
|
-
},
|
|
2276
|
-
lg: {
|
|
2277
|
-
$value: {
|
|
2278
|
-
value: 18,
|
|
2279
|
-
unit: "px"
|
|
2280
|
-
},
|
|
2281
|
-
$type: "dimension"
|
|
2282
|
-
},
|
|
2283
|
-
xl: {
|
|
2284
|
-
$value: {
|
|
2285
|
-
value: 20,
|
|
2286
|
-
unit: "px"
|
|
2287
|
-
},
|
|
2288
|
-
$type: "dimension"
|
|
2289
|
-
},
|
|
2290
|
-
"2xl": {
|
|
2291
|
-
$value: {
|
|
2292
|
-
value: 24,
|
|
2293
|
-
unit: "px"
|
|
2294
|
-
},
|
|
2295
|
-
$type: "dimension"
|
|
2296
|
-
},
|
|
2297
|
-
"3xl": {
|
|
2298
|
-
$value: {
|
|
2299
|
-
value: 30,
|
|
2300
|
-
unit: "px"
|
|
2301
|
-
},
|
|
2302
|
-
$type: "dimension"
|
|
2303
|
-
},
|
|
2304
|
-
"4xl": {
|
|
2305
|
-
$value: {
|
|
2306
|
-
value: 36,
|
|
2307
|
-
unit: "px"
|
|
2308
|
-
},
|
|
2309
|
-
$type: "dimension"
|
|
2310
|
-
},
|
|
2311
|
-
"5xl": {
|
|
2312
|
-
$value: {
|
|
2313
|
-
value: 48,
|
|
2314
|
-
unit: "px"
|
|
2315
|
-
},
|
|
2316
|
-
$type: "dimension"
|
|
2317
|
-
},
|
|
2318
|
-
"6xl": {
|
|
2319
|
-
$value: {
|
|
2320
|
-
value: 60,
|
|
2321
|
-
unit: "px"
|
|
2322
|
-
},
|
|
2323
|
-
$type: "dimension"
|
|
2324
|
-
},
|
|
2325
|
-
"7xl": {
|
|
2326
|
-
$value: {
|
|
2327
|
-
value: 72,
|
|
2328
|
-
unit: "px"
|
|
2329
|
-
},
|
|
2330
|
-
$type: "dimension"
|
|
2331
|
-
},
|
|
2332
|
-
"8xl": {
|
|
2333
|
-
$value: {
|
|
2334
|
-
value: 96,
|
|
2335
|
-
unit: "px"
|
|
2336
|
-
},
|
|
2337
|
-
$type: "dimension"
|
|
2338
|
-
},
|
|
2339
|
-
"9xl": {
|
|
2340
|
-
$value: {
|
|
2341
|
-
value: 128,
|
|
2342
|
-
unit: "px"
|
|
2343
|
-
},
|
|
2344
|
-
$type: "dimension"
|
|
2345
|
-
},
|
|
2346
|
-
code: {
|
|
2347
|
-
$value: {
|
|
2348
|
-
value: 12,
|
|
2349
|
-
unit: "px"
|
|
2350
|
-
},
|
|
2351
|
-
$type: "dimension"
|
|
2352
|
-
}
|
|
2353
|
-
},
|
|
2354
|
-
weight: {
|
|
2355
|
-
thin: {
|
|
2356
|
-
$value: 100,
|
|
2357
|
-
$type: "fontWeight"
|
|
2358
|
-
},
|
|
2359
|
-
extralight: {
|
|
2360
|
-
$value: 200,
|
|
2361
|
-
$type: "fontWeight"
|
|
2362
|
-
},
|
|
2363
|
-
light: {
|
|
2364
|
-
$value: 300,
|
|
2365
|
-
$type: "fontWeight"
|
|
2366
|
-
},
|
|
2367
|
-
normal: {
|
|
2368
|
-
$value: 400,
|
|
2369
|
-
$type: "fontWeight"
|
|
2370
|
-
},
|
|
2371
|
-
medium: {
|
|
2372
|
-
$value: 500,
|
|
2373
|
-
$type: "fontWeight"
|
|
2374
|
-
},
|
|
2375
|
-
semibold: {
|
|
2376
|
-
$value: 600,
|
|
2377
|
-
$type: "fontWeight"
|
|
2378
|
-
},
|
|
2379
|
-
bold: {
|
|
2380
|
-
$value: 700,
|
|
2381
|
-
$type: "fontWeight"
|
|
2382
|
-
},
|
|
2383
|
-
extrabold: {
|
|
2384
|
-
$value: 800,
|
|
2385
|
-
$type: "fontWeight"
|
|
2386
|
-
},
|
|
2387
|
-
black: {
|
|
2388
|
-
$value: 900,
|
|
2389
|
-
$type: "fontWeight"
|
|
2390
|
-
}
|
|
2391
|
-
},
|
|
2392
|
-
"line-height": {
|
|
2393
|
-
xxs: {
|
|
2394
|
-
$value: {
|
|
2395
|
-
value: 12,
|
|
2396
|
-
unit: "px"
|
|
2397
|
-
},
|
|
2398
|
-
$type: "dimension"
|
|
2399
|
-
},
|
|
2400
|
-
xs: {
|
|
2401
|
-
$value: {
|
|
2402
|
-
value: 16,
|
|
2403
|
-
unit: "px"
|
|
2404
|
-
},
|
|
2405
|
-
$type: "dimension"
|
|
2406
|
-
},
|
|
2407
|
-
sm: {
|
|
2408
|
-
$value: {
|
|
2409
|
-
value: 20,
|
|
2410
|
-
unit: "px"
|
|
2411
|
-
},
|
|
2412
|
-
$type: "dimension"
|
|
2413
|
-
},
|
|
2414
|
-
base: {
|
|
2415
|
-
$value: {
|
|
2416
|
-
value: 24,
|
|
2417
|
-
unit: "px"
|
|
2418
|
-
},
|
|
2419
|
-
$type: "dimension"
|
|
2420
|
-
},
|
|
2421
|
-
lg: {
|
|
2422
|
-
$value: {
|
|
2423
|
-
value: 28,
|
|
2424
|
-
unit: "px"
|
|
2425
|
-
},
|
|
2426
|
-
$type: "dimension"
|
|
2427
|
-
},
|
|
2428
|
-
xl: {
|
|
2429
|
-
$value: {
|
|
2430
|
-
value: 28,
|
|
2431
|
-
unit: "px"
|
|
2432
|
-
},
|
|
2433
|
-
$type: "dimension"
|
|
2434
|
-
},
|
|
2435
|
-
"2xl": {
|
|
2436
|
-
$value: {
|
|
2437
|
-
value: 32,
|
|
2438
|
-
unit: "px"
|
|
2439
|
-
},
|
|
2440
|
-
$type: "dimension"
|
|
2441
|
-
},
|
|
2442
|
-
"3xl": {
|
|
2443
|
-
$value: {
|
|
2444
|
-
value: 36,
|
|
2445
|
-
unit: "px"
|
|
2446
|
-
},
|
|
2447
|
-
$type: "dimension"
|
|
2448
|
-
},
|
|
2449
|
-
"4xl": {
|
|
2450
|
-
$value: {
|
|
2451
|
-
value: 48,
|
|
2452
|
-
unit: "px"
|
|
2453
|
-
},
|
|
2454
|
-
$type: "dimension"
|
|
2455
|
-
},
|
|
2456
|
-
"5xl": {
|
|
2457
|
-
$value: {
|
|
2458
|
-
value: 48,
|
|
2459
|
-
unit: "px"
|
|
2460
|
-
},
|
|
2461
|
-
$type: "dimension"
|
|
2462
|
-
},
|
|
2463
|
-
"6xl": {
|
|
2464
|
-
$value: {
|
|
2465
|
-
value: 60,
|
|
2466
|
-
unit: "px"
|
|
2467
|
-
},
|
|
2468
|
-
$type: "dimension"
|
|
2469
|
-
},
|
|
2470
|
-
"7xl": {
|
|
2471
|
-
$value: {
|
|
2472
|
-
value: 72,
|
|
2473
|
-
unit: "px"
|
|
2474
|
-
},
|
|
2475
|
-
$type: "dimension"
|
|
2476
|
-
},
|
|
2477
|
-
"8xl": {
|
|
2478
|
-
$value: {
|
|
2479
|
-
value: 96,
|
|
2480
|
-
unit: "px"
|
|
2481
|
-
},
|
|
2482
|
-
$type: "dimension"
|
|
2483
|
-
},
|
|
2484
|
-
"9xl": {
|
|
2485
|
-
$value: {
|
|
2486
|
-
value: 128,
|
|
2487
|
-
unit: "px"
|
|
2488
|
-
},
|
|
2489
|
-
$type: "dimension"
|
|
2490
|
-
}
|
|
2491
|
-
},
|
|
2492
|
-
letterspacing: {
|
|
2493
|
-
tighter: {
|
|
2494
|
-
$value: {
|
|
2495
|
-
value: -0.800000011920929,
|
|
2496
|
-
unit: "px"
|
|
2497
|
-
},
|
|
2498
|
-
$type: "dimension"
|
|
2499
|
-
},
|
|
2500
|
-
tight: {
|
|
2501
|
-
$value: {
|
|
2502
|
-
value: -0.4000000059604645,
|
|
2503
|
-
unit: "px"
|
|
2504
|
-
},
|
|
2505
|
-
$type: "dimension"
|
|
2506
|
-
},
|
|
2507
|
-
normal: {
|
|
2508
|
-
$value: {
|
|
2509
|
-
value: 0,
|
|
2510
|
-
unit: "px"
|
|
2511
|
-
},
|
|
2512
|
-
$type: "dimension"
|
|
2513
|
-
},
|
|
2514
|
-
wide: {
|
|
2515
|
-
$value: {
|
|
2516
|
-
value: 0.4000000059604645,
|
|
2517
|
-
unit: "px"
|
|
2518
|
-
},
|
|
2519
|
-
$type: "dimension"
|
|
2520
|
-
},
|
|
2521
|
-
wider: {
|
|
2522
|
-
$value: {
|
|
2523
|
-
value: 0.800000011920929,
|
|
2524
|
-
unit: "px"
|
|
2525
|
-
},
|
|
2526
|
-
$type: "dimension"
|
|
2527
|
-
},
|
|
2528
|
-
widest: {
|
|
2529
|
-
$value: {
|
|
2530
|
-
value: 1.600000023841858,
|
|
2531
|
-
unit: "px"
|
|
2532
|
-
},
|
|
2533
|
-
$type: "dimension"
|
|
2534
|
-
}
|
|
2535
|
-
}
|
|
2536
|
-
};
|
|
2537
|
-
|
|
2538
|
-
// src/lib/typography-scale.ts
|
|
2539
|
-
var TYPOGRAPHY_BASE_PX = 14;
|
|
2540
|
-
function formatPx(value) {
|
|
2541
|
-
return `${Number(value.toFixed(4))}px`;
|
|
2542
|
-
}
|
|
2543
|
-
var CODE_SIZE = "code";
|
|
2544
|
-
function typographyScale(uiPx, codePx) {
|
|
2545
|
-
const scale = uiPx / TYPOGRAPHY_BASE_PX;
|
|
2546
|
-
return new Map([
|
|
2547
|
-
...Object.entries(typography_default_default.size).map(
|
|
2548
|
-
([name, token2]) => [
|
|
2549
|
-
`--nx-typography-size-${name}`,
|
|
2550
|
-
formatPx(name === CODE_SIZE ? codePx : token2.$value.value * scale)
|
|
2551
|
-
]
|
|
2552
|
-
),
|
|
2553
|
-
...Object.entries(typography_default_default["line-height"]).map(
|
|
2554
|
-
([name, token2]) => [
|
|
2555
|
-
`--nx-typography-line-height-${name}`,
|
|
2556
|
-
formatPx(token2.$value.value * scale)
|
|
2557
|
-
]
|
|
2558
|
-
)
|
|
2559
|
-
]);
|
|
2560
|
-
}
|
|
2561
|
-
|
|
2562
2261
|
// src/lib/appearance-model.ts
|
|
2563
2262
|
var DEFAULT_BRAND_COLOR = "#0a0a0a";
|
|
2564
2263
|
var BASE_TONE_OPTIONS = [
|
|
@@ -2590,6 +2289,13 @@ var BASE_TONE_SEEDS = {
|
|
|
2590
2289
|
dark: { background: "#111827", foreground: "#f9fafb" }
|
|
2591
2290
|
}
|
|
2592
2291
|
};
|
|
2292
|
+
var UI_SCALE_OPTIONS = [
|
|
2293
|
+
{ value: "small", label: "Small" },
|
|
2294
|
+
{ value: "default", label: "Default" },
|
|
2295
|
+
{ value: "large", label: "Large" },
|
|
2296
|
+
{ value: "larger", label: "Larger" }
|
|
2297
|
+
];
|
|
2298
|
+
var TEXT_SIZE_OPTIONS = TEXT_SIZES.map((value) => ({ value, label: `${value}px` }));
|
|
2593
2299
|
var DENSITY_OPTIONS = [
|
|
2594
2300
|
{ value: "tight", label: "Tight" },
|
|
2595
2301
|
{ value: "compact", label: "Compact" },
|
|
@@ -2623,6 +2329,8 @@ var DEFAULT_NXDS_APPEARANCE = {
|
|
|
2623
2329
|
surfaceTone: "zinc",
|
|
2624
2330
|
lightContrast: 50,
|
|
2625
2331
|
darkContrast: 50,
|
|
2332
|
+
uiScale: "default",
|
|
2333
|
+
textSize: 14,
|
|
2626
2334
|
density: "default",
|
|
2627
2335
|
corners: "subtle",
|
|
2628
2336
|
elevation: "quiet",
|
|
@@ -2631,14 +2339,13 @@ var DEFAULT_NXDS_APPEARANCE = {
|
|
|
2631
2339
|
uiFont: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
2632
2340
|
headingFont: null,
|
|
2633
2341
|
codeFont: 'ui-monospace, "SF Mono", Menlo, monospace',
|
|
2634
|
-
uiFontSize: TYPOGRAPHY_BASE_PX,
|
|
2635
2342
|
codeFontSize: 12,
|
|
2636
2343
|
reduceMotion: false,
|
|
2637
2344
|
pointerCursors: false,
|
|
2638
2345
|
fontSmoothing: false
|
|
2639
2346
|
}
|
|
2640
2347
|
};
|
|
2641
|
-
var FONT_SIZE_PX_MIN =
|
|
2348
|
+
var FONT_SIZE_PX_MIN = MIN_TEXT_PX;
|
|
2642
2349
|
var FONT_SIZE_PX_MAX = 32;
|
|
2643
2350
|
var APPEARANCE_MODES = /* @__PURE__ */ new Set([
|
|
2644
2351
|
"light",
|
|
@@ -2648,6 +2355,10 @@ var APPEARANCE_MODES = /* @__PURE__ */ new Set([
|
|
|
2648
2355
|
var SURFACE_TONES = new Set(
|
|
2649
2356
|
BASE_TONE_OPTIONS.map((option) => option.value)
|
|
2650
2357
|
);
|
|
2358
|
+
var SCALES = new Set(
|
|
2359
|
+
UI_SCALE_OPTIONS.map((option) => option.value)
|
|
2360
|
+
);
|
|
2361
|
+
var TEXT_SIZE_VALUES = new Set(TEXT_SIZES);
|
|
2651
2362
|
var DENSITIES = new Set(
|
|
2652
2363
|
DENSITY_OPTIONS.map((option) => option.value)
|
|
2653
2364
|
);
|
|
@@ -2664,11 +2375,8 @@ var isRecord = (value) => typeof value === "object" && value !== null;
|
|
|
2664
2375
|
var FONT_FAMILY_UNSAFE = /[;{}<]/;
|
|
2665
2376
|
var fontFamilyOr = (value, fallback) => typeof value === "string" && value.length > 0 && !FONT_FAMILY_UNSAFE.test(value) ? value : fallback;
|
|
2666
2377
|
var boolOr = (value, fallback) => typeof value === "boolean" ? value : fallback;
|
|
2667
|
-
var enumOr = (value, values, fallback) =>
|
|
2378
|
+
var enumOr = (value, values, fallback) => values.has(value) ? value : fallback;
|
|
2668
2379
|
var clampFontSize = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.min(FONT_SIZE_PX_MAX, Math.max(FONT_SIZE_PX_MIN, value)) : fallback;
|
|
2669
|
-
function typographyScaleVariables(uiPx, codePx) {
|
|
2670
|
-
return [...typographyScale(uiPx, codePx)].map(([name, value]) => ` ${name}: ${value};`).join("\n");
|
|
2671
|
-
}
|
|
2672
2380
|
var PUBLIC_MODE_RENAME = {
|
|
2673
2381
|
density: {
|
|
2674
2382
|
nova: "compact",
|
|
@@ -2708,7 +2416,6 @@ function sanitizeNxdsAppearancePrefs(raw) {
|
|
|
2708
2416
|
uiFont: fontFamilyOr(o.uiFont, d.uiFont),
|
|
2709
2417
|
headingFont: fontFamilyOr(o.headingFont, d.headingFont),
|
|
2710
2418
|
codeFont: fontFamilyOr(o.codeFont, d.codeFont),
|
|
2711
|
-
uiFontSize: clampFontSize(o.uiFontSize, d.uiFontSize),
|
|
2712
2419
|
codeFontSize: clampFontSize(o.codeFontSize, d.codeFontSize),
|
|
2713
2420
|
reduceMotion: boolOr(o.reduceMotion, d.reduceMotion),
|
|
2714
2421
|
pointerCursors: boolOr(o.pointerCursors, d.pointerCursors),
|
|
@@ -2725,6 +2432,8 @@ function sanitizeNxdsAppearance(rawInput) {
|
|
|
2725
2432
|
surfaceTone: enumOr(raw.surfaceTone, SURFACE_TONES, d.surfaceTone),
|
|
2726
2433
|
lightContrast: normalizeContrast(raw.lightContrast, d.lightContrast),
|
|
2727
2434
|
darkContrast: normalizeContrast(raw.darkContrast, d.darkContrast),
|
|
2435
|
+
uiScale: enumOr(raw.uiScale, SCALES, d.uiScale),
|
|
2436
|
+
textSize: enumOr(raw.textSize, TEXT_SIZE_VALUES, d.textSize),
|
|
2728
2437
|
density: enumOr(raw.density, DENSITIES, d.density),
|
|
2729
2438
|
corners: enumOr(raw.corners, CORNERS, d.corners),
|
|
2730
2439
|
elevation: enumOr(raw.elevation, ELEVATIONS, d.elevation),
|
|
@@ -2741,11 +2450,19 @@ function createNxdsThemeContract(state) {
|
|
|
2741
2450
|
dark: { accent: state.brandColor, ...tone.dark }
|
|
2742
2451
|
};
|
|
2743
2452
|
}
|
|
2453
|
+
function scaledCodeSizes(codePx) {
|
|
2454
|
+
return UI_SCALE_OPTIONS.flatMap(
|
|
2455
|
+
({ value: scale }) => TEXT_SIZES.flatMap((textSize) => {
|
|
2456
|
+
const selector = textSizeSelector(scale, textSize);
|
|
2457
|
+
if (selector === null) return [];
|
|
2458
|
+
const px = scaleText(codePx, scale, textSize);
|
|
2459
|
+
return [`${selector} {
|
|
2460
|
+
--nx-typography-code-size: ${px}px;
|
|
2461
|
+
}`];
|
|
2462
|
+
})
|
|
2463
|
+
).join("\n");
|
|
2464
|
+
}
|
|
2744
2465
|
function appearancePrefsToCss(prefs) {
|
|
2745
|
-
const uiPx = clampFontSize(
|
|
2746
|
-
prefs.uiFontSize,
|
|
2747
|
-
DEFAULT_NXDS_APPEARANCE.prefs.uiFontSize
|
|
2748
|
-
);
|
|
2749
2466
|
const codePx = clampFontSize(
|
|
2750
2467
|
prefs.codeFontSize,
|
|
2751
2468
|
DEFAULT_NXDS_APPEARANCE.prefs.codeFontSize
|
|
@@ -2755,8 +2472,9 @@ function appearancePrefsToCss(prefs) {
|
|
|
2755
2472
|
--nx-typography-family-font-sans: ${prefs.uiFont};
|
|
2756
2473
|
--nx-typography-family-font-heading: ${prefs.headingFont ?? "var(--nx-typography-family-font-sans)"};
|
|
2757
2474
|
--nx-typography-family-font-mono: ${prefs.codeFont};
|
|
2758
|
-
${
|
|
2759
|
-
}
|
|
2475
|
+
--nx-typography-code-size: ${scaleText(codePx, "default")}px;
|
|
2476
|
+
}
|
|
2477
|
+
${scaledCodeSizes(codePx)}`)
|
|
2760
2478
|
];
|
|
2761
2479
|
if (prefs.fontSmoothing) {
|
|
2762
2480
|
blocks.push(
|
|
@@ -4155,32 +3873,6 @@ var color_default2 = {
|
|
|
4155
3873
|
}
|
|
4156
3874
|
};
|
|
4157
3875
|
|
|
4158
|
-
// src/lib/token-scales.generated.ts
|
|
4159
|
-
var PRIMITIVE_PALETTE_NAMES = [
|
|
4160
|
-
"green",
|
|
4161
|
-
"emerald",
|
|
4162
|
-
"teal",
|
|
4163
|
-
"cyan",
|
|
4164
|
-
"sky",
|
|
4165
|
-
"indigo",
|
|
4166
|
-
"violet",
|
|
4167
|
-
"purple",
|
|
4168
|
-
"fuchsia",
|
|
4169
|
-
"pink",
|
|
4170
|
-
"slate",
|
|
4171
|
-
"rose",
|
|
4172
|
-
"lime",
|
|
4173
|
-
"yellow",
|
|
4174
|
-
"blue",
|
|
4175
|
-
"gray",
|
|
4176
|
-
"zinc",
|
|
4177
|
-
"neutral",
|
|
4178
|
-
"stone",
|
|
4179
|
-
"red",
|
|
4180
|
-
"orange",
|
|
4181
|
-
"amber"
|
|
4182
|
-
];
|
|
4183
|
-
|
|
4184
3876
|
// src/lib/primitive-palette.ts
|
|
4185
3877
|
var rampCache = /* @__PURE__ */ new Map();
|
|
4186
3878
|
function getPaletteRamp(palette) {
|
|
@@ -4596,10 +4288,12 @@ ${block(":root.dark", derived.dark)}`
|
|
|
4596
4288
|
}
|
|
4597
4289
|
|
|
4598
4290
|
// src/lib/appearance-snapshot.ts
|
|
4599
|
-
var SNAPSHOT_VERSION =
|
|
4291
|
+
var SNAPSHOT_VERSION = 11;
|
|
4600
4292
|
var STATE_COOKIE_VERSION = 6;
|
|
4601
4293
|
var SNAPSHOT_CACHE_LIMIT = 50;
|
|
4602
4294
|
var NXDS_APPEARANCE_DATA_ATTRS = [
|
|
4295
|
+
"data-ui-scale",
|
|
4296
|
+
"data-text-size",
|
|
4603
4297
|
"data-density",
|
|
4604
4298
|
"data-radius",
|
|
4605
4299
|
"data-shadow",
|
|
@@ -4714,6 +4408,8 @@ function resolveFirstPaint(snapshot, systemPrefersDark) {
|
|
|
4714
4408
|
return {
|
|
4715
4409
|
className: dark ? "dark" : "",
|
|
4716
4410
|
dataAttrs: {
|
|
4411
|
+
"data-ui-scale": state.uiScale,
|
|
4412
|
+
"data-text-size": String(state.textSize),
|
|
4717
4413
|
"data-density": state.density,
|
|
4718
4414
|
"data-radius": state.corners,
|
|
4719
4415
|
"data-shadow": state.elevation,
|
|
@@ -4729,7 +4425,7 @@ function escapeInlineScriptJson(value) {
|
|
|
4729
4425
|
function createNxdsAppearanceBootstrapScript(options = {}) {
|
|
4730
4426
|
const storageKey = options.storageKey ?? DEFAULT_STORAGE_KEY;
|
|
4731
4427
|
const defaultSnapshot = options.defaultSnapshot ? sanitizeNxdsAppearanceSnapshot(options.defaultSnapshot) : createDefaultNxdsAppearanceSnapshot();
|
|
4732
|
-
return `(function(){try{var k=${escapeInlineScriptJson(storageKey)};var f=${escapeInlineScriptJson(defaultSnapshot)};var s=f;try{if(k!==false){var r=window.localStorage&&window.localStorage.getItem(k);if(r){var p=JSON.parse(r);if(p&&p.version===f.version&&p.state&&typeof p.themeCss==="string"&&typeof p.prefsCss==="string"){s=p;}}}}catch(e){}var st=s.state||f.state;var m=st.mode==="dark"||st.mode==="light"||st.mode==="system"?st.mode:f.state.mode;var sys=false;try{sys=m==="system"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;}catch(e){}var dark=m==="dark"||sys===true;var root=document.documentElement;root.classList.toggle("dark",dark);root.setAttribute("data-density",typeof st.density==="string"?st.density:f.state.density);root.setAttribute("data-radius",typeof st.corners==="string"?st.corners:f.state.corners);root.setAttribute("data-shadow",typeof st.elevation==="string"?st.elevation:f.state.elevation);root.setAttribute("data-borderwidth",typeof st.stroke==="string"?st.stroke:f.state.stroke);function upsert(attr,css){var list=document.querySelectorAll("style["+attr+"]");var el=list[0]||document.createElement("style");for(var i=1;i<list.length;i++){list[i].remove();}el.setAttribute(attr,"");el.textContent=css||"";if(!el.parentNode){document.head.appendChild(el);}}upsert("data-nxds-appearance-theme",s.themeCss);upsert("data-nxds-appearance-prefs",s.prefsCss);}catch(e){}})();`;
|
|
4428
|
+
return `(function(){try{var k=${escapeInlineScriptJson(storageKey)};var f=${escapeInlineScriptJson(defaultSnapshot)};var s=f;try{if(k!==false){var r=window.localStorage&&window.localStorage.getItem(k);if(r){var p=JSON.parse(r);if(p&&p.version===f.version&&p.state&&typeof p.themeCss==="string"&&typeof p.prefsCss==="string"){s=p;}}}}catch(e){}var st=s.state||f.state;var m=st.mode==="dark"||st.mode==="light"||st.mode==="system"?st.mode:f.state.mode;var sys=false;try{sys=m==="system"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;}catch(e){}var dark=m==="dark"||sys===true;var root=document.documentElement;root.classList.toggle("dark",dark);root.setAttribute("data-ui-scale",typeof st.uiScale==="string"?st.uiScale:f.state.uiScale);root.setAttribute("data-text-size",String(typeof st.textSize==="number"?st.textSize:f.state.textSize));root.setAttribute("data-density",typeof st.density==="string"?st.density:f.state.density);root.setAttribute("data-radius",typeof st.corners==="string"?st.corners:f.state.corners);root.setAttribute("data-shadow",typeof st.elevation==="string"?st.elevation:f.state.elevation);root.setAttribute("data-borderwidth",typeof st.stroke==="string"?st.stroke:f.state.stroke);function upsert(attr,css){var list=document.querySelectorAll("style["+attr+"]");var el=list[0]||document.createElement("style");for(var i=1;i<list.length;i++){list[i].remove();}el.setAttribute(attr,"");el.textContent=css||"";if(!el.parentNode){document.head.appendChild(el);}}upsert("data-nxds-appearance-theme",s.themeCss);upsert("data-nxds-appearance-prefs",s.prefsCss);}catch(e){}})();`;
|
|
4733
4429
|
}
|
|
4734
4430
|
|
|
4735
4431
|
// src/lib/appearance-dom.ts
|
|
@@ -5056,20 +4752,6 @@ function contrastField(flag, key, description) {
|
|
|
5056
4752
|
})
|
|
5057
4753
|
};
|
|
5058
4754
|
}
|
|
5059
|
-
function fontSizeField(flag, key, description) {
|
|
5060
|
-
return {
|
|
5061
|
-
kind: "integer",
|
|
5062
|
-
flag,
|
|
5063
|
-
key: `prefs.${key}`,
|
|
5064
|
-
description,
|
|
5065
|
-
min: FONT_SIZE_PX_MIN,
|
|
5066
|
-
max: FONT_SIZE_PX_MAX,
|
|
5067
|
-
read: (theme) => String(theme.appearance.prefs[key]),
|
|
5068
|
-
write: (theme, value) => withPrefs(theme, {
|
|
5069
|
-
[key]: integer(flag, value, FONT_SIZE_PX_MIN, FONT_SIZE_PX_MAX)
|
|
5070
|
-
})
|
|
5071
|
-
};
|
|
5072
|
-
}
|
|
5073
4755
|
function fontField(flag, key, description, categories, fallback) {
|
|
5074
4756
|
const fonts = FONT_OPTIONS.filter(
|
|
5075
4757
|
(font) => categories.includes(font.category)
|
|
@@ -5100,6 +4782,9 @@ function fontField(flag, key, description, categories, fallback) {
|
|
|
5100
4782
|
}
|
|
5101
4783
|
};
|
|
5102
4784
|
}
|
|
4785
|
+
var TEXT_SIZES2 = TEXT_SIZE_OPTIONS.map((option) => option.value);
|
|
4786
|
+
var TEXT_SIZE_MIN = Math.min(...TEXT_SIZES2);
|
|
4787
|
+
var TEXT_SIZE_MAX = Math.max(...TEXT_SIZES2);
|
|
5103
4788
|
var DEFAULT_PREFS = DEFAULT_NXDS_APPEARANCE.prefs;
|
|
5104
4789
|
var TEXT_FONTS = ["sans", "serif"];
|
|
5105
4790
|
var NXDS_THEME_FIELDS = [
|
|
@@ -5120,6 +4805,30 @@ var NXDS_THEME_FIELDS = [
|
|
|
5120
4805
|
"neutral tone of backgrounds and borders",
|
|
5121
4806
|
BASE_TONE_OPTIONS.map((option) => option.value)
|
|
5122
4807
|
),
|
|
4808
|
+
enumField(
|
|
4809
|
+
"ui-scale",
|
|
4810
|
+
"uiScale",
|
|
4811
|
+
"size of text, icons and spacing together",
|
|
4812
|
+
UI_SCALE_OPTIONS.map((option) => option.value)
|
|
4813
|
+
),
|
|
4814
|
+
{
|
|
4815
|
+
kind: "integer",
|
|
4816
|
+
flag: "text-size",
|
|
4817
|
+
key: "textSize",
|
|
4818
|
+
description: `label text size in px at the default UI scale, ${TEXT_SIZE_MIN} to ${TEXT_SIZE_MAX}`,
|
|
4819
|
+
min: TEXT_SIZE_MIN,
|
|
4820
|
+
max: TEXT_SIZE_MAX,
|
|
4821
|
+
read: (theme) => String(theme.appearance.textSize),
|
|
4822
|
+
write: (theme, value) => withAppearance(theme, {
|
|
4823
|
+
// Every whole number from the minimum to the maximum is a text size.
|
|
4824
|
+
textSize: integer(
|
|
4825
|
+
"text-size",
|
|
4826
|
+
value,
|
|
4827
|
+
TEXT_SIZE_MIN,
|
|
4828
|
+
TEXT_SIZE_MAX
|
|
4829
|
+
)
|
|
4830
|
+
})
|
|
4831
|
+
},
|
|
5123
4832
|
enumField(
|
|
5124
4833
|
"density",
|
|
5125
4834
|
"density",
|
|
@@ -5170,8 +4879,23 @@ var NXDS_THEME_FIELDS = [
|
|
|
5170
4879
|
value: "system",
|
|
5171
4880
|
family: DEFAULT_PREFS.codeFont
|
|
5172
4881
|
}),
|
|
5173
|
-
|
|
5174
|
-
|
|
4882
|
+
{
|
|
4883
|
+
kind: "integer",
|
|
4884
|
+
flag: "code-font-size",
|
|
4885
|
+
key: "prefs.codeFontSize",
|
|
4886
|
+
description: "code text size in px",
|
|
4887
|
+
min: FONT_SIZE_PX_MIN,
|
|
4888
|
+
max: FONT_SIZE_PX_MAX,
|
|
4889
|
+
read: (theme) => String(theme.appearance.prefs.codeFontSize),
|
|
4890
|
+
write: (theme, value) => withPrefs(theme, {
|
|
4891
|
+
codeFontSize: integer(
|
|
4892
|
+
"code-font-size",
|
|
4893
|
+
value,
|
|
4894
|
+
FONT_SIZE_PX_MIN,
|
|
4895
|
+
FONT_SIZE_PX_MAX
|
|
4896
|
+
)
|
|
4897
|
+
})
|
|
4898
|
+
},
|
|
5175
4899
|
{
|
|
5176
4900
|
kind: "choice",
|
|
5177
4901
|
flag: "icons",
|
|
@@ -5371,7 +5095,9 @@ export {
|
|
|
5371
5095
|
SEMANTIC_TOKEN_REGISTRY,
|
|
5372
5096
|
SNAPSHOT_VERSION,
|
|
5373
5097
|
STROKE_OPTIONS,
|
|
5098
|
+
TEXT_SIZE_OPTIONS,
|
|
5374
5099
|
TIER_THRESHOLDS,
|
|
5100
|
+
UI_SCALE_OPTIONS,
|
|
5375
5101
|
adjustContrast,
|
|
5376
5102
|
apcaLc,
|
|
5377
5103
|
appearancePrefsToCss,
|
|
@@ -5403,6 +5129,7 @@ export {
|
|
|
5403
5129
|
serializeNxdsAppearanceStateCookie,
|
|
5404
5130
|
shuffleNxdsAppearance,
|
|
5405
5131
|
shuffleNxdsIconLibrary,
|
|
5132
|
+
textSizePx,
|
|
5406
5133
|
themeToCss,
|
|
5407
5134
|
watchColorScheme
|
|
5408
5135
|
};
|