swatchkit 1.0.0 → 1.0.1
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 +31 -10
- package/package.json +1 -1
package/build.js
CHANGED
|
@@ -222,7 +222,7 @@ function buildInitManifest(settings) {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
// Template files (swatchkit/tokens/)
|
|
225
|
-
const templateFiles = ["prose.html"
|
|
225
|
+
const templateFiles = ["prose.html"];
|
|
226
226
|
for (const file of templateFiles) {
|
|
227
227
|
manifest.push({
|
|
228
228
|
src: path.join(templatesDir, file),
|
|
@@ -350,17 +350,15 @@ function reportInitStatus(settings) {
|
|
|
350
350
|
|
|
351
351
|
// --- 5. New Command Logic ---
|
|
352
352
|
function generateConfig(cssDir) {
|
|
353
|
-
const isDefaultCssDir = cssDir === './src/css';
|
|
354
353
|
return `// swatchkit.config.js
|
|
355
354
|
module.exports = {
|
|
356
355
|
// Where your CSS lives. SwatchKit scaffolds blueprints here and reads
|
|
357
356
|
// tokens from here when building the pattern library.
|
|
358
357
|
cssDir: "${cssDir}",
|
|
359
358
|
|
|
360
|
-
// Set to
|
|
361
|
-
//
|
|
362
|
-
|
|
363
|
-
cssCopy: ${isDefaultCssDir ? 'false' : 'true'},
|
|
359
|
+
// Set to false if a build tool (Vite, Astro, Eleventy, etc.) is already
|
|
360
|
+
// handling your CSS and you don't need SwatchKit to copy it.
|
|
361
|
+
cssCopy: true,
|
|
364
362
|
|
|
365
363
|
// Where token JSON files live.
|
|
366
364
|
// tokensDir: "./tokens",
|
|
@@ -491,6 +489,23 @@ function runInit(settings, options) {
|
|
|
491
489
|
path.join(settings.cssDir, "utilities"),
|
|
492
490
|
);
|
|
493
491
|
}
|
|
492
|
+
|
|
493
|
+
const cwd2 = process.cwd();
|
|
494
|
+
const tokensDir = path.relative(cwd2, settings.tokensDir);
|
|
495
|
+
console.log(`
|
|
496
|
+
Done! Here's what to do next:
|
|
497
|
+
|
|
498
|
+
1. Edit your design tokens in ${tokensDir}/
|
|
499
|
+
colors.json — your colour palette
|
|
500
|
+
text-sizes.json — fluid type scale
|
|
501
|
+
spacing.json — fluid spacing scale
|
|
502
|
+
fonts.json — font stacks
|
|
503
|
+
text-weights.json — font weights
|
|
504
|
+
|
|
505
|
+
2. Run "swatchkit" to build the pattern library
|
|
506
|
+
|
|
507
|
+
3. Open dist/swatchkit/index.html to view it
|
|
508
|
+
`);
|
|
494
509
|
}
|
|
495
510
|
|
|
496
511
|
// --- 6. Build Logic ---
|
|
@@ -789,13 +804,19 @@ function build(settings) {
|
|
|
789
804
|
});
|
|
790
805
|
|
|
791
806
|
// 6. Write JS Bundle
|
|
807
|
+
// Always prepend the internal token display script (resolves CSS custom
|
|
808
|
+
// property values shown in token documentation pages).
|
|
809
|
+
const tokenDisplayScript = fs.readFileSync(
|
|
810
|
+
path.join(__dirname, "src/templates/script.js"),
|
|
811
|
+
"utf-8",
|
|
812
|
+
);
|
|
813
|
+
const internalScript = `/* --- SwatchKit: token display --- */\n(function() {\n${tokenDisplayScript}\n})();`;
|
|
814
|
+
const allScripts = [internalScript, ...scripts];
|
|
815
|
+
fs.writeFileSync(settings.outputJsFile, allScripts.join("\n"));
|
|
792
816
|
if (scripts.length > 0) {
|
|
793
|
-
fs.writeFileSync(settings.outputJsFile, scripts.join("\n"));
|
|
794
817
|
console.log(
|
|
795
|
-
`Bundled ${scripts.length} scripts to ${settings.outputJsFile}`,
|
|
818
|
+
`Bundled ${scripts.length} swatch scripts to ${settings.outputJsFile}`,
|
|
796
819
|
);
|
|
797
|
-
} else {
|
|
798
|
-
fs.writeFileSync(settings.outputJsFile, "// No swatch scripts found");
|
|
799
820
|
}
|
|
800
821
|
|
|
801
822
|
// 7. Generate preview pages (standalone full-screen view of each swatch)
|