swatchkit 0.0.22 → 0.1.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/build.js +14 -7
- package/package.json +1 -1
- package/src/layout.html +1 -1
package/build.js
CHANGED
|
@@ -3,6 +3,7 @@ const fs = require("fs");
|
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const chokidar = require("chokidar");
|
|
5
5
|
const { processTokens } = require("./src/tokens");
|
|
6
|
+
const { generateTokenSwatches } = require("./src/generators");
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* SwatchKit Build Script
|
|
@@ -207,6 +208,8 @@ function runInit(settings, options) {
|
|
|
207
208
|
copyDefault("fonts.json", "fonts.json");
|
|
208
209
|
|
|
209
210
|
// Copy HTML/JS template patterns to swatchkit/tokens/ (UI documentation)
|
|
211
|
+
// Note: Token display templates (colors, typography, spacing, etc.) are
|
|
212
|
+
// generated dynamically at build time from the JSON token files.
|
|
210
213
|
const copyTemplate = (srcFilename, destFilename) => {
|
|
211
214
|
const destPath = path.join(tokensUiDir, destFilename);
|
|
212
215
|
if (!fs.existsSync(destPath)) {
|
|
@@ -217,12 +220,7 @@ function runInit(settings, options) {
|
|
|
217
220
|
}
|
|
218
221
|
};
|
|
219
222
|
|
|
220
|
-
|
|
221
|
-
copyTemplate("text-weights.html", "text-weights.html");
|
|
222
|
-
copyTemplate("text-leading.html", "text-leading.html");
|
|
223
|
-
copyTemplate("typography.html", "typography.html");
|
|
224
|
-
copyTemplate("spacing.html", "spacing.html");
|
|
225
|
-
copyTemplate("fonts.html", "fonts.html");
|
|
223
|
+
// Only copy non-token templates (prose is a kitchen sink, not a token display)
|
|
226
224
|
copyTemplate("prose.html", "prose.html");
|
|
227
225
|
|
|
228
226
|
// Create shared script for tokens UI
|
|
@@ -416,6 +414,15 @@ function build(settings) {
|
|
|
416
414
|
// 2.5 Process Tokens
|
|
417
415
|
processTokens(settings.tokensDir, settings.cssDir);
|
|
418
416
|
|
|
417
|
+
// 2.6 Generate token display HTML from JSON
|
|
418
|
+
const tokensUiDir = path.join(settings.swatchkitDir, "tokens");
|
|
419
|
+
if (fs.existsSync(tokensUiDir)) {
|
|
420
|
+
const generated = generateTokenSwatches(settings.tokensDir, tokensUiDir);
|
|
421
|
+
if (generated > 0) {
|
|
422
|
+
console.log(`Generated ${generated} token display files`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
419
426
|
// 3. Copy CSS files (recursively)
|
|
420
427
|
if (fs.existsSync(settings.cssDir)) {
|
|
421
428
|
console.log("Copying CSS...");
|
|
@@ -537,7 +544,7 @@ function build(settings) {
|
|
|
537
544
|
: `preview/${p.id}.html`;
|
|
538
545
|
|
|
539
546
|
return `
|
|
540
|
-
<section id="${p.id}">
|
|
547
|
+
<section id="${p.id}" class="flow">
|
|
541
548
|
<h2>${p.name} <small style="font-weight: normal; opacity: 0.6; font-size: 0.7em">(${section})</small></h2>
|
|
542
549
|
<div class="preview">${p.content}</div>
|
|
543
550
|
<div class="swatchkit-preview-link"><a href="${previewPath}">View full screen</a></div>
|
package/package.json
CHANGED