swatchkit 0.0.8 → 0.0.9

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.
Files changed (3) hide show
  1. package/README.md +4 -2
  2. package/build.js +39 -1
  3. package/package.json +5 -2
package/README.md CHANGED
@@ -89,7 +89,8 @@ SwatchKit can auto-calculate fluid typography and spacing scales.
89
89
  { "name": "base", "value": "1rem" }, // Static: 1rem always
90
90
  { "name": "md", "min": 16, "max": 20 }, // Fluid: 16px -> 20px
91
91
  { "name": "lg", "max": 24 }, // Auto: 19.2px -> 24px (24 / 1.25)
92
- { "name": "xl", "min": 32 } // Auto: 32px -> 40px (32 * 1.25)
92
+ { "name": "xl", "min": 32 }, // Auto: 32px -> 40px (32 * 1.25)
93
+ { "name": "jumbo", "max": 64, "fluidRatio": 1.5 } // Auto: 42.6px -> 64px (64 / 1.5)
93
94
  ]
94
95
  }
95
96
  ```
@@ -101,6 +102,7 @@ SwatchKit can auto-calculate fluid typography and spacing scales.
101
102
  --s-md: clamp(1rem, ... , 1.25rem);
102
103
  --s-lg: clamp(1.2rem, ... , 1.5rem);
103
104
  --s-xl: clamp(2rem, ... , 2.5rem);
105
+ --s-jumbo: clamp(2.66rem, ... , 4rem);
104
106
  }
105
107
  ```
106
108
 
@@ -168,7 +170,7 @@ swatchkit [command] [options]
168
170
  ### Flags
169
171
  | Flag | Short | Description |
170
172
  | :--- | :--- | :--- |
171
- | `--watch` | `-w` | Watch mode (coming soon). |
173
+ | `--watch` | `-w` | Watch files and rebuild on change. |
172
174
  | `--config` | `-c` | Path to config file. |
173
175
  | `--input` | `-i` | Pattern directory (Default: `swatches/`). |
174
176
  | `--outDir` | `-o` | Output directory (Default: `public/swatchkit`). |
package/build.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require("fs");
3
3
  const path = require("path");
4
+ const chokidar = require("chokidar");
4
5
  const { processTokens } = require("./src/tokens");
5
6
 
6
7
  /**
@@ -479,6 +480,43 @@ function build(settings) {
479
480
  console.log(`Build complete! Generated ${settings.outputFile}`);
480
481
  }
481
482
 
483
+ // --- 6. Watch Logic ---
484
+ function watch(settings) {
485
+ const watchPaths = [
486
+ settings.patternsDir,
487
+ settings.tokensDir,
488
+ settings.projectLayout,
489
+ settings.stylesCssFile
490
+ ].filter(p => fs.existsSync(p)); // Only watch files that exist
491
+
492
+ console.log("[SwatchKit] Watch mode enabled.");
493
+ console.log("Watching for changes in:");
494
+ watchPaths.forEach(p => console.log(` - ${p}`));
495
+
496
+ let buildTimeout;
497
+ const rebuild = () => {
498
+ if (buildTimeout) clearTimeout(buildTimeout);
499
+ buildTimeout = setTimeout(() => {
500
+ try {
501
+ console.log("[SwatchKit] Change detected. Rebuilding...");
502
+ build(settings);
503
+ } catch (e) {
504
+ console.error("[SwatchKit] Build failed:", e.message);
505
+ }
506
+ }, 100); // 100ms debounce
507
+ };
508
+
509
+ const watcher = chokidar.watch(watchPaths, {
510
+ ignored: /(^|[\/\\])\../, // ignore dotfiles
511
+ persistent: true,
512
+ ignoreInitial: true
513
+ });
514
+
515
+ watcher.on('all', (event, path) => {
516
+ rebuild();
517
+ });
518
+ }
519
+
482
520
  // --- Main Execution ---
483
521
  try {
484
522
  const cliOptions = parseArgs(process.argv);
@@ -490,7 +528,7 @@ try {
490
528
  } else {
491
529
  build(settings);
492
530
  if (cliOptions.watch) {
493
- console.log("[SwatchKit] Watch mode is not yet fully implemented.");
531
+ watch(settings);
494
532
  }
495
533
  }
496
534
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swatchkit",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "A lightweight tool for creating HTML pattern libraries.",
5
5
  "main": "build.js",
6
6
  "bin": {
@@ -23,5 +23,8 @@
23
23
  "bugs": {
24
24
  "url": "https://github.com/cwebley/swatchkit/issues"
25
25
  },
26
- "homepage": "https://github.com/cwebley/swatchkit#readme"
26
+ "homepage": "https://github.com/cwebley/swatchkit#readme",
27
+ "dependencies": {
28
+ "chokidar": "^5.0.0"
29
+ }
27
30
  }