emily-css 1.0.2 → 1.0.5

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 CHANGED
@@ -152,7 +152,10 @@ Edit `emily.config.json` to customise:
152
152
 
153
153
  "baseUnit": "8px",
154
154
  "baseFontSize": "16px",
155
- "fontFamily": "system-ui",
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
- ## CDN
279
+ ## Fonts
277
280
 
278
- ```html
279
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/emily-css/dist/emily.css">
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emily-css",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
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,11 +9,6 @@
9
9
  "files": [
10
10
  "bin/",
11
11
  "src/",
12
- "dist/emily.css",
13
- "dist/emily.min.css",
14
- "dist/emily.demo.css",
15
- "dist/emily.demo.min.css",
16
- "fonts/",
17
12
  "README.md",
18
13
  "LICENSE"
19
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
- bundled: false,
157
+ googleFont: false,
160
158
  },
161
159
  'inter': {
162
160
  name: 'Inter',
163
161
  stack: '"Inter", system-ui, sans-serif',
164
- bundled: true,
165
- file: '../fonts/inter/Inter-Variable.woff2',
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
- bundled: true,
173
- file: '../fonts/lexend/Lexend-Variable.woff2',
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
- bundled: false,
173
+ googleFont: false,
180
174
  },
181
175
  'mono': {
182
176
  stack: '"Menlo", "Monaco", "Courier New", monospace',
183
- bundled: false,
177
+ googleFont: false,
184
178
  },
185
179
  };
186
180
 
187
181
  function generateFontCSS(config) {
188
- const fontFamily = (config.fontFamily || 'system').toLowerCase();
189
- const preset = FONT_PRESETS[fontFamily] || FONT_PRESETS['system'];
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 (preset.bundled) {
195
- fontFace += `@font-face {\n`;
196
- fontFace += ` font-family: "${preset.name}";\n`;
197
- fontFace += ` src: url("${preset.file}") format("woff2");\n`;
198
- fontFace += ` font-weight: ${preset.weight};\n`;
199
- fontFace += ` font-style: ${preset.style};\n`;
200
- fontFace += ` font-display: swap;\n`;
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 = ` body {\n font-family: ${preset.stack};\n font-synthesis: style;\n }\n`;
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
  }
@@ -949,4 +954,5 @@ module.exports = {
949
954
  generateSpacingUtilities,
950
955
  addStateVariants,
951
956
  addResponsiveVariants,
957
+ generateFontCSS,
952
958
  };
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: 'system-ui',
41
+ fontFamily: { heading: 'lexend', body: 'inter' },
42
42
  customFonts: [],
43
43
  colours,
44
44
  breakpoints: {