@nxds/core 0.12.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 +11 -2
- package/dist/runtime/catalogue.cjs +1070 -742
- package/dist/runtime/catalogue.cjs.map +1 -1
- package/dist/runtime/catalogue.d.cts +40 -16
- package/dist/runtime/catalogue.d.ts +40 -16
- package/dist/runtime/catalogue.js +1070 -742
- package/dist/runtime/catalogue.js.map +1 -1
- package/dist/runtime/index.cjs +140 -390
- 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 +137 -390
- 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-CAjRqzCx.d.ts → surface-ladder-B8LyPHC_.d.ts} +64 -3
- package/dist/runtime/{surface-ladder-tv7B_RKy.d.cts → surface-ladder-DQ9Yfwie.d.cts} +64 -3
- 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,329 +1975,59 @@ function apcaLc(foreground, background) {
|
|
|
1972
1975
|
);
|
|
1973
1976
|
}
|
|
1974
1977
|
|
|
1975
|
-
//
|
|
1976
|
-
var
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
$type: "fontFamily",
|
|
2008
|
-
$extensions: {
|
|
2009
|
-
"nx-font-source": {
|
|
2010
|
-
type: "system"
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
},
|
|
2015
|
-
size: {
|
|
2016
|
-
xxs: {
|
|
2017
|
-
$value: {
|
|
2018
|
-
value: 11,
|
|
2019
|
-
unit: "px"
|
|
2020
|
-
},
|
|
2021
|
-
$type: "dimension"
|
|
2022
|
-
},
|
|
2023
|
-
xs: {
|
|
2024
|
-
$value: {
|
|
2025
|
-
value: 12,
|
|
2026
|
-
unit: "px"
|
|
2027
|
-
},
|
|
2028
|
-
$type: "dimension"
|
|
2029
|
-
},
|
|
2030
|
-
sm: {
|
|
2031
|
-
$value: {
|
|
2032
|
-
value: 14,
|
|
2033
|
-
unit: "px"
|
|
2034
|
-
},
|
|
2035
|
-
$type: "dimension"
|
|
2036
|
-
},
|
|
2037
|
-
base: {
|
|
2038
|
-
$value: {
|
|
2039
|
-
value: 16,
|
|
2040
|
-
unit: "px"
|
|
2041
|
-
},
|
|
2042
|
-
$type: "dimension"
|
|
2043
|
-
},
|
|
2044
|
-
lg: {
|
|
2045
|
-
$value: {
|
|
2046
|
-
value: 18,
|
|
2047
|
-
unit: "px"
|
|
2048
|
-
},
|
|
2049
|
-
$type: "dimension"
|
|
2050
|
-
},
|
|
2051
|
-
xl: {
|
|
2052
|
-
$value: {
|
|
2053
|
-
value: 20,
|
|
2054
|
-
unit: "px"
|
|
2055
|
-
},
|
|
2056
|
-
$type: "dimension"
|
|
2057
|
-
},
|
|
2058
|
-
"2xl": {
|
|
2059
|
-
$value: {
|
|
2060
|
-
value: 24,
|
|
2061
|
-
unit: "px"
|
|
2062
|
-
},
|
|
2063
|
-
$type: "dimension"
|
|
2064
|
-
},
|
|
2065
|
-
"3xl": {
|
|
2066
|
-
$value: {
|
|
2067
|
-
value: 30,
|
|
2068
|
-
unit: "px"
|
|
2069
|
-
},
|
|
2070
|
-
$type: "dimension"
|
|
2071
|
-
},
|
|
2072
|
-
"4xl": {
|
|
2073
|
-
$value: {
|
|
2074
|
-
value: 36,
|
|
2075
|
-
unit: "px"
|
|
2076
|
-
},
|
|
2077
|
-
$type: "dimension"
|
|
2078
|
-
},
|
|
2079
|
-
"5xl": {
|
|
2080
|
-
$value: {
|
|
2081
|
-
value: 48,
|
|
2082
|
-
unit: "px"
|
|
2083
|
-
},
|
|
2084
|
-
$type: "dimension"
|
|
2085
|
-
},
|
|
2086
|
-
"6xl": {
|
|
2087
|
-
$value: {
|
|
2088
|
-
value: 60,
|
|
2089
|
-
unit: "px"
|
|
2090
|
-
},
|
|
2091
|
-
$type: "dimension"
|
|
2092
|
-
},
|
|
2093
|
-
"7xl": {
|
|
2094
|
-
$value: {
|
|
2095
|
-
value: 72,
|
|
2096
|
-
unit: "px"
|
|
2097
|
-
},
|
|
2098
|
-
$type: "dimension"
|
|
2099
|
-
},
|
|
2100
|
-
"8xl": {
|
|
2101
|
-
$value: {
|
|
2102
|
-
value: 96,
|
|
2103
|
-
unit: "px"
|
|
2104
|
-
},
|
|
2105
|
-
$type: "dimension"
|
|
2106
|
-
},
|
|
2107
|
-
"9xl": {
|
|
2108
|
-
$value: {
|
|
2109
|
-
value: 128,
|
|
2110
|
-
unit: "px"
|
|
2111
|
-
},
|
|
2112
|
-
$type: "dimension"
|
|
2113
|
-
}
|
|
2114
|
-
},
|
|
2115
|
-
weight: {
|
|
2116
|
-
thin: {
|
|
2117
|
-
$value: 100,
|
|
2118
|
-
$type: "fontWeight"
|
|
2119
|
-
},
|
|
2120
|
-
extralight: {
|
|
2121
|
-
$value: 200,
|
|
2122
|
-
$type: "fontWeight"
|
|
2123
|
-
},
|
|
2124
|
-
light: {
|
|
2125
|
-
$value: 300,
|
|
2126
|
-
$type: "fontWeight"
|
|
2127
|
-
},
|
|
2128
|
-
normal: {
|
|
2129
|
-
$value: 400,
|
|
2130
|
-
$type: "fontWeight"
|
|
2131
|
-
},
|
|
2132
|
-
medium: {
|
|
2133
|
-
$value: 500,
|
|
2134
|
-
$type: "fontWeight"
|
|
2135
|
-
},
|
|
2136
|
-
semibold: {
|
|
2137
|
-
$value: 600,
|
|
2138
|
-
$type: "fontWeight"
|
|
2139
|
-
},
|
|
2140
|
-
bold: {
|
|
2141
|
-
$value: 700,
|
|
2142
|
-
$type: "fontWeight"
|
|
2143
|
-
},
|
|
2144
|
-
extrabold: {
|
|
2145
|
-
$value: 800,
|
|
2146
|
-
$type: "fontWeight"
|
|
2147
|
-
},
|
|
2148
|
-
black: {
|
|
2149
|
-
$value: 900,
|
|
2150
|
-
$type: "fontWeight"
|
|
2151
|
-
}
|
|
2152
|
-
},
|
|
2153
|
-
"line-height": {
|
|
2154
|
-
xxs: {
|
|
2155
|
-
$value: {
|
|
2156
|
-
value: 12,
|
|
2157
|
-
unit: "px"
|
|
2158
|
-
},
|
|
2159
|
-
$type: "dimension"
|
|
2160
|
-
},
|
|
2161
|
-
xs: {
|
|
2162
|
-
$value: {
|
|
2163
|
-
value: 16,
|
|
2164
|
-
unit: "px"
|
|
2165
|
-
},
|
|
2166
|
-
$type: "dimension"
|
|
2167
|
-
},
|
|
2168
|
-
sm: {
|
|
2169
|
-
$value: {
|
|
2170
|
-
value: 20,
|
|
2171
|
-
unit: "px"
|
|
2172
|
-
},
|
|
2173
|
-
$type: "dimension"
|
|
2174
|
-
},
|
|
2175
|
-
base: {
|
|
2176
|
-
$value: {
|
|
2177
|
-
value: 24,
|
|
2178
|
-
unit: "px"
|
|
2179
|
-
},
|
|
2180
|
-
$type: "dimension"
|
|
2181
|
-
},
|
|
2182
|
-
lg: {
|
|
2183
|
-
$value: {
|
|
2184
|
-
value: 28,
|
|
2185
|
-
unit: "px"
|
|
2186
|
-
},
|
|
2187
|
-
$type: "dimension"
|
|
2188
|
-
},
|
|
2189
|
-
xl: {
|
|
2190
|
-
$value: {
|
|
2191
|
-
value: 28,
|
|
2192
|
-
unit: "px"
|
|
2193
|
-
},
|
|
2194
|
-
$type: "dimension"
|
|
2195
|
-
},
|
|
2196
|
-
"2xl": {
|
|
2197
|
-
$value: {
|
|
2198
|
-
value: 32,
|
|
2199
|
-
unit: "px"
|
|
2200
|
-
},
|
|
2201
|
-
$type: "dimension"
|
|
2202
|
-
},
|
|
2203
|
-
"3xl": {
|
|
2204
|
-
$value: {
|
|
2205
|
-
value: 36,
|
|
2206
|
-
unit: "px"
|
|
2207
|
-
},
|
|
2208
|
-
$type: "dimension"
|
|
2209
|
-
},
|
|
2210
|
-
"4xl": {
|
|
2211
|
-
$value: {
|
|
2212
|
-
value: 48,
|
|
2213
|
-
unit: "px"
|
|
2214
|
-
},
|
|
2215
|
-
$type: "dimension"
|
|
2216
|
-
},
|
|
2217
|
-
"5xl": {
|
|
2218
|
-
$value: {
|
|
2219
|
-
value: 48,
|
|
2220
|
-
unit: "px"
|
|
2221
|
-
},
|
|
2222
|
-
$type: "dimension"
|
|
2223
|
-
},
|
|
2224
|
-
"6xl": {
|
|
2225
|
-
$value: {
|
|
2226
|
-
value: 60,
|
|
2227
|
-
unit: "px"
|
|
2228
|
-
},
|
|
2229
|
-
$type: "dimension"
|
|
2230
|
-
},
|
|
2231
|
-
"7xl": {
|
|
2232
|
-
$value: {
|
|
2233
|
-
value: 72,
|
|
2234
|
-
unit: "px"
|
|
2235
|
-
},
|
|
2236
|
-
$type: "dimension"
|
|
2237
|
-
},
|
|
2238
|
-
"8xl": {
|
|
2239
|
-
$value: {
|
|
2240
|
-
value: 96,
|
|
2241
|
-
unit: "px"
|
|
2242
|
-
},
|
|
2243
|
-
$type: "dimension"
|
|
2244
|
-
},
|
|
2245
|
-
"9xl": {
|
|
2246
|
-
$value: {
|
|
2247
|
-
value: 128,
|
|
2248
|
-
unit: "px"
|
|
2249
|
-
},
|
|
2250
|
-
$type: "dimension"
|
|
2251
|
-
}
|
|
2252
|
-
},
|
|
2253
|
-
letterspacing: {
|
|
2254
|
-
tighter: {
|
|
2255
|
-
$value: {
|
|
2256
|
-
value: -0.800000011920929,
|
|
2257
|
-
unit: "px"
|
|
2258
|
-
},
|
|
2259
|
-
$type: "dimension"
|
|
2260
|
-
},
|
|
2261
|
-
tight: {
|
|
2262
|
-
$value: {
|
|
2263
|
-
value: -0.4000000059604645,
|
|
2264
|
-
unit: "px"
|
|
2265
|
-
},
|
|
2266
|
-
$type: "dimension"
|
|
2267
|
-
},
|
|
2268
|
-
normal: {
|
|
2269
|
-
$value: {
|
|
2270
|
-
value: 0,
|
|
2271
|
-
unit: "px"
|
|
2272
|
-
},
|
|
2273
|
-
$type: "dimension"
|
|
2274
|
-
},
|
|
2275
|
-
wide: {
|
|
2276
|
-
$value: {
|
|
2277
|
-
value: 0.4000000059604645,
|
|
2278
|
-
unit: "px"
|
|
2279
|
-
},
|
|
2280
|
-
$type: "dimension"
|
|
2281
|
-
},
|
|
2282
|
-
wider: {
|
|
2283
|
-
$value: {
|
|
2284
|
-
value: 0.800000011920929,
|
|
2285
|
-
unit: "px"
|
|
2286
|
-
},
|
|
2287
|
-
$type: "dimension"
|
|
2288
|
-
},
|
|
2289
|
-
widest: {
|
|
2290
|
-
$value: {
|
|
2291
|
-
value: 1.600000023841858,
|
|
2292
|
-
unit: "px"
|
|
2293
|
-
},
|
|
2294
|
-
$type: "dimension"
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
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 }
|
|
2297
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
|
+
}
|
|
2298
2031
|
|
|
2299
2032
|
// src/lib/contrast.ts
|
|
2300
2033
|
var import_apca_w33 = require("apca-w3");
|
|
@@ -2642,6 +2375,13 @@ var BASE_TONE_SEEDS = {
|
|
|
2642
2375
|
dark: { background: "#111827", foreground: "#f9fafb" }
|
|
2643
2376
|
}
|
|
2644
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` }));
|
|
2645
2385
|
var DENSITY_OPTIONS = [
|
|
2646
2386
|
{ value: "tight", label: "Tight" },
|
|
2647
2387
|
{ value: "compact", label: "Compact" },
|
|
@@ -2675,6 +2415,8 @@ var DEFAULT_NXDS_APPEARANCE = {
|
|
|
2675
2415
|
surfaceTone: "zinc",
|
|
2676
2416
|
lightContrast: 50,
|
|
2677
2417
|
darkContrast: 50,
|
|
2418
|
+
uiScale: "default",
|
|
2419
|
+
textSize: 14,
|
|
2678
2420
|
density: "default",
|
|
2679
2421
|
corners: "subtle",
|
|
2680
2422
|
elevation: "quiet",
|
|
@@ -2683,14 +2425,13 @@ var DEFAULT_NXDS_APPEARANCE = {
|
|
|
2683
2425
|
uiFont: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
|
|
2684
2426
|
headingFont: null,
|
|
2685
2427
|
codeFont: 'ui-monospace, "SF Mono", Menlo, monospace',
|
|
2686
|
-
uiFontSize: 14,
|
|
2687
2428
|
codeFontSize: 12,
|
|
2688
2429
|
reduceMotion: false,
|
|
2689
2430
|
pointerCursors: false,
|
|
2690
2431
|
fontSmoothing: false
|
|
2691
2432
|
}
|
|
2692
2433
|
};
|
|
2693
|
-
var FONT_SIZE_PX_MIN =
|
|
2434
|
+
var FONT_SIZE_PX_MIN = MIN_TEXT_PX;
|
|
2694
2435
|
var FONT_SIZE_PX_MAX = 32;
|
|
2695
2436
|
var APPEARANCE_MODES = /* @__PURE__ */ new Set([
|
|
2696
2437
|
"light",
|
|
@@ -2700,6 +2441,10 @@ var APPEARANCE_MODES = /* @__PURE__ */ new Set([
|
|
|
2700
2441
|
var SURFACE_TONES = new Set(
|
|
2701
2442
|
BASE_TONE_OPTIONS.map((option) => option.value)
|
|
2702
2443
|
);
|
|
2444
|
+
var SCALES = new Set(
|
|
2445
|
+
UI_SCALE_OPTIONS.map((option) => option.value)
|
|
2446
|
+
);
|
|
2447
|
+
var TEXT_SIZE_VALUES = new Set(TEXT_SIZES);
|
|
2703
2448
|
var DENSITIES = new Set(
|
|
2704
2449
|
DENSITY_OPTIONS.map((option) => option.value)
|
|
2705
2450
|
);
|
|
@@ -2716,21 +2461,8 @@ var isRecord = (value) => typeof value === "object" && value !== null;
|
|
|
2716
2461
|
var FONT_FAMILY_UNSAFE = /[;{}<]/;
|
|
2717
2462
|
var fontFamilyOr = (value, fallback) => typeof value === "string" && value.length > 0 && !FONT_FAMILY_UNSAFE.test(value) ? value : fallback;
|
|
2718
2463
|
var boolOr = (value, fallback) => typeof value === "boolean" ? value : fallback;
|
|
2719
|
-
var enumOr = (value, values, fallback) =>
|
|
2464
|
+
var enumOr = (value, values, fallback) => values.has(value) ? value : fallback;
|
|
2720
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;
|
|
2721
|
-
function formatPx(value) {
|
|
2722
|
-
return `${Number(value.toFixed(4))}px`;
|
|
2723
|
-
}
|
|
2724
|
-
function typographyScaleVariables(uiPx) {
|
|
2725
|
-
const scale = uiPx / DEFAULT_NXDS_APPEARANCE.prefs.uiFontSize;
|
|
2726
|
-
const sizeVars = Object.entries(typography_default_default.size).map(
|
|
2727
|
-
([name, token2]) => ` --nx-typography-size-${name}: ${formatPx(token2.$value.value * scale)};`
|
|
2728
|
-
);
|
|
2729
|
-
const lineHeightVars = Object.entries(typography_default_default["line-height"]).map(
|
|
2730
|
-
([name, token2]) => ` --nx-typography-line-height-${name}: ${formatPx(token2.$value.value * scale)};`
|
|
2731
|
-
);
|
|
2732
|
-
return [...sizeVars, ...lineHeightVars].join("\n");
|
|
2733
|
-
}
|
|
2734
2466
|
var PUBLIC_MODE_RENAME = {
|
|
2735
2467
|
density: {
|
|
2736
2468
|
nova: "compact",
|
|
@@ -2770,7 +2502,6 @@ function sanitizeNxdsAppearancePrefs(raw) {
|
|
|
2770
2502
|
uiFont: fontFamilyOr(o.uiFont, d.uiFont),
|
|
2771
2503
|
headingFont: fontFamilyOr(o.headingFont, d.headingFont),
|
|
2772
2504
|
codeFont: fontFamilyOr(o.codeFont, d.codeFont),
|
|
2773
|
-
uiFontSize: clampFontSize(o.uiFontSize, d.uiFontSize),
|
|
2774
2505
|
codeFontSize: clampFontSize(o.codeFontSize, d.codeFontSize),
|
|
2775
2506
|
reduceMotion: boolOr(o.reduceMotion, d.reduceMotion),
|
|
2776
2507
|
pointerCursors: boolOr(o.pointerCursors, d.pointerCursors),
|
|
@@ -2787,6 +2518,8 @@ function sanitizeNxdsAppearance(rawInput) {
|
|
|
2787
2518
|
surfaceTone: enumOr(raw.surfaceTone, SURFACE_TONES, d.surfaceTone),
|
|
2788
2519
|
lightContrast: normalizeContrast(raw.lightContrast, d.lightContrast),
|
|
2789
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),
|
|
2790
2523
|
density: enumOr(raw.density, DENSITIES, d.density),
|
|
2791
2524
|
corners: enumOr(raw.corners, CORNERS, d.corners),
|
|
2792
2525
|
elevation: enumOr(raw.elevation, ELEVATIONS, d.elevation),
|
|
@@ -2803,11 +2536,19 @@ function createNxdsThemeContract(state) {
|
|
|
2803
2536
|
dark: { accent: state.brandColor, ...tone.dark }
|
|
2804
2537
|
};
|
|
2805
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
|
+
}
|
|
2806
2551
|
function appearancePrefsToCss(prefs) {
|
|
2807
|
-
const uiPx = clampFontSize(
|
|
2808
|
-
prefs.uiFontSize,
|
|
2809
|
-
DEFAULT_NXDS_APPEARANCE.prefs.uiFontSize
|
|
2810
|
-
);
|
|
2811
2552
|
const codePx = clampFontSize(
|
|
2812
2553
|
prefs.codeFontSize,
|
|
2813
2554
|
DEFAULT_NXDS_APPEARANCE.prefs.codeFontSize
|
|
@@ -2817,9 +2558,9 @@ function appearancePrefsToCss(prefs) {
|
|
|
2817
2558
|
--nx-typography-family-font-sans: ${prefs.uiFont};
|
|
2818
2559
|
--nx-typography-family-font-heading: ${prefs.headingFont ?? "var(--nx-typography-family-font-sans)"};
|
|
2819
2560
|
--nx-typography-family-font-mono: ${prefs.codeFont};
|
|
2820
|
-
${
|
|
2821
|
-
}
|
|
2822
|
-
|
|
2561
|
+
--nx-typography-code-size: ${scaleText(codePx, "default")}px;
|
|
2562
|
+
}
|
|
2563
|
+
${scaledCodeSizes(codePx)}`)
|
|
2823
2564
|
];
|
|
2824
2565
|
if (prefs.fontSmoothing) {
|
|
2825
2566
|
blocks.push(
|
|
@@ -4218,32 +3959,6 @@ var color_default2 = {
|
|
|
4218
3959
|
}
|
|
4219
3960
|
};
|
|
4220
3961
|
|
|
4221
|
-
// src/lib/token-scales.generated.ts
|
|
4222
|
-
var PRIMITIVE_PALETTE_NAMES = [
|
|
4223
|
-
"green",
|
|
4224
|
-
"emerald",
|
|
4225
|
-
"teal",
|
|
4226
|
-
"cyan",
|
|
4227
|
-
"sky",
|
|
4228
|
-
"indigo",
|
|
4229
|
-
"violet",
|
|
4230
|
-
"purple",
|
|
4231
|
-
"fuchsia",
|
|
4232
|
-
"pink",
|
|
4233
|
-
"slate",
|
|
4234
|
-
"rose",
|
|
4235
|
-
"lime",
|
|
4236
|
-
"yellow",
|
|
4237
|
-
"blue",
|
|
4238
|
-
"gray",
|
|
4239
|
-
"zinc",
|
|
4240
|
-
"neutral",
|
|
4241
|
-
"stone",
|
|
4242
|
-
"red",
|
|
4243
|
-
"orange",
|
|
4244
|
-
"amber"
|
|
4245
|
-
];
|
|
4246
|
-
|
|
4247
3962
|
// src/lib/primitive-palette.ts
|
|
4248
3963
|
var rampCache = /* @__PURE__ */ new Map();
|
|
4249
3964
|
function getPaletteRamp(palette) {
|
|
@@ -4659,10 +4374,12 @@ ${block(":root.dark", derived.dark)}`
|
|
|
4659
4374
|
}
|
|
4660
4375
|
|
|
4661
4376
|
// src/lib/appearance-snapshot.ts
|
|
4662
|
-
var SNAPSHOT_VERSION =
|
|
4377
|
+
var SNAPSHOT_VERSION = 11;
|
|
4663
4378
|
var STATE_COOKIE_VERSION = 6;
|
|
4664
4379
|
var SNAPSHOT_CACHE_LIMIT = 50;
|
|
4665
4380
|
var NXDS_APPEARANCE_DATA_ATTRS = [
|
|
4381
|
+
"data-ui-scale",
|
|
4382
|
+
"data-text-size",
|
|
4666
4383
|
"data-density",
|
|
4667
4384
|
"data-radius",
|
|
4668
4385
|
"data-shadow",
|
|
@@ -4777,6 +4494,8 @@ function resolveFirstPaint(snapshot, systemPrefersDark) {
|
|
|
4777
4494
|
return {
|
|
4778
4495
|
className: dark ? "dark" : "",
|
|
4779
4496
|
dataAttrs: {
|
|
4497
|
+
"data-ui-scale": state.uiScale,
|
|
4498
|
+
"data-text-size": String(state.textSize),
|
|
4780
4499
|
"data-density": state.density,
|
|
4781
4500
|
"data-radius": state.corners,
|
|
4782
4501
|
"data-shadow": state.elevation,
|
|
@@ -4792,7 +4511,7 @@ function escapeInlineScriptJson(value) {
|
|
|
4792
4511
|
function createNxdsAppearanceBootstrapScript(options = {}) {
|
|
4793
4512
|
const storageKey = options.storageKey ?? DEFAULT_STORAGE_KEY;
|
|
4794
4513
|
const defaultSnapshot = options.defaultSnapshot ? sanitizeNxdsAppearanceSnapshot(options.defaultSnapshot) : createDefaultNxdsAppearanceSnapshot();
|
|
4795
|
-
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){}})();`;
|
|
4796
4515
|
}
|
|
4797
4516
|
|
|
4798
4517
|
// src/lib/appearance-dom.ts
|
|
@@ -5119,20 +4838,6 @@ function contrastField(flag, key, description) {
|
|
|
5119
4838
|
})
|
|
5120
4839
|
};
|
|
5121
4840
|
}
|
|
5122
|
-
function fontSizeField(flag, key, description) {
|
|
5123
|
-
return {
|
|
5124
|
-
kind: "integer",
|
|
5125
|
-
flag,
|
|
5126
|
-
key: `prefs.${key}`,
|
|
5127
|
-
description,
|
|
5128
|
-
min: FONT_SIZE_PX_MIN,
|
|
5129
|
-
max: FONT_SIZE_PX_MAX,
|
|
5130
|
-
read: (theme) => String(theme.appearance.prefs[key]),
|
|
5131
|
-
write: (theme, value) => withPrefs(theme, {
|
|
5132
|
-
[key]: integer(flag, value, FONT_SIZE_PX_MIN, FONT_SIZE_PX_MAX)
|
|
5133
|
-
})
|
|
5134
|
-
};
|
|
5135
|
-
}
|
|
5136
4841
|
function fontField(flag, key, description, categories, fallback) {
|
|
5137
4842
|
const fonts = FONT_OPTIONS.filter(
|
|
5138
4843
|
(font) => categories.includes(font.category)
|
|
@@ -5163,6 +4868,9 @@ function fontField(flag, key, description, categories, fallback) {
|
|
|
5163
4868
|
}
|
|
5164
4869
|
};
|
|
5165
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);
|
|
5166
4874
|
var DEFAULT_PREFS = DEFAULT_NXDS_APPEARANCE.prefs;
|
|
5167
4875
|
var TEXT_FONTS = ["sans", "serif"];
|
|
5168
4876
|
var NXDS_THEME_FIELDS = [
|
|
@@ -5183,6 +4891,30 @@ var NXDS_THEME_FIELDS = [
|
|
|
5183
4891
|
"neutral tone of backgrounds and borders",
|
|
5184
4892
|
BASE_TONE_OPTIONS.map((option) => option.value)
|
|
5185
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
|
+
},
|
|
5186
4918
|
enumField(
|
|
5187
4919
|
"density",
|
|
5188
4920
|
"density",
|
|
@@ -5233,8 +4965,23 @@ var NXDS_THEME_FIELDS = [
|
|
|
5233
4965
|
value: "system",
|
|
5234
4966
|
family: DEFAULT_PREFS.codeFont
|
|
5235
4967
|
}),
|
|
5236
|
-
|
|
5237
|
-
|
|
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
|
+
},
|
|
5238
4985
|
{
|
|
5239
4986
|
kind: "choice",
|
|
5240
4987
|
flag: "icons",
|
|
@@ -5435,7 +5182,9 @@ var SEMANTIC_TOKEN_REGISTRY = [
|
|
|
5435
5182
|
SEMANTIC_TOKEN_REGISTRY,
|
|
5436
5183
|
SNAPSHOT_VERSION,
|
|
5437
5184
|
STROKE_OPTIONS,
|
|
5185
|
+
TEXT_SIZE_OPTIONS,
|
|
5438
5186
|
TIER_THRESHOLDS,
|
|
5187
|
+
UI_SCALE_OPTIONS,
|
|
5439
5188
|
adjustContrast,
|
|
5440
5189
|
apcaLc,
|
|
5441
5190
|
appearancePrefsToCss,
|
|
@@ -5467,6 +5216,7 @@ var SEMANTIC_TOKEN_REGISTRY = [
|
|
|
5467
5216
|
serializeNxdsAppearanceStateCookie,
|
|
5468
5217
|
shuffleNxdsAppearance,
|
|
5469
5218
|
shuffleNxdsIconLibrary,
|
|
5219
|
+
textSizePx,
|
|
5470
5220
|
themeToCss,
|
|
5471
5221
|
watchColorScheme
|
|
5472
5222
|
});
|