@nebutra/tokens 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/brand-package/index.d.ts +11 -5
- package/dist/brand-package/index.js +15 -14
- package/dist/brand-package/index.js.map +1 -1
- package/dist/brand-package/use-brand.js +15 -14
- package/dist/brand-package/use-brand.js.map +1 -1
- package/dist/index.js +15 -14
- package/dist/index.js.map +1 -1
- package/dist/values.d.ts +1192 -0
- package/dist/values.js +518 -0
- package/dist/values.js.map +1 -0
- package/package.json +11 -5
- package/recipe.css +28 -2
- package/skins/cosmos.css +8 -8
- package/skins/gsap.css +8 -8
- package/skins/linear.css +8 -8
- package/skins/notion.css +8 -8
- package/skins/raycast.css +8 -8
- package/skins/stripe.css +8 -8
- package/skins/vanta.css +6 -6
- package/skins/vercel.css +8 -8
- package/styles.css +396 -140
package/CHANGELOG.md
CHANGED
|
@@ -43,19 +43,25 @@ type EmitBrandCssMode =
|
|
|
43
43
|
| "scoped";
|
|
44
44
|
interface EmitBrandCssOptions {
|
|
45
45
|
/**
|
|
46
|
-
* `global` (default): `:root` +
|
|
46
|
+
* `global` (default): `:root` + `<root>[data-brand]` — one import recolors the app.
|
|
47
47
|
* Single-mode dark packs also include `.dark`.
|
|
48
48
|
* Dual-mode packs (`modes.light` + `modes.dark`) emit separate light/dark color blocks.
|
|
49
|
-
* `scoped`: only
|
|
49
|
+
* `scoped`: only `<root>[data-brand]` (+ `<root>.dark[data-brand]` when dual).
|
|
50
50
|
*/
|
|
51
51
|
mode?: EmitBrandCssMode;
|
|
52
|
+
/**
|
|
53
|
+
* Element the carrier attaches to. Defaults to `html` — the app-level swap.
|
|
54
|
+
* A subtree preview passes its own root (e.g. `.theme-preview-artboard`) so
|
|
55
|
+
* the emitted CSS cannot leak out of the preview.
|
|
56
|
+
*/
|
|
57
|
+
root?: string;
|
|
52
58
|
}
|
|
53
59
|
/** Global single-skin selector list — single-mode packs only. */
|
|
54
|
-
declare function emitGlobalSkinSelector(brandId: string, darkDefault: boolean): string;
|
|
60
|
+
declare function emitGlobalSkinSelector(brandId: string, darkDefault: boolean, root?: string): string;
|
|
55
61
|
/** Light mode selector (dual-mode). */
|
|
56
|
-
declare function emitLightModeSelector(brandId: string, mode: EmitBrandCssMode): string;
|
|
62
|
+
declare function emitLightModeSelector(brandId: string, mode: EmitBrandCssMode, root?: string): string;
|
|
57
63
|
/** Dark mode selector (dual-mode) — never paints light colors under .dark. */
|
|
58
|
-
declare function emitDarkModeSelector(brandId: string, mode: EmitBrandCssMode): string;
|
|
64
|
+
declare function emitDarkModeSelector(brandId: string, mode: EmitBrandCssMode, root?: string): string;
|
|
59
65
|
/**
|
|
60
66
|
* Emit a single opt-in skin CSS file from a Brand Package.
|
|
61
67
|
*/
|
|
@@ -327,8 +327,8 @@ var GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
|
327
327
|
function withCjkTail(stack) {
|
|
328
328
|
const families = stack.split(",").map((f) => f.trim());
|
|
329
329
|
const cut = families.findIndex((f) => GENERIC_FAMILIES.has(f.replace(/"/g, "")));
|
|
330
|
-
if (cut === -1 || families.some((f) => f.includes("
|
|
331
|
-
const cjk = ['var(--font-
|
|
330
|
+
if (cut === -1 || families.some((f) => f.includes("MiSans"))) return stack;
|
|
331
|
+
const cjk = ['var(--font-misans, "MiSans")', '"PingFang SC"'];
|
|
332
332
|
return [...families.slice(0, cut), ...cjk, ...families.slice(cut)].join(", ");
|
|
333
333
|
}
|
|
334
334
|
function motionVars(motion) {
|
|
@@ -538,24 +538,24 @@ function emitFontFaces(faces) {
|
|
|
538
538
|
}
|
|
539
539
|
return out;
|
|
540
540
|
}
|
|
541
|
-
function emitGlobalSkinSelector(brandId, darkDefault) {
|
|
541
|
+
function emitGlobalSkinSelector(brandId, darkDefault, root = "html") {
|
|
542
542
|
if (darkDefault) {
|
|
543
543
|
return `:root,
|
|
544
544
|
.dark,
|
|
545
|
-
|
|
545
|
+
${root}[data-brand="${brandId}"] {`;
|
|
546
546
|
}
|
|
547
547
|
return `:root,
|
|
548
|
-
|
|
548
|
+
${root}[data-brand="${brandId}"] {`;
|
|
549
549
|
}
|
|
550
|
-
function emitLightModeSelector(brandId, mode) {
|
|
551
|
-
if (mode === "scoped") return
|
|
550
|
+
function emitLightModeSelector(brandId, mode, root = "html") {
|
|
551
|
+
if (mode === "scoped") return `${root}[data-brand="${brandId}"] {`;
|
|
552
552
|
return `:root,
|
|
553
|
-
|
|
553
|
+
${root}[data-brand="${brandId}"] {`;
|
|
554
554
|
}
|
|
555
|
-
function emitDarkModeSelector(brandId, mode) {
|
|
556
|
-
if (mode === "scoped") return
|
|
555
|
+
function emitDarkModeSelector(brandId, mode, root = "html") {
|
|
556
|
+
if (mode === "scoped") return `${root}.dark[data-brand="${brandId}"] {`;
|
|
557
557
|
return `.dark,
|
|
558
|
-
|
|
558
|
+
${root}.dark[data-brand="${brandId}"] {`;
|
|
559
559
|
}
|
|
560
560
|
function neutralRamp(s, r) {
|
|
561
561
|
const hsl = (triple) => `hsl(${triple})`;
|
|
@@ -690,6 +690,7 @@ function emitColorVars(s, r) {
|
|
|
690
690
|
}
|
|
691
691
|
function emitBrandCss(brand, options = {}) {
|
|
692
692
|
const mode = options.mode ?? "global";
|
|
693
|
+
const root = options.root ?? "html";
|
|
693
694
|
const b = normalizeBrandPackage(brand);
|
|
694
695
|
const t = b.typography;
|
|
695
696
|
const dual = isDualModeBrand(b);
|
|
@@ -747,17 +748,17 @@ function emitBrandCss(brand, options = {}) {
|
|
|
747
748
|
...extLines.length ? ["", " /* Taxonomy / decorative (not product CTA) */", ...extLines] : []
|
|
748
749
|
];
|
|
749
750
|
if (dual && b.modes?.light?.semantic && b.modes?.dark?.semantic) {
|
|
750
|
-
parts.push(emitLightModeSelector(b.id, mode));
|
|
751
|
+
parts.push(emitLightModeSelector(b.id, mode, root));
|
|
751
752
|
parts.push(
|
|
752
753
|
...emitColorVars(b.modes.light.semantic, b.modes.light.roles),
|
|
753
754
|
...sharedChrome,
|
|
754
755
|
`}`,
|
|
755
756
|
``
|
|
756
757
|
);
|
|
757
|
-
parts.push(emitDarkModeSelector(b.id, mode));
|
|
758
|
+
parts.push(emitDarkModeSelector(b.id, mode, root));
|
|
758
759
|
parts.push(...emitColorVars(b.modes.dark.semantic, b.modes.dark.roles), `}`, ``);
|
|
759
760
|
} else {
|
|
760
|
-
const selector = mode === "scoped" ?
|
|
761
|
+
const selector = mode === "scoped" ? `${root}[data-brand="${b.id}"] {` : emitGlobalSkinSelector(b.id, b.darkDefault, root);
|
|
761
762
|
parts.push(selector);
|
|
762
763
|
parts.push(...emitColorVars(b.semantic, b.roles), ...sharedChrome, `}`, ``);
|
|
763
764
|
}
|