@nxds/core 0.9.1 → 0.10.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 +79 -21
- package/dist/runtime/catalogue.cjs.map +1 -1
- package/dist/runtime/catalogue.d.cts +6 -5
- package/dist/runtime/catalogue.d.ts +6 -5
- package/dist/runtime/catalogue.js +79 -21
- package/dist/runtime/catalogue.js.map +1 -1
- package/dist/runtime/index.cjs +30 -4
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +8 -1
- package/dist/runtime/index.d.ts +8 -1
- package/dist/runtime/index.js +29 -4
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/palette.cjs +26 -3
- package/dist/runtime/palette.cjs.map +1 -1
- package/dist/runtime/palette.d.cts +3 -1402
- package/dist/runtime/palette.d.ts +3 -1402
- package/dist/runtime/palette.js +26 -3
- package/dist/runtime/palette.js.map +1 -1
- package/dist/runtime/token-scales.generated-CCNkHJ3I.d.cts +9 -0
- package/dist/runtime/token-scales.generated-CCNkHJ3I.d.ts +9 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -173,7 +173,7 @@ at build time.
|
|
|
173
173
|
### Generate CSS
|
|
174
174
|
|
|
175
175
|
```bash
|
|
176
|
-
pnpm tokens:tailwind # From the repo root: build core and generate @nxds/tailwind CSS
|
|
176
|
+
pnpm tokens:tailwind # From the repo root: generate the token scales, build core and generate @nxds/tailwind CSS
|
|
177
177
|
```
|
|
178
178
|
|
|
179
179
|
### Output Files
|
|
@@ -197,4 +197,4 @@ When multi-platform support is needed, tools like Style Dictionary can be added
|
|
|
197
197
|
- **Color** is engine-owned: edit the derivation in `src/lib/surface-ladder.ts` / `src/lib/derive-theme.ts` (color primitives live in `tokens/primitives/color.json`).
|
|
198
198
|
- **Non-color** (spacing, radius, shadow, borderwidth, motion, typography): edit the DTCG token files in `tokens/` (`$value`, `$type`, `$description`).
|
|
199
199
|
|
|
200
|
-
Then run `make tokens` (or `pnpm tokens:tailwind`) to regenerate CSS; the
|
|
200
|
+
Then run `make tokens` (or `pnpm tokens:tailwind`) to regenerate the spacing steps and palette names in `src/lib/token-scales.generated.ts` and the CSS; the CSS is copied into the `@nxds/tailwind` package. A new or renamed token file also needs an import in `src/catalogue/token-files.ts`; `pnpm test:unit` fails until the manifest matches the files on disk.
|
|
@@ -2531,10 +2531,33 @@ var color_default = {
|
|
|
2531
2531
|
}
|
|
2532
2532
|
};
|
|
2533
2533
|
|
|
2534
|
+
// src/lib/token-scales.generated.ts
|
|
2535
|
+
var PRIMITIVE_PALETTE_NAMES = [
|
|
2536
|
+
"green",
|
|
2537
|
+
"emerald",
|
|
2538
|
+
"teal",
|
|
2539
|
+
"cyan",
|
|
2540
|
+
"sky",
|
|
2541
|
+
"indigo",
|
|
2542
|
+
"violet",
|
|
2543
|
+
"purple",
|
|
2544
|
+
"fuchsia",
|
|
2545
|
+
"pink",
|
|
2546
|
+
"slate",
|
|
2547
|
+
"rose",
|
|
2548
|
+
"lime",
|
|
2549
|
+
"yellow",
|
|
2550
|
+
"blue",
|
|
2551
|
+
"gray",
|
|
2552
|
+
"zinc",
|
|
2553
|
+
"neutral",
|
|
2554
|
+
"stone",
|
|
2555
|
+
"red",
|
|
2556
|
+
"orange",
|
|
2557
|
+
"amber"
|
|
2558
|
+
];
|
|
2559
|
+
|
|
2534
2560
|
// src/lib/primitive-palette.ts
|
|
2535
|
-
var PRIMITIVE_PALETTE_NAMES = Object.keys(color_default).filter(
|
|
2536
|
-
(name) => name !== "white" && name !== "black"
|
|
2537
|
-
);
|
|
2538
2561
|
var rampCache = /* @__PURE__ */ new Map();
|
|
2539
2562
|
function getPaletteRamp(palette) {
|
|
2540
2563
|
if (!PRIMITIVE_PALETTE_NAMES.includes(palette)) {
|
|
@@ -3197,6 +3220,15 @@ function formatShadowStyle(tokenPath, value, primitiveMap) {
|
|
|
3197
3220
|
const isInset = tokenPath.length === 1 && tokenPath[0] === "inner";
|
|
3198
3221
|
return formatShadowComposite(value, primitiveMap, isInset);
|
|
3199
3222
|
}
|
|
3223
|
+
function inlineVariables(value, values) {
|
|
3224
|
+
return value.replace(/var\((--[\w-]+)\)/g, (reference, name) => {
|
|
3225
|
+
const literal = values.get(name);
|
|
3226
|
+
if (literal === void 0) {
|
|
3227
|
+
throw new Error(`inlineVariables: ${reference} has no value`);
|
|
3228
|
+
}
|
|
3229
|
+
return literal;
|
|
3230
|
+
});
|
|
3231
|
+
}
|
|
3200
3232
|
var TYPOGRAPHY_PROPERTIES = [
|
|
3201
3233
|
["fontFamily", "font-family"],
|
|
3202
3234
|
["fontSize", "font-size"],
|
|
@@ -11237,21 +11269,46 @@ function typographyStyleEntry(lookup) {
|
|
|
11237
11269
|
};
|
|
11238
11270
|
};
|
|
11239
11271
|
}
|
|
11240
|
-
function
|
|
11241
|
-
|
|
11272
|
+
function shadowLayerSets(layers, lookup) {
|
|
11273
|
+
const sets = /* @__PURE__ */ new Map();
|
|
11274
|
+
for (const { preset, mode, leaf } of layers) {
|
|
11275
|
+
const key = `${preset}/${mode}`;
|
|
11276
|
+
const set = sets.get(key) ?? { preset, mode, values: /* @__PURE__ */ new Map() };
|
|
11277
|
+
set.values.set(
|
|
11278
|
+
primitiveName("shadow", leaf.path),
|
|
11279
|
+
resolveValue(leaf.value, lookup, leaf.type, leaf.path)
|
|
11280
|
+
);
|
|
11281
|
+
sets.set(key, set);
|
|
11282
|
+
}
|
|
11283
|
+
return [...sets.values()];
|
|
11284
|
+
}
|
|
11285
|
+
function shadowStyleTokens(layers, lookup) {
|
|
11286
|
+
const sets = shadowLayerSets(layers, lookup);
|
|
11287
|
+
return styleLeaves("shadow", SHADOW_STYLES_FILE).map(({ leaf }) => {
|
|
11242
11288
|
const key = pathToCssVarPrefixed(leaf.path, "shadow");
|
|
11243
|
-
const
|
|
11289
|
+
const name = `--nx-${key}`;
|
|
11290
|
+
const composite = formatShadowStyle(leaf.path, leaf.value, lookup);
|
|
11244
11291
|
return {
|
|
11245
|
-
name
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11292
|
+
name,
|
|
11293
|
+
family: "shadow",
|
|
11294
|
+
group: leafGroup("shadow", leaf.path),
|
|
11295
|
+
type: leaf.type,
|
|
11296
|
+
description: leaf.description ?? null,
|
|
11297
|
+
aliases: [cssVariable(`--${key}`)],
|
|
11298
|
+
control: PRESET_CONTROLS.shadow ?? null,
|
|
11299
|
+
variants: sets.map(({ preset, mode, values }) => ({
|
|
11300
|
+
mode,
|
|
11301
|
+
preset,
|
|
11302
|
+
source: { file: SHADOW_STYLES_FILE, path: leaf.path },
|
|
11303
|
+
appearance: null,
|
|
11304
|
+
authoredValue: structuredClone(leaf.value),
|
|
11305
|
+
declarations: [
|
|
11306
|
+
{ property: name, value: inlineVariables(composite, values) }
|
|
11307
|
+
],
|
|
11308
|
+
references: []
|
|
11309
|
+
}))
|
|
11253
11310
|
};
|
|
11254
|
-
};
|
|
11311
|
+
});
|
|
11255
11312
|
}
|
|
11256
11313
|
function styleLeaves(family, file) {
|
|
11257
11314
|
return fileLeaves(family, file, SINGLE_SOURCE).filter(
|
|
@@ -11313,8 +11370,13 @@ function runtimeColorTokens() {
|
|
|
11313
11370
|
function createTokenCatalogue() {
|
|
11314
11371
|
const primitives = PRIMITIVE_FAMILIES.flatMap(primitiveLeaves);
|
|
11315
11372
|
const lookup = primitiveLookup(primitives);
|
|
11373
|
+
const shadowLayers = primitives.filter(({ family }) => family === "shadow");
|
|
11316
11374
|
return [
|
|
11317
|
-
...authoredTokens(
|
|
11375
|
+
...authoredTokens(
|
|
11376
|
+
primitives.filter((leaf) => leaf.family !== "shadow"),
|
|
11377
|
+
lookup,
|
|
11378
|
+
primitiveEntry(lookup)
|
|
11379
|
+
),
|
|
11318
11380
|
...runtimeColorTokens(),
|
|
11319
11381
|
...authoredTokens(spacingLeaves(), lookup, spacingEntry),
|
|
11320
11382
|
...authoredTokens(
|
|
@@ -11332,11 +11394,7 @@ function createTokenCatalogue() {
|
|
|
11332
11394
|
lookup,
|
|
11333
11395
|
typographyStyleEntry(lookup)
|
|
11334
11396
|
),
|
|
11335
|
-
...
|
|
11336
|
-
styleLeaves("shadow", SHADOW_STYLES_FILE),
|
|
11337
|
-
lookup,
|
|
11338
|
-
shadowStyleEntry(lookup)
|
|
11339
|
-
)
|
|
11397
|
+
...shadowStyleTokens(shadowLayers, lookup)
|
|
11340
11398
|
];
|
|
11341
11399
|
}
|
|
11342
11400
|
// Annotate the CommonJS export names for ESM import in node:
|