swatchkit 1.0.1 → 1.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.
Files changed (2) hide show
  1. package/build.js +31 -2
  2. package/package.json +1 -1
package/build.js CHANGED
@@ -231,6 +231,26 @@ function buildInitManifest(settings) {
231
231
  });
232
232
  }
233
233
 
234
+ // Utility and composition display templates — walk each subfolder
235
+ for (const section of ["utilities", "compositions"]) {
236
+ const sectionSrc = path.join(templatesDir, section);
237
+ if (!fs.existsSync(sectionSrc)) continue;
238
+ const folders = fs.readdirSync(sectionSrc).filter(f =>
239
+ fs.statSync(path.join(sectionSrc, f)).isDirectory()
240
+ );
241
+ for (const folder of folders) {
242
+ const folderSrc = path.join(sectionSrc, folder);
243
+ const files = fs.readdirSync(folderSrc).filter(f => f.endsWith(".html"));
244
+ for (const file of files) {
245
+ manifest.push({
246
+ src: path.join(folderSrc, file),
247
+ dest: path.join(settings.swatchkitDir, section, folder, file),
248
+ transform: (content) => content.trim(),
249
+ });
250
+ }
251
+ }
252
+ }
253
+
234
254
  // CSS entry point
235
255
  manifest.push({
236
256
  src: path.join(blueprintsDir, "main.css"),
@@ -279,6 +299,8 @@ function getInitDirs(settings) {
279
299
  settings.swatchkitDir,
280
300
  settings.tokensDir,
281
301
  path.join(settings.swatchkitDir, "tokens"),
302
+ path.join(settings.swatchkitDir, "utilities"),
303
+ path.join(settings.swatchkitDir, "compositions"),
282
304
  settings.cssDir,
283
305
  path.join(settings.cssDir, "global"),
284
306
  ];
@@ -544,7 +566,7 @@ function scanSwatches(dir, scriptsCollector, exclude = []) {
544
566
  const itemPath = path.join(dir, item);
545
567
  const stat = fs.statSync(itemPath);
546
568
 
547
- let name, content, id;
569
+ let name, content, id, description;
548
570
 
549
571
  // Handle Component Directory
550
572
  if (stat.isDirectory()) {
@@ -555,6 +577,12 @@ function scanSwatches(dir, scriptsCollector, exclude = []) {
555
577
  id = item;
556
578
  content = fs.readFileSync(indexFile, "utf-8");
557
579
 
580
+ // Optional description shown above the iframe in the main UI
581
+ const descriptionFile = path.join(itemPath, "description.html");
582
+ if (fs.existsSync(descriptionFile)) {
583
+ description = fs.readFileSync(descriptionFile, "utf-8");
584
+ }
585
+
558
586
  // Find all .js files
559
587
  const jsFiles = fs
560
588
  .readdirSync(itemPath)
@@ -594,7 +622,7 @@ ${scriptContent}
594
622
  }
595
623
 
596
624
  if (name && content) {
597
- swatches.push({ name, id, content });
625
+ swatches.push({ name, id, content, description: description || null });
598
626
  }
599
627
  });
600
628
 
@@ -791,6 +819,7 @@ function build(settings) {
791
819
  return `
792
820
  <section id="${p.id}" class="region flow">
793
821
  <h2>${p.name} <small style="font-weight: normal; opacity: 0.6; font-size: 0.7em">(${section})</small></h2>
822
+ ${p.description ? `<div class="swatch-description">${p.description}</div>` : ''}
794
823
  <iframe src="${previewPath}" style="width: 100%; border: var(--stroke); min-height: 25rem; resize: vertical; overflow: auto;"></iframe>
795
824
  <div class="swatchkit-preview-link"><a href="${previewLink}">View full screen</a></div>
796
825
  <details>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swatchkit",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "A lightweight tool for creating HTML pattern libraries.",
5
5
  "main": "build.js",
6
6
  "bin": {