swatchkit 0.0.8 → 0.0.10
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/README.md +5 -12
- package/build.js +40 -15
- 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 }
|
|
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
|
|
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`). |
|
|
@@ -189,15 +191,6 @@ module.exports = {
|
|
|
189
191
|
css: './assets/css',
|
|
190
192
|
|
|
191
193
|
// Exclude files (supports glob patterns)
|
|
192
|
-
exclude: ['*.test.js', 'temp*']
|
|
193
|
-
|
|
194
|
-
// Override token settings
|
|
195
|
-
tokens: {
|
|
196
|
-
input: './design-tokens', // Where token JSON files live
|
|
197
|
-
leading: {
|
|
198
|
-
ratio: 1.25, // Modular scale ratio
|
|
199
|
-
base: 1
|
|
200
|
-
}
|
|
201
|
-
}
|
|
194
|
+
exclude: ['*.test.js', 'temp*']
|
|
202
195
|
};
|
|
203
196
|
```
|
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
|
/**
|
|
@@ -196,20 +197,7 @@ function runInit(settings, options) {
|
|
|
196
197
|
copyDefault('text-weights.json', 'text-weights.json');
|
|
197
198
|
|
|
198
199
|
// 3. Create Text Leading Token
|
|
199
|
-
|
|
200
|
-
if (!fs.existsSync(leadingFile)) {
|
|
201
|
-
const srcPath = path.join(__dirname, 'src/blueprints/text-leading.json');
|
|
202
|
-
let sampleLeading = JSON.parse(fs.readFileSync(srcPath, 'utf-8'));
|
|
203
|
-
|
|
204
|
-
// Get settings from config or defaults
|
|
205
|
-
const leadingConfig = settings.fileConfig?.tokens?.leading || {};
|
|
206
|
-
if (leadingConfig.base) sampleLeading.base = leadingConfig.base;
|
|
207
|
-
if (leadingConfig.ratio) sampleLeading.ratio = leadingConfig.ratio;
|
|
208
|
-
if (leadingConfig.items) sampleLeading.items = leadingConfig.items;
|
|
209
|
-
|
|
210
|
-
fs.writeFileSync(leadingFile, JSON.stringify(sampleLeading, null, 2));
|
|
211
|
-
console.log(`Created sample tokens file at ${leadingFile}`);
|
|
212
|
-
}
|
|
200
|
+
copyDefault('text-leading.json', 'text-leading.json');
|
|
213
201
|
|
|
214
202
|
// 4. Create Viewports Token
|
|
215
203
|
copyDefault('viewports.json', 'viewports.json');
|
|
@@ -479,6 +467,43 @@ function build(settings) {
|
|
|
479
467
|
console.log(`Build complete! Generated ${settings.outputFile}`);
|
|
480
468
|
}
|
|
481
469
|
|
|
470
|
+
// --- 6. Watch Logic ---
|
|
471
|
+
function watch(settings) {
|
|
472
|
+
const watchPaths = [
|
|
473
|
+
settings.patternsDir,
|
|
474
|
+
settings.tokensDir,
|
|
475
|
+
settings.projectLayout,
|
|
476
|
+
settings.stylesCssFile
|
|
477
|
+
].filter(p => fs.existsSync(p)); // Only watch files that exist
|
|
478
|
+
|
|
479
|
+
console.log("[SwatchKit] Watch mode enabled.");
|
|
480
|
+
console.log("Watching for changes in:");
|
|
481
|
+
watchPaths.forEach(p => console.log(` - ${p}`));
|
|
482
|
+
|
|
483
|
+
let buildTimeout;
|
|
484
|
+
const rebuild = () => {
|
|
485
|
+
if (buildTimeout) clearTimeout(buildTimeout);
|
|
486
|
+
buildTimeout = setTimeout(() => {
|
|
487
|
+
try {
|
|
488
|
+
console.log("[SwatchKit] Change detected. Rebuilding...");
|
|
489
|
+
build(settings);
|
|
490
|
+
} catch (e) {
|
|
491
|
+
console.error("[SwatchKit] Build failed:", e.message);
|
|
492
|
+
}
|
|
493
|
+
}, 100); // 100ms debounce
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
const watcher = chokidar.watch(watchPaths, {
|
|
497
|
+
ignored: /(^|[\/\\])\../, // ignore dotfiles
|
|
498
|
+
persistent: true,
|
|
499
|
+
ignoreInitial: true
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
watcher.on('all', (event, path) => {
|
|
503
|
+
rebuild();
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
482
507
|
// --- Main Execution ---
|
|
483
508
|
try {
|
|
484
509
|
const cliOptions = parseArgs(process.argv);
|
|
@@ -490,7 +515,7 @@ try {
|
|
|
490
515
|
} else {
|
|
491
516
|
build(settings);
|
|
492
517
|
if (cliOptions.watch) {
|
|
493
|
-
|
|
518
|
+
watch(settings);
|
|
494
519
|
}
|
|
495
520
|
}
|
|
496
521
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swatchkit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
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
|
}
|