emily-css 1.0.3 → 1.0.6
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 +15 -4
- package/bin/emilyui.js +2 -1
- package/package.json +1 -4
- package/src/index.js +35 -26
- package/src/init.js +1 -1
- package/dist/emily.css +0 -23068
- package/dist/emily.min.css +0 -1
- package/fonts/inter/Inter-Variable.woff2 +0 -0
- package/fonts/lexend/Lexend-Variable.woff2 +0 -0
package/README.md
CHANGED
|
@@ -152,7 +152,10 @@ Edit `emily.config.json` to customise:
|
|
|
152
152
|
|
|
153
153
|
"baseUnit": "8px",
|
|
154
154
|
"baseFontSize": "16px",
|
|
155
|
-
"fontFamily":
|
|
155
|
+
"fontFamily": {
|
|
156
|
+
"heading": "lexend",
|
|
157
|
+
"body": "inter"
|
|
158
|
+
},
|
|
156
159
|
|
|
157
160
|
"colours": {
|
|
158
161
|
"primary": "#0077b6",
|
|
@@ -273,12 +276,20 @@ npx emily-css purge
|
|
|
273
276
|
2. Run `npx emily-css build`
|
|
274
277
|
3. No cache invalidation needed
|
|
275
278
|
|
|
276
|
-
##
|
|
279
|
+
## Fonts
|
|
277
280
|
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
Emily includes built-in support for **Inter** and **Lexend** via Google Fonts. Set `fontFamily` in your config and the generated CSS handles the import automatically:
|
|
282
|
+
|
|
283
|
+
```json
|
|
284
|
+
"fontFamily": "inter"
|
|
280
285
|
```
|
|
281
286
|
|
|
287
|
+
```json
|
|
288
|
+
"fontFamily": "lexend"
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
To use your own font, set `fontFamily` to any value (e.g. `"system"` for system-ui), then add your own `@import` or `<link>` to your HTML before loading `emily.css`.
|
|
292
|
+
|
|
282
293
|
## Support
|
|
283
294
|
|
|
284
295
|
- Website: https://www.emilyui.com
|
package/bin/emilyui.js
CHANGED
|
@@ -5,7 +5,8 @@ const command = process.argv[2];
|
|
|
5
5
|
if (command === "init") {
|
|
6
6
|
require("../src/init.js");
|
|
7
7
|
} else if (command === "build") {
|
|
8
|
-
require("../src/index.js");
|
|
8
|
+
const { build } = require("../src/index.js");
|
|
9
|
+
build();
|
|
9
10
|
} else if (command === "purge") {
|
|
10
11
|
require("../src/purge-cmd.js");
|
|
11
12
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emily-css",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "A config-driven utility CSS framework. Define your brand once, generate the CSS.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"bin/",
|
|
11
11
|
"src/",
|
|
12
|
-
"dist/emily.css",
|
|
13
|
-
"dist/emily.min.css",
|
|
14
|
-
"fonts/",
|
|
15
12
|
"README.md",
|
|
16
13
|
"LICENSE"
|
|
17
14
|
],
|
package/src/index.js
CHANGED
|
@@ -151,57 +151,62 @@ function generateSpacing(baseUnit, scale) {
|
|
|
151
151
|
// FONT PRESETS
|
|
152
152
|
// ============================================================================
|
|
153
153
|
|
|
154
|
-
// Bundled fonts live in fonts/{name}/ relative to the package root.
|
|
155
|
-
// The generated CSS lives in dist/, so relative paths use ../fonts/...
|
|
156
154
|
const FONT_PRESETS = {
|
|
157
155
|
'system': {
|
|
158
156
|
stack: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
159
|
-
|
|
157
|
+
googleFont: false,
|
|
160
158
|
},
|
|
161
159
|
'inter': {
|
|
162
160
|
name: 'Inter',
|
|
163
161
|
stack: '"Inter", system-ui, sans-serif',
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
weight: '100 900',
|
|
167
|
-
style: 'normal',
|
|
162
|
+
googleFont: true,
|
|
163
|
+
importUrl: 'https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap',
|
|
168
164
|
},
|
|
169
165
|
'lexend': {
|
|
170
166
|
name: 'Lexend',
|
|
171
167
|
stack: '"Lexend", system-ui, sans-serif',
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
weight: '100 900',
|
|
175
|
-
style: 'normal',
|
|
168
|
+
googleFont: true,
|
|
169
|
+
importUrl: 'https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap',
|
|
176
170
|
},
|
|
177
171
|
'georgia': {
|
|
178
172
|
stack: 'Georgia, "Times New Roman", serif',
|
|
179
|
-
|
|
173
|
+
googleFont: false,
|
|
180
174
|
},
|
|
181
175
|
'mono': {
|
|
182
176
|
stack: '"Menlo", "Monaco", "Courier New", monospace',
|
|
183
|
-
|
|
177
|
+
googleFont: false,
|
|
184
178
|
},
|
|
185
179
|
};
|
|
186
180
|
|
|
187
181
|
function generateFontCSS(config) {
|
|
188
|
-
|
|
189
|
-
const
|
|
182
|
+
// Support both legacy string format and new { heading, body } object format
|
|
183
|
+
const fontConfig = config.fontFamily || 'system';
|
|
184
|
+
let headingKey, bodyKey;
|
|
185
|
+
|
|
186
|
+
if (typeof fontConfig === 'object') {
|
|
187
|
+
headingKey = (fontConfig.heading || 'system').toLowerCase();
|
|
188
|
+
bodyKey = (fontConfig.body || 'system').toLowerCase();
|
|
189
|
+
} else {
|
|
190
|
+
headingKey = fontConfig.toLowerCase();
|
|
191
|
+
bodyKey = fontConfig.toLowerCase();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const headingPreset = FONT_PRESETS[headingKey] || FONT_PRESETS['system'];
|
|
195
|
+
const bodyPreset = FONT_PRESETS[bodyKey] || FONT_PRESETS['system'];
|
|
190
196
|
|
|
191
197
|
let fontFace = '';
|
|
192
198
|
let bodyFont = '';
|
|
193
199
|
|
|
194
|
-
if
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
fontFace +=
|
|
200
|
-
|
|
201
|
-
fontFace += `}\n`;
|
|
202
|
-
}
|
|
200
|
+
// Import Google Fonts — dedupe if heading and body use the same font
|
|
201
|
+
const imports = new Set();
|
|
202
|
+
if (headingPreset.googleFont) imports.add(headingPreset.importUrl);
|
|
203
|
+
if (bodyPreset.googleFont) imports.add(bodyPreset.importUrl);
|
|
204
|
+
imports.forEach(url => {
|
|
205
|
+
fontFace += `@import url("${url}");\n`;
|
|
206
|
+
});
|
|
203
207
|
|
|
204
|
-
bodyFont
|
|
208
|
+
bodyFont += ` body {\n font-family: ${bodyPreset.stack};\n font-synthesis: style;\n }\n`;
|
|
209
|
+
bodyFont += ` h1, h2, h3, h4, h5, h6 {\n font-family: ${headingPreset.stack};\n }\n`;
|
|
205
210
|
|
|
206
211
|
return { fontFace, bodyFont };
|
|
207
212
|
}
|
|
@@ -852,7 +857,10 @@ function build(options = {}) {
|
|
|
852
857
|
// components → reserved for future component styles
|
|
853
858
|
// utilities → generated utility classes (highest priority)
|
|
854
859
|
const { fontFace, bodyFont } = generateFontCSS(config);
|
|
855
|
-
|
|
860
|
+
const fontLabel = typeof config.fontFamily === 'object'
|
|
861
|
+
? 'heading: ' + (config.fontFamily.heading || 'system') + ', body: ' + (config.fontFamily.body || 'system')
|
|
862
|
+
: (config.fontFamily || 'system');
|
|
863
|
+
console.log('✓ Font: ' + fontLabel);
|
|
856
864
|
|
|
857
865
|
const baseCss = `
|
|
858
866
|
/* Box sizing */
|
|
@@ -949,4 +957,5 @@ module.exports = {
|
|
|
949
957
|
generateSpacingUtilities,
|
|
950
958
|
addStateVariants,
|
|
951
959
|
addResponsiveVariants,
|
|
960
|
+
generateFontCSS,
|
|
952
961
|
};
|
package/src/init.js
CHANGED
|
@@ -38,7 +38,7 @@ function createDefaultConfig(name, colours, fonts, baseUnit, sourceDir) {
|
|
|
38
38
|
description: `${name} design system`,
|
|
39
39
|
baseUnit: `${baseUnit}px`,
|
|
40
40
|
baseFontSize: '16px',
|
|
41
|
-
fontFamily: '
|
|
41
|
+
fontFamily: { heading: 'lexend', body: 'inter' },
|
|
42
42
|
customFonts: [],
|
|
43
43
|
colours,
|
|
44
44
|
breakpoints: {
|