swatchkit 0.0.18 → 0.0.20

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 +19 -11
  2. package/build.js +21 -26
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -20,16 +20,21 @@ This will create:
20
20
 
21
21
  ```
22
22
  my-project/
23
+ ├── tokens/ # Design token definitions (you edit these)
24
+ │ ├── colors.json
25
+ │ ├── fonts.json
26
+ │ ├── spacing.json
27
+ │ └── ...
23
28
  ├── css/
24
29
  │ ├── compositions/ # Layout primitives (flow, sidebar, etc.)
25
- │ ├── tokens.css # Generated design tokens
30
+ │ ├── tokens.css # Generated from tokens/*.json
26
31
  │ ├── styles.css # Starter stylesheet (imports tokens + compositions)
27
32
  │ └── swatchkit-ui.css # UI styles for the documentation sidebar
28
33
  ├── swatchkit/
29
34
  │ ├── _layout.html # Layout template (you own this)
30
- │ └── tokens/ # Token definitions + documentation patterns
31
- │ ├── colors.json
35
+ │ └── tokens/ # Visual documentation for design tokens
32
36
  │ ├── colors.html
37
+ │ ├── typography.html
33
38
  │ └── ...
34
39
  └── public/
35
40
  └── swatchkit/ # Built pattern library
@@ -65,8 +70,9 @@ SwatchKit automatically turns subfolders into sections in the documentation side
65
70
 
66
71
  ```
67
72
  swatchkit/
68
- ├── tokens/ # Section: "Design Tokens"
69
- └── colors.json
73
+ ├── tokens/ # Section: "Design Tokens" (visual previews)
74
+ ├── colors.html
75
+ │ └── typography.html
70
76
  ├── components/ # Section: "Components"
71
77
  │ ├── button.html
72
78
  │ └── card/
@@ -79,11 +85,10 @@ swatchkit/
79
85
 
80
86
  - **Files at root:** Go to the "Patterns" section.
81
87
  - **Subfolders:** Create a new section (e.g. `utilities/` -> "Utilities").
82
- - **Tokens:** Special folder for JSON definitions.
83
88
 
84
89
  ### 2. Design Token Engine
85
90
 
86
- SwatchKit scaffolds a design system for you. Edit the JSON files in `swatchkit/tokens/`, and SwatchKit auto-generates `css/tokens.css`.
91
+ SwatchKit scaffolds a design system for you. Edit the JSON files in `tokens/`, and SwatchKit auto-generates `css/tokens.css`.
87
92
 
88
93
  **Supported Tokens:**
89
94
 
@@ -93,7 +98,7 @@ SwatchKit scaffolds a design system for you. Edit the JSON files in `swatchkit/t
93
98
  - **Modular Leading** (`text-leading.json`): Generates line-heights using `pow()` modular scales.
94
99
  - **Fonts & Weights**: Manages font families and weights.
95
100
 
96
- Documentation patterns for these are automatically created alongside the JSON files.
101
+ Visual documentation patterns for these tokens live in `swatchkit/tokens/` and are created during init.
97
102
 
98
103
  ### 3. Intelligent Fluid Logic (New!)
99
104
 
@@ -105,7 +110,7 @@ SwatchKit can auto-calculate fluid typography and spacing scales.
105
110
  - **Fluid:** Provide `min` and `max` (e.g. `16` and `18`).
106
111
  - **Auto-Fluid:** Provide just ONE side (`min` or `max`), and SwatchKit calculates the other using a default ratio (1.125).
107
112
 
108
- **Example (`swatchkit/tokens/text-sizes.json`):**
113
+ **Example (`tokens/text-sizes.json`):**
109
114
 
110
115
  ```json
