swatchkit 0.0.21 → 0.0.23
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 +3 -3
- package/build.js +22 -15
- package/package.json +1 -1
- package/src/layout.html +2 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ my-project/
|
|
|
28
28
|
├── css/
|
|
29
29
|
│ ├── compositions/ # Layout primitives (flow, sidebar, etc.)
|
|
30
30
|
│ ├── tokens.css # Generated from tokens/*.json
|
|
31
|
-
│ ├──
|
|
31
|
+
│ ├── main.css # Main stylesheet (imports tokens + compositions)
|
|
32
32
|
│ └── swatchkit-ui.css # UI styles for the documentation sidebar
|
|
33
33
|
├── swatchkit/
|
|
34
34
|
│ ├── _layout.html # Layout template (you own this)
|
|
@@ -158,7 +158,7 @@ You can mix modular scales with manual overrides.
|
|
|
158
158
|
|
|
159
159
|
### 5. CSS Workflow
|
|
160
160
|
|
|
161
|
-
SwatchKit generates `css/tokens.css` with your design tokens.
|
|
161
|
+
SwatchKit generates `css/tokens.css` with your design tokens. Your `css/main.css` imports this file along with layout primitives:
|
|
162
162
|
|
|
163
163
|
```css
|
|
164
164
|
@import 'tokens.css';
|
|
@@ -170,7 +170,7 @@ body {
|
|
|
170
170
|
}
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
The pattern library uses **your stylesheet** (`
|
|
173
|
+
The pattern library uses **your stylesheet** (`main.css`), so components render exactly as they will in your app.
|
|
174
174
|
|
|
175
175
|
**Documentation Styling:**
|
|
176
176
|
The sidebar and documentation layout are styled by `css/swatchkit-ui.css`. This file is separate from your app styles so you can customize the docs UI without affecting your production CSS.
|
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
|
|
@@ -116,7 +117,7 @@ function resolveSettings(cliOptions, fileConfig) {
|
|
|
116
117
|
? path.resolve(cwd, fileConfig.outDir)
|
|
117
118
|
: path.join(cwd, "public/swatchkit");
|
|
118
119
|
|
|
119
|
-
// CSS directory - where tokens.css and user's
|
|
120
|
+
// CSS directory - where tokens.css and user's main.css live
|
|
120
121
|
// Default: css/ at project root
|
|
121
122
|
const cssDir = fileConfig.cssDir
|
|
122
123
|
? path.resolve(cwd, fileConfig.cssDir)
|
|
@@ -153,7 +154,7 @@ function resolveSettings(cliOptions, fileConfig) {
|
|
|
153
154
|
outputFile: path.join(outDir, "index.html"),
|
|
154
155
|
outputJsFile: path.join(outDir, "js/swatches.js"),
|
|
155
156
|
tokensCssFile: path.join(cssDir, "tokens.css"),
|
|
156
|
-
|
|
157
|
+
mainCssFile: path.join(cssDir, "main.css"),
|
|
157
158
|
};
|
|
158
159
|
}
|
|
159
160
|
|
|
@@ -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
|
|
@@ -234,12 +232,12 @@ function runInit(settings, options) {
|
|
|
234
232
|
console.log(`Created tokens script at ${tokensScriptFile}`);
|
|
235
233
|
}
|
|
236
234
|
|
|
237
|
-
// Create
|
|
238
|
-
if (!fs.existsSync(settings.
|
|
239
|
-
const srcPath = path.join(__dirname, "src/blueprints/
|
|
235
|
+
// Create main.css entry point
|
|
236
|
+
if (!fs.existsSync(settings.mainCssFile)) {
|
|
237
|
+
const srcPath = path.join(__dirname, "src/blueprints/main.css");
|
|
240
238
|
const content = fs.readFileSync(srcPath, "utf-8");
|
|
241
|
-
fs.writeFileSync(settings.
|
|
242
|
-
console.log(`Created
|
|
239
|
+
fs.writeFileSync(settings.mainCssFile, content);
|
|
240
|
+
console.log(`Created main stylesheet at ${settings.mainCssFile}`);
|
|
243
241
|
}
|
|
244
242
|
|
|
245
243
|
// Copy CSS Reset
|
|
@@ -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>
|
|
@@ -637,7 +644,7 @@ function watch(settings) {
|
|
|
637
644
|
settings.swatchkitDir,
|
|
638
645
|
settings.tokensDir,
|
|
639
646
|
settings.projectLayout,
|
|
640
|
-
settings.
|
|
647
|
+
settings.mainCssFile,
|
|
641
648
|
].filter((p) => fs.existsSync(p)); // Only watch files that exist
|
|
642
649
|
|
|
643
650
|
console.log("[SwatchKit] Watch mode enabled.");
|
package/package.json
CHANGED
package/src/layout.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>SwatchKit</title>
|
|
7
|
-
<link rel="stylesheet" href="css/
|
|
7
|
+
<link rel="stylesheet" href="css/main.css" />
|
|
8
8
|
<link rel="stylesheet" href="css/swatchkit-ui.css" />
|
|
9
9
|
<!-- HEAD_EXTRAS -->
|
|
10
10
|
</head>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</header>
|
|
17
17
|
<!-- SIDEBAR_LINKS -->
|
|
18
18
|
</nav>
|
|
19
|
-
<main class="wrapper
|
|
19
|
+
<main class="wrapper">
|
|
20
20
|
<!-- SWATCHES -->
|
|
21
21
|
</main>
|
|
22
22
|
</div>
|