@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.cjs
CHANGED
|
@@ -44,7 +44,9 @@ __export(src_exports, {
|
|
|
44
44
|
SEMANTIC_TOKEN_REGISTRY: () => SEMANTIC_TOKEN_REGISTRY,
|
|
45
45
|
SNAPSHOT_VERSION: () => SNAPSHOT_VERSION,
|
|
46
46
|
STROKE_OPTIONS: () => STROKE_OPTIONS,
|
|
47
|
+
TEXT_SIZE_OPTIONS: () => TEXT_SIZE_OPTIONS,
|
|
47
48
|
TIER_THRESHOLDS: () => TIER_THRESHOLDS,
|
|
49
|
+
UI_SCALE_OPTIONS: () => UI_SCALE_OPTIONS,
|
|
48
50
|
adjustContrast: () => adjustContrast,
|
|
49
51
|
apcaLc: () => apcaLc,
|
|
50
52
|
appearancePrefsToCss: () => appearancePrefsToCss,
|
|
@@ -76,6 +78,7 @@ __export(src_exports, {
|
|
|
76
78
|
serializeNxdsAppearanceStateCookie: () => serializeNxdsAppearanceStateCookie,
|
|
77
79
|
shuffleNxdsAppearance: () => shuffleNxdsAppearance,
|
|
78
80
|
shuffleNxdsIconLibrary: () => shuffleNxdsIconLibrary,
|
|
81
|
+
textSizePx: () => textSizePx,
|
|
79
82
|
themeToCss: () => themeToCss,
|
|
80
83
|
watchColorScheme: () => watchColorScheme
|
|
81
84
|
});
|
|
@@ -1972,6 +1975,60 @@ function apcaLc(foreground, background) {
|
|
|
1972
1975
|
);
|
|
1973
1976
|
}
|
|
1974
1977
|
|
|
1978
|
+
// src/lib/token-scales.generated.ts
|
|
1979
|
+
var PRIMITIVE_PALETTE_NAMES = [
|
|
1980
|
+
"green",
|
|
1981
|
+
"emerald",
|
|
1982
|
+
"teal",
|
|
1983
|
+
"cyan",
|
|
1984
|
+
"sky",
|
|
1985
|
+
"indigo",
|
|
1986
|
+
"violet",
|
|
1987
|
+
"purple",
|
|
1988
|
+
"fuchsia",
|
|
1989
|
+
"pink",
|
|
1990
|
+
"slate",
|
|
1991
|
+
"rose",
|
|
1992
|
+
"lime",
|
|
1993
|
+
"yellow",
|
|
1994
|
+
"blue",
|
|
1995
|
+
"gray",
|
|
1996
|
+
"zinc",
|
|
1997
|
+
"neutral",
|
|
1998
|
+
"stone",
|
|
1999
|
+
"red",
|
|
2000
|
+
"orange",
|
|
2001
|
+
"amber"
|
|
2002
|
+
];
|
|
2003
|
+
|
|
2004
|
+
// src/token-source/ui-scale.ts
|
|
2005
|
+
var UI_SCALES = {
|
|
2006
|
+
small: { spacing: 0.9, text: 12 / 14, icon: 14 / 16 },
|
|
2007
|
+
default: { spacing: 1, text: 1, icon: 1 },
|
|
2008
|
+
large: { spacing: 1.1, text: 16 / 14, icon: 18 / 16 },
|
|
2009
|
+
larger: { spacing: 1.25, text: 18 / 14, icon: 20 / 16 }
|
|
2010
|
+
};
|
|
2011
|
+
var NON_DEFAULT_UI_SCALES = Object.keys(UI_SCALES).filter((scale) => scale !== "default");
|
|
2012
|
+
var uiScaleSelector = (scale) => `[data-ui-scale='${scale}']`;
|
|
2013
|
+
var TEXT_SIZES = [12, 13, 14, 15, 16];
|
|
2014
|
+
var DEFAULT_TEXT_SIZE = 14;
|
|
2015
|
+
function textSizeAttr(scale, textSize) {
|
|
2016
|
+
const sizeAttr = `[data-text-size='${textSize}']`;
|
|
2017
|
+
return scale === "default" ? sizeAttr : `${uiScaleSelector(scale)}${sizeAttr}`;
|
|
2018
|
+
}
|
|
2019
|
+
function textSizeSelector(scale, textSize) {
|
|
2020
|
+
if (textSize !== DEFAULT_TEXT_SIZE) return textSizeAttr(scale, textSize);
|
|
2021
|
+
return scale === "default" ? null : uiScaleSelector(scale);
|
|
2022
|
+
}
|
|
2023
|
+
var MIN_TEXT_PX = 8;
|
|
2024
|
+
var textFactor = (scale, textSize) => UI_SCALES[scale].text * (textSize / DEFAULT_TEXT_SIZE);
|
|
2025
|
+
function scaleText(size, scale, textSize = DEFAULT_TEXT_SIZE) {
|
|
2026
|
+
return Math.max(MIN_TEXT_PX, Math.round(size * textFactor(scale, textSize)));
|
|
2027
|
+
}
|
|
2028
|
+
function textSizePx(textSize, scale) {
|
|
2029
|
+
return scaleText(DEFAULT_TEXT_SIZE, scale, textSize);
|
|
2030
|
+
}
|
|
2031
|
+
|
|
1975
2032
|
// src/lib/contrast.ts
|
|
1976
2033
|
var import_apca_w33 = require("apca-w3");
|
|
1977
2034
|
var import_culori6 = require("culori");
|
|
@@ -2287,361 +2344,6 @@ ${css}
|
|
|
2287
2344
|
`;
|
|
2288
2345
|
}
|
|
2289
2346
|
|
|
2290
|
-
// tokens/primitives/typography/typography-default.json
|
|
2291
|
-
var typography_default_default = {
|
|
2292
|
-
family: {
|
|
2293
|
-
"font-sans": {
|
|
2294
|
-
$value: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
2295
|
-
$type: "fontFamily",
|
|
2296
|
-
$extensions: {
|
|
2297
|
-
"nx-font-source": {
|
|
2298
|
-
type: "system"
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
},
|
|
2302
|
-
"font-heading": {
|
|
2303
|
-
$value: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif",
|
|
2304
|
-
$type: "fontFamily",
|
|
2305
|
-
$extensions: {
|
|
2306
|
-
"nx-font-source": {
|
|
2307
|
-
type: "system"
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
},
|
|
2311
|
-
"font-serif": {
|
|
2312
|
-
$value: "Georgia",
|
|
2313
|
-
$type: "fontFamily",
|
|
2314
|
-
$extensions: {
|
|
2315
|
-
"nx-font-source": {
|
|
2316
|
-
type: "system"
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
},
|
|
2320
|
-
"font-mono": {
|
|
2321
|
-
$value: "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",
|
|
2322
|
-
$type: "fontFamily",
|
|
2323
|
-
$extensions: {
|
|
2324
|
-
"nx-font-source": {
|
|
2325
|
-
type: "system"
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
},
|
|
2330
|
-
size: {
|
|
2331
|
-
xxs: {
|
|
2332
|
-
$value: {
|
|
2333
|
-
value: 11,
|
|
2334
|
-
unit: "px"
|
|
2335
|
-
},
|
|
2336
|
-
$type: "dimension"
|
|
2337
|
-
},
|
|
2338
|
-
xs: {
|
|
2339
|
-
$value: {
|
|
2340
|
-
value: 12,
|
|
2341
|
-
unit: "px"
|
|
2342
|
-
},
|
|
2343
|
-
$type: "dimension"
|
|
2344
|
-
},
|
|
2345
|
-
sm: {
|
|
2346
|
-
$value: {
|
|
2347
|
-
value: 14,
|
|
2348
|
-
unit: "px"
|
|
2349
|
-
},
|
|
2350
|
-
$type: "dimension"
|
|
2351
|
-
},
|
|
2352
|
-
base: {
|
|
2353
|
-
$value: {
|
|
2354
|
-
value: 16,
|
|
2355
|
-
unit: "px"
|
|
2356
|
-
},
|
|
2357
|
-
$type: "dimension"
|
|
2358
|
-
},
|
|
2359
|
-
lg: {
|
|
2360
|
-
$value: {
|
|
2361
|
-
value: 18,
|
|
2362
|
-
unit: "px"
|
|
2363
|
-
},
|
|
2364
|
-
$type: "dimension"
|
|
2365
|
-
},
|
|
2366
|
-
xl: {
|
|
2367
|
-
$value: {
|
|
2368
|
-
value: 20,
|
|
2369
|
-
unit: "px"
|
|
2370
|
-
},
|
|
2371
|
-
$type: "dimension"
|
|
2372
|
-
},
|
|
2373
|
-
"2xl": {
|
|
2374
|
-
$value: {
|
|
2375
|
-
value: 24,
|
|
2376
|
-
unit: "px"
|
|
2377
|
-
},
|
|
2378
|
-
$type: "dimension"
|
|
2379
|
-
},
|
|
2380
|
-
"3xl": {
|
|
2381
|
-
$value: {
|
|
2382
|
-
value: 30,
|
|
2383
|
-
unit: "px"
|
|
2384
|
-
},
|
|
2385
|
-
$type: "dimension"
|
|
2386
|
-
},
|
|
2387
|
-
"4xl": {
|
|
2388
|
-
$value: {
|
|
2389
|
-
value: 36,
|
|
2390
|
-
unit: "px"
|
|
2391
|
-
},
|
|
2392
|
-
$type: "dimension"
|
|
2393
|
-
},
|
|
2394
|
-
"5xl": {
|
|
2395
|
-
$value: {
|
|
2396
|
-
value: 48,
|
|
2397
|
-
unit: "px"
|
|
2398
|
-
},
|
|
2399
|
-
$type: "dimension"
|
|
2400
|
-
},
|
|
2401
|
-
"6xl": {
|
|
2402
|
-
$value: {
|
|
2403
|
-
value: 60,
|
|
2404
|
-
unit: "px"
|
|
2405
|
-
},
|
|
2406
|
-
$type: "dimension"
|
|
2407
|
-
},
|
|
2408
|
-
"7xl": {
|
|
2409
|
-
$value: {
|
|
2410
|
-
value: 72,
|
|
2411
|
-
unit: "px"
|
|
2412
|
-
},
|
|
2413
|
-
$type: "dimension"
|
|
2414
|
-
},
|
|
2415
|
-
"8xl": {
|
|
2416
|
-
$value: {
|
|
2417
|
-
value: 96,
|
|
2418
|
-
unit: "px"
|
|
2419
|
-
},
|
|
2420
|
-
$type: "dimension"
|
|
2421
|
-
},
|
|
2422
|
-
"9xl": {
|
|
2423
|
-
$value: {
|
|
2424
|
-
value: 128,
|
|
2425
|
-
unit: "px"
|
|
2426
|
-
},
|
|
2427
|
-
$type: "dimension"
|
|
2428
|
-
},
|
|
2429
|
-
code: {
|
|
2430
|
-
$value: {
|
|
2431
|
-
value: 12,
|
|
2432
|
-
unit: "px"
|
|
2433
|
-
},
|
|
2434
|
-
$type: "dimension"
|
|
2435
|
-
}
|
|
2436
|
-
},
|
|
2437
|
-
weight: {
|
|
2438
|
-
thin: {
|
|
2439
|
-
$value: 100,
|
|
2440
|
-
$type: "fontWeight"
|
|
2441
|
-
},
|
|
2442
|
-
extralight: {
|
|
2443
|
-
$value: 200,
|
|
2444
|
-
$type: "fontWeight"
|
|
2445
|
-
},
|
|
2446
|
-
light: {
|
|
2447
|
-
$value: 300,
|
|
2448
|
-
$type: "fontWeight"
|
|
2449
|
-
},
|
|
2450
|
-
normal: {
|
|
2451
|
-
$value: 400,
|
|
2452
|
-
$type: "fontWeight"
|
|
2453
|
-
},
|
|
2454
|
-
medium: {
|
|
2455
|
-
$value: 500,
|
|
2456
|
-
$type: "fontWeight"
|
|
2457
|
-
},
|
|
2458
|
-
semibold: {
|
|
2459
|
-
$value: 600,
|
|
2460
|
-
$type: "fontWeight"
|
|
2461
|
-
},
|
|
2462
|
-
bold: {
|
|
2463
|
-
$value: 700,
|
|
2464
|
-
$type: "fontWeight"
|
|
2465
|
-
},
|
|
2466
|
-
extrabold: {
|
|
2467
|
-
$value: 800,
|
|
2468
|
-
$type: "fontWeight"
|
|
2469
|
-
},
|
|
2470
|
-
black: {
|
|
2471
|
-
$value: 900,
|
|
2472
|
-
$type: "fontWeight"
|
|
2473
|
-
}
|
|
2474
|
-
},
|
|
2475
|
-
"line-height": {
|
|
2476
|
-
xxs: {
|
|
2477
|
-
$value: {
|
|
2478
|
-
value: 12,
|
|
2479
|
-
unit: "px"
|
|
2480
|
-
},
|
|
2481
|
-
$type: "dimension"
|
|
2482
|
-
},
|
|
2483
|
-
xs: {
|
|
2484
|
-
$value: {
|
|
2485
|
-
value: 16,
|
|
2486
|
-
unit: "px"
|
|
2487
|
-
},
|
|
2488
|
-
$type: "dimension"
|
|
2489
|
-
},
|
|
2490
|
-
sm: {
|
|
2491
|
-
$value: {
|
|
2492
|
-
value: 20,
|
|
2493
|
-
unit: "px"
|
|
2494
|
-
},
|
|
2495
|
-
$type: "dimension"
|
|
2496
|
-
},
|
|
2497
|
-
base: {
|
|
2498
|
-
$value: {
|
|
2499
|
-
value: 24,
|
|
2500
|
-
unit: "px"
|
|
2501
|
-
},
|
|
2502
|
-
$type: "dimension"
|
|
2503
|
-
},
|
|
2504
|
-
lg: {
|
|
2505
|
-
$value: {
|
|
2506
|
-
value: 28,
|
|
2507
|
-
unit: "px"
|
|
2508
|
-
},
|
|
2509
|
-
$type: "dimension"
|
|
2510
|
-
},
|
|
2511
|
-
xl: {
|
|
2512
|
-
$value: {
|
|
2513
|
-
value: 28,
|
|
2514
|
-
unit: "px"
|
|
2515
|
-
},
|
|
2516
|
-
$type: "dimension"
|
|
2517
|
-
},
|
|
2518
|
-
"2xl": {
|
|
2519
|
-
$value: {
|
|
2520
|
-
value: 32,
|
|
2521
|
-
unit: "px"
|
|
2522
|
-
},
|
|
2523
|
-
$type: "dimension"
|
|
2524
|
-
},
|
|
2525
|
-
"3xl": {
|
|
2526
|
-
$value: {
|
|
2527
|
-
value: 36,
|
|
2528
|
-
unit: "px"
|
|
2529
|
-
},
|
|
2530
|
-
$type: "dimension"
|
|
2531
|
-
},
|
|
2532
|
-
"4xl": {
|
|
2533
|
-
$value: {
|
|
2534
|
-
value: 48,
|
|
2535
|
-
unit: "px"
|
|
2536
|
-
},
|
|
2537
|
-
$type: "dimension"
|
|
2538
|
-
},
|
|
2539
|
-
"5xl": {
|
|
2540
|
-
$value: {
|
|
2541
|
-
value: 48,
|
|
2542
|
-
unit: "px"
|
|
2543
|
-
},
|
|
2544
|
-
$type: "dimension"
|
|
2545
|
-
},
|
|
2546
|
-
"6xl": {
|
|
2547
|
-
$value: {
|
|
2548
|
-
value: 60,
|
|
2549
|
-
unit: "px"
|
|
2550
|
-
},
|
|
2551
|
-
$type: "dimension"
|
|
2552
|
-
},
|
|
2553
|
-
"7xl": {
|
|
2554
|
-
$value: {
|
|
2555
|
-
value: 72,
|
|
2556
|
-
unit: "px"
|
|
2557
|
-
},
|
|
2558
|
-
$type: "dimension"
|
|
2559
|
-
},
|
|
2560
|
-
"8xl": {
|
|
2561
|
-
$value: {
|
|
2562
|
-
value: 96,
|
|
2563
|
-
unit: "px"
|
|
2564
|
-
},
|
|
2565
|
-
$type: "dimension"
|
|
2566
|
-
},
|
|
2567
|
-
"9xl": {
|
|
2568
|
-
$value: {
|
|
2569
|
-
value: 128,
|
|
2570
|
-
unit: "px"
|
|
2571
|
-
},
|
|
2572
|
-
$type: "dimension"
|
|
2573
|
-
}
|
|
2574
|
-
},
|
|
2575
|
-
letterspacing: {
|
|
2576
|
-
tighter: {
|
|
2577
|
-
$value: {
|
|
2578
|
-
value: -0.800000011920929,
|
|
2579
|
-
unit: "px"
|
|
2580
|
-
},
|
|
2581
|
-
$type: "dimension"
|
|
2582
|
-
},
|
|
2583
|
-
tight: {
|
|
2584
|
-
$value: {
|
|
2585
|
-
value: -0.4000000059604645,
|
|
2586
|
-
unit: "px"
|
|
2587
|
-
},
|
|
2588
|
-
$type: "dimension"
|
|
2589
|
-
},
|
|
2590
|
-
normal: {
|
|
2591
|
-
$value: {
|
|
2592
|
-
value: 0,
|
|
2593
|
-
unit: "px"
|
|
2594
|
-
},
|
|
2595
|
-
$type: "dimension"
|
|
2596
|
-
},
|
|
2597
|
-
wide: {
|
|
2598
|
-
$value: {
|
|
2599
|
-
value: 0.4000000059604645,
|
|
2600
|
-
unit: "px"
|
|
2601
|
-
},
|
|
2602
|
-
$type: "dimension"
|
|
2603
|
-
},
|
|
2604
|
-
wider: {
|
|
2605
|
-
$value: {
|
|
2606
|
-
value: 0.800000011920929,
|
|
2607
|
-
unit: "px"
|
|
2608
|
-
},
|
|
2609
|
-
$type: "dimension"
|
|
2610
|
-
},
|
|
2611
|
-
widest: {
|
|
2612
|
-
$value: {
|
|
2613
|
-
value: 1.600000023841858,
|
|
2614
|
-
unit: "px"
|
|
2615
|
-
},
|
|
2616
|
-
$type: "dimension"
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
};
|
|
2620
|
-
|
|
2621
|
-
// src/lib/typography-scale.ts
|
|
2622
|
-
var TYPOGRAPHY_BASE_PX = 14;
|
|
2623
|
-
function formatPx(value) {
|
|
2624
|
-
return `${Number(value.toFixed(4))}px`;
|
|
2625
|
-
}
|
|
2626
|
-
var CODE_SIZE = "code";
|
|
2627
|
-
function typographyScale(uiPx, codePx) {
|
|
2628
|
-
const scale = uiPx / TYPOGRAPHY_BASE_PX;
|
|
2629
|
-
return new Map([
|
|
2630
|
-
...Object.entries(typography_default_default.size).map(
|
|
2631
|
-
([name, token2]) => [
|
|
2632
|
-
`--nx-typography-size-${name}`,
|
|
2633
|
-
formatPx(name === CODE_SIZE ? codePx : token2.$value.value * scale)
|
|
2634
|
-
]
|
|
2635
|
-
),
|
|
2636
|
-
...Object.entries(typography_default_default["line-height"]).map(
|
|
2637
|
-
([name, token2]) => [
|
|
2638
|
-
`--nx-typography-line-height-${name}`,
|
|
2639
|
-
formatPx(token2.$value.value * scale)
|
|
2640
|
-
]
|
|
2641
|
-
)
|
|
2642
|
-
]);
|
|
2643
|
-
}
|
|
2644
|
-
|
|
2645
2347
|
// src/lib/appearance-model.ts
|
|
2646
2348
|
var DEFAULT_BRAND_COLOR = "#0a0a0a";
|
|
2647
2349
|
var BASE_TONE_OPTIONS = [
|
|
@@ -2673,6 +2375,13 @@ var BASE_TONE_SEEDS = {
|
|
|
2673
2375
|
dark: { background: "#111827", foreground: "#f9fafb" }
|
|
2674
2376
|
}
|
|
2675
2377
|
};
|
|
2378
|
+
var UI_SCALE_OPTIONS = [
|
|
2379
|
+
{ value: "small", label: "Small" },
|
|
2380
|
+
{ value: "default", label: "Default" },
|
|
2381
|
+
{ value: "large", label: "Large" },
|
|
2382
|
+
{ value: "larger", label: "Larger" }
|
|
2383
|
+
];
|
|
2384
|
+
var TEXT_SIZE_OPTIONS = TEXT_SIZES.map((value) => ({ value, label: `${value}px` }));
|
|
2676
2385
|
var DENSITY_OPTIONS = [
|
|
2677
2386
|
{ value: "tight", label: "Tight" },
|
|
2678
2387
|
{ value: "compact", label: "Compact" },
|
|
@@ -2706,6 +2415,8 @@ var DEFAULT_NXDS_APPEARANCE = {
|
|
|
2706
2415
|
surfaceTone: "zinc",
|
|
2707
2416
|
lightContrast: 50,
|
|
2708
2417
|
darkContrast: 50,
|
|
2418
|
+
uiScale: "default",
|
|
2419
|
+
textSize: 14,
|
|
2709
2420
|
density: "default",
|
|
2710
2421
|
corners: "subtle",
|
|
2711
2422
|
elevation: "quiet",
|
|
@@ -2714,14 +2425,13 @@ var DEFAULT_NXDS_APPEARANCE = {
|
|
|
2714
2425
|
uiFont: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
2715
2426
|
headingFont: null,
|
|
2716
2427
|
codeFont: 'ui-monospace, "SF Mono", Menlo, monospace',
|
|
2717
|
-
uiFontSize: TYPOGRAPHY_BASE_PX,
|
|
2718
2428
|
codeFontSize: 12,
|
|
2719
2429
|
reduceMotion: false,
|
|
2720
2430
|
pointerCursors: false,
|
|
2721
2431
|
fontSmoothing: false
|
|
2722
2432
|
}
|
|
2723
2433
|
};
|
|
2724
|
-
var FONT_SIZE_PX_MIN =
|
|
2434
|
+
var FONT_SIZE_PX_MIN = MIN_TEXT_PX;
|
|
2725
2435
|
var FONT_SIZE_PX_MAX = 32;
|
|
2726
2436
|
var APPEARANCE_MODES = /* @__PURE__ */ new Set([
|
|
2727
2437
|
"light",
|
|
@@ -2731,6 +2441,10 @@ var APPEARANCE_MODES = /* @__PURE__ */ new Set([
|
|
|
2731
2441
|
var SURFACE_TONES = new Set(
|
|
2732
2442
|
BASE_TONE_OPTIONS.map((option) => option.value)
|
|
2733
2443
|
);
|
|
2444
|
+
var SCALES = new Set(
|
|
2445
|
+
UI_SCALE_OPTIONS.map((option) => option.value)
|
|
2446
|
+
);
|
|
2447
|
+
var TEXT_SIZE_VALUES = new Set(TEXT_SIZES);
|
|
2734
2448
|
var DENSITIES = new Set(
|
|
2735
2449
|
DENSITY_OPTIONS.map((option) => option.value)
|
|
2736
2450
|
);
|
|
@@ -2747,11 +2461,8 @@ var isRecord = (value) => typeof value === "object" && value !== null;
|
|
|
2747
2461
|
var FONT_FAMILY_UNSAFE = /[;{}<]/;
|
|
2748
2462
|
var fontFamilyOr = (value, fallback) => typeof value === "string" && value.length > 0 && !FONT_FAMILY_UNSAFE.test(value) ? value : fallback;
|
|
2749
2463
|
var boolOr = (value, fallback) => typeof value === "boolean" ? value : fallback;
|
|
2750
|
-
var enumOr = (value, values, fallback) =>
|
|
2464
|
+
var enumOr = (value, values, fallback) => values.has(value) ? value : fallback;
|
|
2751
2465
|
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;
|
|
2752
|
-
function typographyScaleVariables(uiPx, codePx) {
|
|
2753
|
-
return [...typographyScale(uiPx, codePx)].map(([name, value]) => ` ${name}: ${value};`).join("\n");
|
|
2754
|
-
}
|
|
2755
2466
|
var PUBLIC_MODE_RENAME = {
|
|
2756
2467
|
density: {
|
|
2757
2468
|
nova: "compact",
|
|
@@ -2791,7 +2502,6 @@ function sanitizeNxdsAppearancePrefs(raw) {
|
|
|
2791
2502
|
uiFont: fontFamilyOr(o.uiFont, d.uiFont),
|
|
2792
2503
|
headingFont: fontFamilyOr(o.headingFont, d.headingFont),
|
|
2793
2504
|
codeFont: fontFamilyOr(o.codeFont, d.codeFont),
|
|
2794
|
-
uiFontSize: clampFontSize(o.uiFontSize, d.uiFontSize),
|
|
2795
2505
|
codeFontSize: clampFontSize(o.codeFontSize, d.codeFontSize),
|
|
2796
2506
|
reduceMotion: boolOr(o.reduceMotion, d.reduceMotion),
|
|
2797
2507
|
pointerCursors: boolOr(o.pointerCursors, d.pointerCursors),
|
|
@@ -2808,6 +2518,8 @@ function sanitizeNxdsAppearance(rawInput) {
|
|
|
2808
2518
|
surfaceTone: enumOr(raw.surfaceTone, SURFACE_TONES, d.surfaceTone),
|
|
2809
2519
|
lightContrast: normalizeContrast(raw.lightContrast, d.lightContrast),
|
|
2810
2520
|
darkContrast: normalizeContrast(raw.darkContrast, d.darkContrast),
|
|
2521
|
+
uiScale: enumOr(raw.uiScale, SCALES, d.uiScale),
|
|
2522
|
+
textSize: enumOr(raw.textSize, TEXT_SIZE_VALUES, d.textSize),
|
|
2811
2523
|
density: enumOr(raw.density, DENSITIES, d.density),
|
|
2812
2524
|
corners: enumOr(raw.corners, CORNERS, d.corners),
|
|
2813
2525
|
elevation: enumOr(raw.elevation, ELEVATIONS, d.elevation),
|
|
@@ -2824,11 +2536,19 @@ function createNxdsThemeContract(state) {
|
|
|
2824
2536
|
dark: { accent: state.brandColor, ...tone.dark }
|
|
2825
2537
|
};
|
|
2826
2538
|
}
|
|
2539
|
+
function scaledCodeSizes(codePx) {
|
|
2540
|
+
return UI_SCALE_OPTIONS.flatMap(
|
|
2541
|
+
({ value: scale }) => TEXT_SIZES.flatMap((textSize) => {
|
|
2542
|
+
const selector = textSizeSelector(scale, textSize);
|
|
2543
|
+
if (selector === null) return [];
|
|
2544
|
+
const px = scaleText(codePx, scale, textSize);
|
|
2545
|
+
return [`${selector} {
|
|
2546
|
+
--nx-typography-code-size: ${px}px;
|
|
2547
|
+
}`];
|
|
2548
|
+
})
|
|
2549
|
+
).join("\n");
|
|
2550
|
+
}
|
|
2827
2551
|
function appearancePrefsToCss(prefs) {
|
|
2828
|
-
const uiPx = clampFontSize(
|
|
2829
|
-
prefs.uiFontSize,
|
|
2830
|
-
DEFAULT_NXDS_APPEARANCE.prefs.uiFontSize
|
|
2831
|
-
);
|
|
2832
2552
|
const codePx = clampFontSize(
|
|
2833
2553
|
prefs.codeFontSize,
|
|
2834
2554
|
DEFAULT_NXDS_APPEARANCE.prefs.codeFontSize
|
|
@@ -2838,8 +2558,9 @@ function appearancePrefsToCss(prefs) {
|
|
|
2838
2558
|
--nx-typography-family-font-sans: ${prefs.uiFont};
|
|
2839
2559
|
--nx-typography-family-font-heading: ${prefs.headingFont ?? "var(--nx-typography-family-font-sans)"};
|
|
2840
2560
|
--nx-typography-family-font-mono: ${prefs.codeFont};
|
|
2841
|
-
${
|
|
2842
|
-
}
|
|
2561
|
+
--nx-typography-code-size: ${scaleText(codePx, "default")}px;
|
|
2562
|
+
}
|
|
2563
|
+
${scaledCodeSizes(codePx)}`)
|
|
2843
2564
|
];
|
|
2844
2565
|
if (prefs.fontSmoothing) {
|
|
2845
2566
|
blocks.push(
|
|
@@ -4238,32 +3959,6 @@ var color_default2 = {
|
|
|
4238
3959
|
}
|
|
4239
3960
|
};
|
|
4240
3961
|
|
|
4241
|
-
// src/lib/token-scales.generated.ts
|
|
4242
|
-
var PRIMITIVE_PALETTE_NAMES = [
|
|
4243
|
-
"green",
|
|
4244
|
-
"emerald",
|
|
4245
|
-
"teal",
|
|
4246
|
-
"cyan",
|
|
4247
|
-
"sky",
|
|
4248
|
-
"indigo",
|
|
4249
|
-
"violet",
|
|
4250
|
-
"purple",
|
|
4251
|
-
"fuchsia",
|
|
4252
|
-
"pink",
|
|
4253
|
-
"slate",
|
|
4254
|
-
"rose",
|
|
4255
|
-
"lime",
|
|
4256
|
-
"yellow",
|
|
4257
|
-
"blue",
|
|
4258
|
-
"gray",
|
|
4259
|
-
"zinc",
|
|
4260
|
-
"neutral",
|
|
4261
|
-
"stone",
|
|
4262
|
-
"red",
|
|
4263
|
-
"orange",
|
|
4264
|
-
"amber"
|
|
4265
|
-
];
|
|
4266
|
-
|
|
4267
3962
|
// src/lib/primitive-palette.ts
|
|
4268
3963
|
var rampCache = /* @__PURE__ */ new Map();
|
|
4269
3964
|
function getPaletteRamp(palette) {
|
|
@@ -4679,10 +4374,12 @@ ${block(":root.dark", derived.dark)}`
|
|
|
4679
4374
|
}
|
|
4680
4375
|
|
|
4681
4376
|
// src/lib/appearance-snapshot.ts
|
|
4682
|
-
var SNAPSHOT_VERSION =
|
|
4377
|
+
var SNAPSHOT_VERSION = 11;
|
|
4683
4378
|
var STATE_COOKIE_VERSION = 6;
|
|
4684
4379
|
var SNAPSHOT_CACHE_LIMIT = 50;
|
|
4685
4380
|
var NXDS_APPEARANCE_DATA_ATTRS = [
|
|
4381
|
+
"data-ui-scale",
|
|
4382
|
+
"data-text-size",
|
|
4686
4383
|
"data-density",
|
|
4687
4384
|
"data-radius",
|
|
4688
4385
|
"data-shadow",
|
|
@@ -4797,6 +4494,8 @@ function resolveFirstPaint(snapshot, systemPrefersDark) {
|
|
|
4797
4494
|
return {
|
|
4798
4495
|
className: dark ? "dark" : "",
|
|
4799
4496
|
dataAttrs: {
|
|
4497
|
+
"data-ui-scale": state.uiScale,
|
|
4498
|
+
"data-text-size": String(state.textSize),
|
|
4800
4499
|
"data-density": state.density,
|
|
4801
4500
|
"data-radius": state.corners,
|
|
4802
4501
|
"data-shadow": state.elevation,
|
|
@@ -4812,7 +4511,7 @@ function escapeInlineScriptJson(value) {
|
|
|
4812
4511
|
function createNxdsAppearanceBootstrapScript(options = {}) {
|
|
4813
4512
|
const storageKey = options.storageKey ?? DEFAULT_STORAGE_KEY;
|
|
4814
4513
|
const defaultSnapshot = options.defaultSnapshot ? sanitizeNxdsAppearanceSnapshot(options.defaultSnapshot) : createDefaultNxdsAppearanceSnapshot();
|
|
4815
|
-
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){}})();`;
|
|
4514
|
+
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){}})();`;
|
|
4816
4515
|
}
|
|
4817
4516
|
|
|
4818
4517
|
// src/lib/appearance-dom.ts
|
|
@@ -5139,20 +4838,6 @@ function contrastField(flag, key, description) {
|
|
|
5139
4838
|
})
|
|
5140
4839
|
};
|
|
5141
4840
|
}
|
|
5142
|
-
function fontSizeField(flag, key, description) {
|
|
5143
|
-
return {
|
|
5144
|
-
kind: "integer",
|
|
5145
|
-
flag,
|
|
5146
|
-
key: `prefs.${key}`,
|
|
5147
|
-
description,
|
|
5148
|
-
min: FONT_SIZE_PX_MIN,
|
|
5149
|
-
max: FONT_SIZE_PX_MAX,
|
|
5150
|
-
read: (theme) => String(theme.appearance.prefs[key]),
|
|
5151
|
-
write: (theme, value) => withPrefs(theme, {
|
|
5152
|
-
[key]: integer(flag, value, FONT_SIZE_PX_MIN, FONT_SIZE_PX_MAX)
|
|
5153
|
-
})
|
|
5154
|
-
};
|
|
5155
|
-
}
|
|
5156
4841
|
function fontField(flag, key, description, categories, fallback) {
|
|
5157
4842
|
const fonts = FONT_OPTIONS.filter(
|
|
5158
4843
|
(font) => categories.includes(font.category)
|
|
@@ -5183,6 +4868,9 @@ function fontField(flag, key, description, categories, fallback) {
|
|
|
5183
4868
|
}
|
|
5184
4869
|
};
|
|
5185
4870
|
}
|
|
4871
|
+
var TEXT_SIZES2 = TEXT_SIZE_OPTIONS.map((option) => option.value);
|
|
4872
|
+
var TEXT_SIZE_MIN = Math.min(...TEXT_SIZES2);
|
|
4873
|
+
var TEXT_SIZE_MAX = Math.max(...TEXT_SIZES2);
|
|
5186
4874
|
var DEFAULT_PREFS = DEFAULT_NXDS_APPEARANCE.prefs;
|
|
5187
4875
|
var TEXT_FONTS = ["sans", "serif"];
|
|
5188
4876
|
var NXDS_THEME_FIELDS = [
|
|
@@ -5203,6 +4891,30 @@ var NXDS_THEME_FIELDS = [
|
|
|
5203
4891
|
"neutral tone of backgrounds and borders",
|
|
5204
4892
|
BASE_TONE_OPTIONS.map((option) => option.value)
|
|
5205
4893
|
),
|
|
4894
|
+
enumField(
|
|
4895
|
+
"ui-scale",
|
|
4896
|
+
"uiScale",
|
|
4897
|
+
"size of text, icons and spacing together",
|
|
4898
|
+
UI_SCALE_OPTIONS.map((option) => option.value)
|
|
4899
|
+
),
|
|
4900
|
+
{
|
|
4901
|
+
kind: "integer",
|
|
4902
|
+
flag: "text-size",
|
|
4903
|
+
key: "textSize",
|
|
4904
|
+
description: `label text size in px at the default UI scale, ${TEXT_SIZE_MIN} to ${TEXT_SIZE_MAX}`,
|
|
4905
|
+
min: TEXT_SIZE_MIN,
|
|
4906
|
+
max: TEXT_SIZE_MAX,
|
|
4907
|
+
read: (theme) => String(theme.appearance.textSize),
|
|
4908
|
+
write: (theme, value) => withAppearance(theme, {
|
|
4909
|
+
// Every whole number from the minimum to the maximum is a text size.
|
|
4910
|
+
textSize: integer(
|
|
4911
|
+
"text-size",
|
|
4912
|
+
value,
|
|
4913
|
+
TEXT_SIZE_MIN,
|
|
4914
|
+
TEXT_SIZE_MAX
|
|
4915
|
+
)
|
|
4916
|
+
})
|
|
4917
|
+
},
|
|
5206
4918
|
enumField(
|
|
5207
4919
|
"density",
|
|
5208
4920
|
"density",
|
|
@@ -5253,8 +4965,23 @@ var NXDS_THEME_FIELDS = [
|
|
|
5253
4965
|
value: "system",
|
|
5254
4966
|
family: DEFAULT_PREFS.codeFont
|
|
5255
4967
|
}),
|
|
5256
|
-
|
|
5257
|
-
|
|
4968
|
+
{
|
|
4969
|
+
kind: "integer",
|
|
4970
|
+
flag: "code-font-size",
|
|
4971
|
+
key: "prefs.codeFontSize",
|
|
4972
|
+
description: "code text size in px",
|
|
4973
|
+
min: FONT_SIZE_PX_MIN,
|
|
4974
|
+
max: FONT_SIZE_PX_MAX,
|
|
4975
|
+
read: (theme) => String(theme.appearance.prefs.codeFontSize),
|
|
4976
|
+
write: (theme, value) => withPrefs(theme, {
|
|
4977
|
+
codeFontSize: integer(
|
|
4978
|
+
"code-font-size",
|
|
4979
|
+
value,
|
|
4980
|
+
FONT_SIZE_PX_MIN,
|
|
4981
|
+
FONT_SIZE_PX_MAX
|
|
4982
|
+
)
|
|
4983
|
+
})
|
|
4984
|
+
},
|
|
5258
4985
|
{
|
|
5259
4986
|
kind: "choice",
|
|
5260
4987
|
flag: "icons",
|
|
@@ -5455,7 +5182,9 @@ var SEMANTIC_TOKEN_REGISTRY = [
|
|
|
5455
5182
|
SEMANTIC_TOKEN_REGISTRY,
|
|
5456
5183
|
SNAPSHOT_VERSION,
|
|
5457
5184
|
STROKE_OPTIONS,
|
|
5185
|
+
TEXT_SIZE_OPTIONS,
|
|
5458
5186
|
TIER_THRESHOLDS,
|
|
5187
|
+
UI_SCALE_OPTIONS,
|
|
5459
5188
|
adjustContrast,
|
|
5460
5189
|
apcaLc,
|
|
5461
5190
|
appearancePrefsToCss,
|
|
@@ -5487,6 +5216,7 @@ var SEMANTIC_TOKEN_REGISTRY = [
|
|
|
5487
5216
|
serializeNxdsAppearanceStateCookie,
|
|
5488
5217
|
shuffleNxdsAppearance,
|
|
5489
5218
|
shuffleNxdsIconLibrary,
|
|
5219
|
+
textSizePx,
|
|
5490
5220
|
themeToCss,
|
|
5491
5221
|
watchColorScheme
|
|
5492
5222
|
});
|