@7onic-ui/tokens 0.3.2 → 0.3.4
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/cli/sync.js +76 -33
- package/css/variables.css +7 -1
- package/llms.txt +11 -0
- package/package.json +1 -1
package/cli/sync.js
CHANGED
|
@@ -915,6 +915,39 @@ function generateVariablesCss(tokens) {
|
|
|
915
915
|
lines.push(``);
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
|
+
lines.push(`/* ========================================`);
|
|
919
|
+
lines.push(` Framework Compat Aliases`);
|
|
920
|
+
lines.push(` Maps Next.js 15 / Tailwind v4 convention`);
|
|
921
|
+
lines.push(` (--background, --foreground) to our tokens.`);
|
|
922
|
+
lines.push(` ======================================== */`);
|
|
923
|
+
lines.push(``);
|
|
924
|
+
lines.push(`html:root {`);
|
|
925
|
+
lines.push(` --background: var(--color-background);`);
|
|
926
|
+
lines.push(` --foreground: var(--color-text);`);
|
|
927
|
+
lines.push(` color-scheme: light dark;`);
|
|
928
|
+
lines.push(`}`);
|
|
929
|
+
lines.push(``);
|
|
930
|
+
lines.push(`/* ========================================`);
|
|
931
|
+
lines.push(` Body Baseline`);
|
|
932
|
+
lines.push(` Overrides framework default body rules.`);
|
|
933
|
+
lines.push(` ======================================== */`);
|
|
934
|
+
lines.push(``);
|
|
935
|
+
lines.push(`html body {`);
|
|
936
|
+
lines.push(` background-color: var(--color-background);`);
|
|
937
|
+
lines.push(` color: var(--color-foreground);`);
|
|
938
|
+
lines.push(` font-family: var(--font-family-sans);`);
|
|
939
|
+
lines.push(` display: block;`);
|
|
940
|
+
lines.push(` place-items: initial;`);
|
|
941
|
+
lines.push(` min-width: auto;`);
|
|
942
|
+
lines.push(` margin: 0;`);
|
|
943
|
+
lines.push(`}`);
|
|
944
|
+
lines.push(``);
|
|
945
|
+
lines.push(`html body code,`);
|
|
946
|
+
lines.push(`html body pre,`);
|
|
947
|
+
lines.push(`html body kbd {`);
|
|
948
|
+
lines.push(` font-family: var(--font-family-mono);`);
|
|
949
|
+
lines.push(`}`);
|
|
950
|
+
lines.push(``);
|
|
918
951
|
return lines.join("\n");
|
|
919
952
|
}
|
|
920
953
|
function generateThemeLight(tokens) {
|
|
@@ -926,7 +959,7 @@ function generateThemeLight(tokens) {
|
|
|
926
959
|
lines.push(` * Usage: @import '@7onic-ui/tokens/css/themes/light.css';`);
|
|
927
960
|
lines.push(` */`);
|
|
928
961
|
lines.push(``);
|
|
929
|
-
lines.push(
|
|
962
|
+
lines.push(`html:root {`);
|
|
930
963
|
const lightColor = tokens.light.color;
|
|
931
964
|
const semanticColorOrder = orderedKeys(lightColor, { type: "known", order: KNOWN_ORDERS.semanticColorCategories }, "light.color");
|
|
932
965
|
for (const category of semanticColorOrder) {
|
|
@@ -1007,13 +1040,13 @@ function generateThemeDark(tokens) {
|
|
|
1007
1040
|
const declarations = declLines.join("\n");
|
|
1008
1041
|
const mediaDeclarations = declLines.map((l) => l ? ` ${l}` : l).join("\n");
|
|
1009
1042
|
lines.push(`@media (prefers-color-scheme: dark) {`);
|
|
1010
|
-
lines.push(` :root:not([data-theme="light"]) {`);
|
|
1043
|
+
lines.push(` html:root:not([data-theme="light"]) {`);
|
|
1011
1044
|
lines.push(mediaDeclarations);
|
|
1012
1045
|
lines.push(` }`);
|
|
1013
1046
|
lines.push(`}`);
|
|
1014
1047
|
lines.push(``);
|
|
1015
|
-
lines.push(
|
|
1016
|
-
lines.push(
|
|
1048
|
+
lines.push(`html:root[data-theme="dark"],`);
|
|
1049
|
+
lines.push(`html:root.dark {`);
|
|
1017
1050
|
lines.push(declarations);
|
|
1018
1051
|
lines.push(`}`);
|
|
1019
1052
|
lines.push(``);
|
|
@@ -1909,7 +1942,7 @@ function generateV3Preset(tokens) {
|
|
|
1909
1942
|
}
|
|
1910
1943
|
const scaleData = p.scale;
|
|
1911
1944
|
lines.push(` scale: {`);
|
|
1912
|
-
for (const
|
|
1945
|
+
for (const name of Object.keys(scaleData)) {
|
|
1913
1946
|
if (name.startsWith("$")) continue;
|
|
1914
1947
|
lines.push(` '${name}': 'var(--scale-${name})',`);
|
|
1915
1948
|
}
|
|
@@ -2314,7 +2347,7 @@ function generateV4Theme(tokens) {
|
|
|
2314
2347
|
lines.push(``);
|
|
2315
2348
|
lines.push(`/* Scale \u2014 var() references to variables.css */`);
|
|
2316
2349
|
const v4ScaleData = p.scale;
|
|
2317
|
-
for (const
|
|
2350
|
+
for (const name of Object.keys(v4ScaleData)) {
|
|
2318
2351
|
if (name.startsWith("$")) continue;
|
|
2319
2352
|
lines.push(`@utility scale-${name} {`);
|
|
2320
2353
|
lines.push(` scale: var(--scale-${name});`);
|
|
@@ -2570,7 +2603,7 @@ Options:
|
|
|
2570
2603
|
--help, -h Show this help message
|
|
2571
2604
|
|
|
2572
2605
|
Generated files:
|
|
2573
|
-
css/variables.css All CSS custom properties
|
|
2606
|
+
css/variables.css All CSS custom properties + framework baseline (html body reset)
|
|
2574
2607
|
css/themes/light.css Light theme semantic colors
|
|
2575
2608
|
css/themes/dark.css Dark theme semantic colors
|
|
2576
2609
|
css/all.css All-in-one CSS bundle
|
|
@@ -2592,7 +2625,20 @@ function writeOutputFile(outputDir, relativePath, content) {
|
|
|
2592
2625
|
if (!fs2.existsSync(dir)) {
|
|
2593
2626
|
fs2.mkdirSync(dir, { recursive: true });
|
|
2594
2627
|
}
|
|
2628
|
+
let status;
|
|
2629
|
+
if (!fs2.existsSync(fullPath)) {
|
|
2630
|
+
status = "new";
|
|
2631
|
+
} else {
|
|
2632
|
+
const existing = fs2.readFileSync(fullPath, "utf-8");
|
|
2633
|
+
status = existing === content ? "unchanged" : "updated";
|
|
2634
|
+
}
|
|
2595
2635
|
fs2.writeFileSync(fullPath, content);
|
|
2636
|
+
return status;
|
|
2637
|
+
}
|
|
2638
|
+
function formatStatusBadge(status) {
|
|
2639
|
+
if (status === "new") return "(NEW)";
|
|
2640
|
+
if (status === "updated") return "(updated)";
|
|
2641
|
+
return "(unchanged)";
|
|
2596
2642
|
}
|
|
2597
2643
|
async function cliMain() {
|
|
2598
2644
|
const opts = parseArgs(process.argv);
|
|
@@ -2677,36 +2723,33 @@ async function cliMain() {
|
|
|
2677
2723
|
console.log("\n\u2705 Dry run complete.");
|
|
2678
2724
|
return;
|
|
2679
2725
|
}
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2726
|
+
const statuses = [
|
|
2727
|
+
{ label: "css/variables.css", status: writeOutputFile(outputDir, "css/variables.css", variablesCss) },
|
|
2728
|
+
{ label: "css/themes/light.css", status: writeOutputFile(outputDir, "css/themes/light.css", themeLight) },
|
|
2729
|
+
{ label: "css/themes/dark.css", status: writeOutputFile(outputDir, "css/themes/dark.css", themeDark) },
|
|
2730
|
+
{ label: "tailwind/v3-preset.js", status: writeOutputFile(outputDir, "tailwind/v3-preset.js", v3Preset) },
|
|
2731
|
+
{ label: "tailwind/v4-theme.css", status: writeOutputFile(outputDir, "tailwind/v4-theme.css", v4Theme) },
|
|
2732
|
+
{ label: "js/index.js", status: writeOutputFile(outputDir, "js/index.js", jsTokens.cjs) },
|
|
2733
|
+
{ label: "js/index.mjs", status: writeOutputFile(outputDir, "js/index.mjs", jsTokens.esm) },
|
|
2734
|
+
{ label: "types/index.d.ts", status: writeOutputFile(outputDir, "types/index.d.ts", typeDefs) },
|
|
2735
|
+
{ label: "json/tokens.json", status: writeOutputFile(outputDir, "json/tokens.json", normalizedJson) },
|
|
2736
|
+
{ label: "css/all.css (bundle)", status: writeOutputFile(outputDir, "css/all.css", cssBundle) },
|
|
2737
|
+
{ label: "tailwind/v4.css (bundle)", status: writeOutputFile(outputDir, "tailwind/v4.css", v4Bundle) }
|
|
2738
|
+
];
|
|
2691
2739
|
if (deprecatedCss) {
|
|
2692
|
-
writeOutputFile(outputDir, "css/deprecated.css", deprecatedCss);
|
|
2740
|
+
const depStatus = writeOutputFile(outputDir, "css/deprecated.css", deprecatedCss);
|
|
2741
|
+
statuses.push({ label: "css/deprecated.css (backwards compat)", status: depStatus });
|
|
2693
2742
|
}
|
|
2694
2743
|
printTokenWarnings(tokenWarnings);
|
|
2744
|
+
const newCount = statuses.filter((s) => s.status === "new").length;
|
|
2745
|
+
const updatedCount = statuses.filter((s) => s.status === "updated").length;
|
|
2746
|
+
const unchangedCount = statuses.filter((s) => s.status === "unchanged").length;
|
|
2695
2747
|
console.log("");
|
|
2696
|
-
console.log(
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
console.log(` \u{1F4C4} ${path2.relative(".", path2.join(outputDir, "tailwind/v4-theme.css"))}`);
|
|
2702
|
-
console.log(` \u{1F4C4} ${path2.relative(".", path2.join(outputDir, "js/index.js"))}`);
|
|
2703
|
-
console.log(` \u{1F4C4} ${path2.relative(".", path2.join(outputDir, "js/index.mjs"))}`);
|
|
2704
|
-
console.log(` \u{1F4C4} ${path2.relative(".", path2.join(outputDir, "types/index.d.ts"))}`);
|
|
2705
|
-
console.log(` \u{1F4C4} ${path2.relative(".", path2.join(outputDir, "json/tokens.json"))}`);
|
|
2706
|
-
console.log(` \u{1F4C4} ${path2.relative(".", path2.join(outputDir, "css/all.css"))} (bundle)`);
|
|
2707
|
-
console.log(` \u{1F4C4} ${path2.relative(".", path2.join(outputDir, "tailwind/v4.css"))} (bundle)`);
|
|
2708
|
-
if (deprecatedCss) {
|
|
2709
|
-
console.log(` \u{1F4C4} ${path2.relative(".", path2.join(outputDir, "css/deprecated.css"))} (backwards compat)`);
|
|
2748
|
+
console.log(`\u2705 sync-tokens complete: ${newCount} new, ${updatedCount} updated, ${unchangedCount} unchanged`);
|
|
2749
|
+
for (const { label, status } of statuses) {
|
|
2750
|
+
const fullLabel = path2.relative(".", path2.join(outputDir, label.replace(/ \(.*\)/, "")));
|
|
2751
|
+
const suffix = label.includes("(bundle)") ? " (bundle)" : label.includes("(backwards compat)") ? " (backwards compat)" : "";
|
|
2752
|
+
console.log(` \u{1F4C4} ${fullLabel}${suffix} ${formatStatusBadge(status)}`);
|
|
2710
2753
|
}
|
|
2711
2754
|
}
|
|
2712
2755
|
cliMain().catch((err) => {
|
package/css/variables.css
CHANGED
|
@@ -951,10 +951,16 @@ html:root {
|
|
|
951
951
|
|
|
952
952
|
html body {
|
|
953
953
|
background-color: var(--color-background);
|
|
954
|
-
color: var(--
|
|
954
|
+
color: var(--foreground);
|
|
955
955
|
font-family: var(--font-family-sans);
|
|
956
956
|
display: block;
|
|
957
957
|
place-items: initial;
|
|
958
958
|
min-width: auto;
|
|
959
959
|
margin: 0;
|
|
960
960
|
}
|
|
961
|
+
|
|
962
|
+
html body code,
|
|
963
|
+
html body pre,
|
|
964
|
+
html body kbd {
|
|
965
|
+
font-family: var(--font-family-mono);
|
|
966
|
+
}
|
package/llms.txt
CHANGED
|
@@ -78,6 +78,17 @@ module.exports = {
|
|
|
78
78
|
<body class="bg-background text-foreground">
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
+
**Font baseline (automatic — do NOT add manually):**
|
|
82
|
+
`variables.css` import automatically applies:
|
|
83
|
+
- `html body { font-family: var(--font-family-sans) }` — Inter by default
|
|
84
|
+
- `html body code, pre, kbd { font-family: var(--font-family-mono) }` — monospace
|
|
85
|
+
|
|
86
|
+
Do NOT write `body { font-family: ... }` manually — it is already handled by the token import.
|
|
87
|
+
To use a custom font, override the CSS variable instead:
|
|
88
|
+
```css
|
|
89
|
+
:root { --font-family-sans: 'Your Font', sans-serif; }
|
|
90
|
+
```
|
|
91
|
+
|
|
81
92
|
**2-4. Apply user's answers:**
|
|
82
93
|
|
|
83
94
|
- Dark mode = yes → implement dark mode toggle (see below)
|
package/package.json
CHANGED