111
116
  {
@@ -137,7 +142,7 @@ SwatchKit can auto-calculate fluid typography and spacing scales.
137
142
 
138
143
  You can mix modular scales with manual overrides.
139
144
 
140
- **Example (`swatchkit/tokens/text-leading.json`):**
145
+ **Example (`tokens/text-leading.json`):**
141
146
 
142
147
  ```json
143
148
  {
@@ -225,7 +230,10 @@ module.exports = {
225
230
  outDir: "./dist/patterns",
226
231
 
227
232
  // Override CSS directory
228
- css: "./assets/css",
233
+ cssDir: "./assets/css",
234
+
235
+ // Override tokens directory (JSON token definitions)
236
+ tokensDir: "./src/tokens",
229
237
 
230
238
  // Exclude files (supports glob patterns)
231
239
  exclude: ["*.test.js", "temp*"],
package/build.js CHANGED
@@ -117,16 +117,16 @@ function resolveSettings(cliOptions, fileConfig) {
117
117
  : path.join(cwd, "public/swatchkit");
118
118
 
119
119
  // CSS directory - where tokens.css and user's styles.css live
120
- // Default: css/ at project root (not src/css/)
121
- const cssDir = fileConfig.css
122
- ? path.resolve(cwd, fileConfig.css)
120
+ // Default: css/ at project root
121
+ const cssDir = fileConfig.cssDir
122
+ ? path.resolve(cwd, fileConfig.cssDir)
123
123
  : path.join(cwd, "css");
124
124
 
125
- // Token definitions directory
126
- // Default: swatches/tokens/ (not src/tokens/)
127
- const tokensDir = fileConfig.tokens?.input
128
- ? path.resolve(cwd, fileConfig.tokens.input)
129
- : path.join(swatchkitDir, "tokens");
125
+ // Token definitions directory (JSON files the user edits)
126
+ // Default: tokens/ at project root (separate from swatchkit/ UI)
127
+ const tokensDir = fileConfig.tokensDir
128
+ ? path.resolve(cwd, fileConfig.tokensDir)
129
+ : path.join(cwd, "tokens");
130
130
 
131
131
  // Exclude patterns
132
132
  const exclude = fileConfig.exclude || [];
@@ -164,19 +164,27 @@ function runInit(settings, options) {
164
164
  fs.mkdirSync(settings.swatchkitDir, { recursive: true });
165
165
  }
166
166
 
167
- // Create swatches/tokens directory (for both JSON definitions and HTML patterns)
167
+ // Create tokens/ directory at project root (JSON token definitions)
168
168
  const tokensDir = settings.tokensDir;
169
169
  if (!fs.existsSync(tokensDir)) {
170
170
  console.log(`Creating tokens directory: ${tokensDir}`);
171
171
  fs.mkdirSync(tokensDir, { recursive: true });
172
172
  }
173
173
 
174
+ // Create swatchkit/tokens/ directory (HTML/JS visual previews)
175
+ const tokensUiDir = path.join(settings.swatchkitDir, "tokens");
176
+ if (!fs.existsSync(tokensUiDir)) {
177
+ console.log(`Creating tokens UI directory: ${tokensUiDir}`);
178
+ fs.mkdirSync(tokensUiDir, { recursive: true });
179
+ }
180
+
174
181
  // Create css/ directory at project root
175
182
  if (!fs.existsSync(settings.cssDir)) {
176
183
  console.log(`Creating CSS directory: ${settings.cssDir}`);
177
184
  fs.mkdirSync(settings.cssDir, { recursive: true });
178
185
  }
179
186
 
187
+ // Copy JSON token blueprints to tokens/ (project root)
180
188
  const copyDefault = (srcFilename, destFilename) => {
181
189
  const destPath = path.join(tokensDir, destFilename);
182
190
  if (!fs.existsSync(destPath)) {
@@ -187,29 +195,17 @@ function runInit(settings, options) {
187
195
  }
188
196
  };
189
197
 
190
- // 1. Create Colors Token
191
198
  copyDefault("colors.json", "colors.json");
192
-
193
- // 2. Create Text Weights Token
194
199
  copyDefault("text-weights.json", "text-weights.json");
195
-
196
- // 3. Create Text Leading Token
197
200
  copyDefault("text-leading.json", "text-leading.json");
198
-
199
- // 4. Create Viewports Token
200
201
  copyDefault("viewports.json", "viewports.json");
201
-
202
- // 5. Create Text Sizes Token (Fluid)
203
202
  copyDefault("text-sizes.json", "text-sizes.json");
204
-
205
- // 6. Create Spacing Token
206
203
  copyDefault("spacing.json", "spacing.json");
207
-
208
- // 7. Create Fonts Token
209
204
  copyDefault("fonts.json", "fonts.json");
210
205
 
206
+ // Copy HTML/JS template patterns to swatchkit/tokens/ (UI documentation)
211
207
  const copyTemplate = (srcFilename, destFilename) => {
212
- const destPath = path.join(tokensDir, destFilename);
208
+ const destPath = path.join(tokensUiDir, destFilename);
213
209
  if (!fs.existsSync(destPath)) {
214
210
  const srcPath = path.join(__dirname, "src/templates", srcFilename);
215
211
  const content = fs.readFileSync(srcPath, "utf-8");
@@ -218,7 +214,6 @@ function runInit(settings, options) {
218
214
  }
219
215
  };
220
216
 
221
- // Create sample patterns
222
217
  copyTemplate("colors.html", "colors.html");
223
218
  copyTemplate("text-weights.html", "text-weights.html");
224
219
  copyTemplate("text-leading.html", "text-leading.html");
@@ -226,8 +221,8 @@ function runInit(settings, options) {
226
221
  copyTemplate("spacing.html", "spacing.html");
227
222
  copyTemplate("fonts.html", "fonts.html");
228
223
 
229
- // Create shared script for tokens
230
- const tokensScriptFile = path.join(tokensDir, "script.js");
224
+ // Create shared script for tokens UI
225
+ const tokensScriptFile = path.join(tokensUiDir, "script.js");
231
226
  if (!fs.existsSync(tokensScriptFile)) {
232
227
  const srcPath = path.join(__dirname, "src/templates/script.js");
233
228
  const content = fs.readFileSync(srcPath, "utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swatchkit",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "A lightweight tool for creating HTML pattern libraries.",
5
5
  "main": "build.js",
6
6
  "bin": {