emily-css 1.0.9 → 1.0.15

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/src/generators.js CHANGED
@@ -483,6 +483,38 @@ function containerUtilities() {
483
483
  `;
484
484
  }
485
485
 
486
+ // ============================================================================
487
+ // CODE BLOCK UTILITIES
488
+ // ============================================================================
489
+ // Styles pre/code elements to look like a VSCode Dark+ editor out of the box.
490
+ // All colours are fixed VSCode Dark+ values — not config-driven, because code
491
+ // editor chrome should always look like a code editor regardless of brand.
492
+ function codeUtilities() {
493
+ return `/* Code — window chrome */
494
+ .code-window { border-radius: 8px; overflow: hidden; border: 1px solid #3c3c3c; }
495
+ .code-title-bar { background-color: #2d2d2d; padding: 0.5rem 1rem; display: flex; align-items: center; gap: 0.5rem; border-bottom: 1px solid #3c3c3c; }
496
+ .code-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
497
+ .code-dot-red { background-color: #ff5f57; }
498
+ .code-dot-yellow { background-color: #ffbd2e; }
499
+ .code-dot-green { background-color: #28c840; }
500
+ .code-filename { font-family: "Menlo", "Monaco", "Courier New", monospace; font-size: 0.85rem; color: white; margin-left: 0.5rem; }
501
+
502
+ /* Code — VSCode Dark+ token colours */
503
+ .token-tag { color: #569cd6; }
504
+ .token-attr { color: #9cdcfe; }
505
+ .token-string { color: #ce9178; }
506
+ .token-number { color: #b5cea8; }
507
+ .token-variant { color: #4ec9b0; }
508
+ .token-utility { color: #dcdcaa; }
509
+ .token-colour { color: #6a9955; }
510
+ .token-comment { color: #6a9955; opacity: 0.75; font-style: italic; }
511
+ .token-keyword { color: #c586c0; }
512
+ .token-operator { color: #d4d4d4; }
513
+ .token-line-number { color: #858585; user-select: none; padding-right: 1rem; display: inline-block; min-width: 2rem; text-align: right; }
514
+
515
+ `;
516
+ }
517
+
486
518
  module.exports = {
487
519
  displayUtilities,
488
520
  sizingUtilities,
@@ -502,5 +534,6 @@ module.exports = {
502
534
  blendUtilities,
503
535
  cursorUtilities,
504
536
  accessibilityUtilities,
505
- containerUtilities
537
+ containerUtilities,
538
+ codeUtilities
506
539
  };
package/src/index.js CHANGED
@@ -142,8 +142,9 @@ function generateAllColours(colourConfig) {
142
142
  // ============================================================================
143
143
 
144
144
  function generateSpacing(baseUnit, scale) {
145
- // scale is now a key-value object from config
146
- // Just return it as-is since values are already defined (e.g., "1rem", "4px")
145
+ // Spacing values are defined explicitly in emily.config.json under spacing.scale.
146
+ // The baseUnit key in config is informational only it documents the design intent
147
+ // (e.g. "this system is based on 8px") but does not drive generation.
147
148
  return scale;
148
149
  }
149
150
 
@@ -151,30 +152,40 @@ function generateSpacing(baseUnit, scale) {
151
152
  // FONT PRESETS
152
153
  // ============================================================================
153
154
 
155
+ // Font presets define the CSS font-family stack only.
156
+ // Loading the actual font files is the user's responsibility — link them in your HTML
157
+ // or use @fontsource packages in your build. emily-css does not generate @import rules
158
+ // for external CDNs so it stays self-contained and works offline.
159
+ // See docs: https://emilyui.com/docs/getting-started
154
160
  const FONT_PRESETS = {
155
161
  'system': {
156
162
  stack: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
157
- googleFont: false,
158
163
  },
159
164
  'inter': {
160
165
  name: 'Inter',
161
166
  stack: '"Inter", system-ui, sans-serif',
162
- googleFont: true,
163
- importUrl: 'https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap',
164
167
  },
165
168
  'lexend': {
166
169
  name: 'Lexend',
167
170
  stack: '"Lexend", system-ui, sans-serif',
168
- googleFont: true,
169
- importUrl: 'https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap',
170
171
  },
171
172
  'georgia': {
172
173
  stack: 'Georgia, "Times New Roman", serif',
173
- googleFont: false,
174
+ },
175
+ 'dm-sans': {
176
+ name: 'DM Sans',
177
+ stack: '"DM Sans", system-ui, sans-serif',
178
+ },
179
+ 'nunito': {
180
+ name: 'Nunito',
181
+ stack: '"Nunito", system-ui, sans-serif',
182
+ },
183
+ 'atkinson': {
184
+ name: 'Atkinson Hyperlegible',
185
+ stack: '"Atkinson Hyperlegible", system-ui, sans-serif',
174
186
  },
175
187
  'mono': {
176
188
  stack: '"Menlo", "Monaco", "Courier New", monospace',
177
- googleFont: false,
178
189
  },
179
190
  };
180
191
 
@@ -197,14 +208,6 @@ function generateFontCSS(config) {
197
208
  let fontFace = '';
198
209
  let bodyFont = '';
199
210
 
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
- });
207
-
208
211
  bodyFont += ` body {\n font-family: ${bodyPreset.stack};\n font-synthesis: style;\n }\n`;
209
212
  bodyFont += ` h1, h2, h3, h4, h5, h6 {\n font-family: ${headingPreset.stack};\n }\n`;
210
213
 
@@ -284,7 +287,8 @@ const {
284
287
  blendUtilities,
285
288
  cursorUtilities,
286
289
  accessibilityUtilities,
287
- containerUtilities
290
+ containerUtilities,
291
+ codeUtilities
288
292
  } = require('./generators');
289
293
 
290
294
  // ============================================================================
@@ -471,8 +475,7 @@ function generateTypographyUtilities(config) {
471
475
  css += `.text-right { text-align: right; }\n`;
472
476
  css += `.text-justify { text-align: justify; }\n`;
473
477
 
474
- // Text wrapping
475
- css += `.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n`;
478
+ // Text wrapping (.truncate lives in overflowUtilities in generators.js — not duplicated here)
476
479
  css += `.whitespace-nowrap { white-space: nowrap; }\n`;
477
480
  css += `.whitespace-normal { white-space: normal; }\n`;
478
481
  css += `.break-words { word-break: break-word; }\n`;
@@ -582,7 +585,7 @@ function generateBaseStyles(config) {
582
585
  // Build a lookup map from font size name → CSS variable
583
586
  const fontSizeMap = {};
584
587
  (config.typography?.fontSizes || []).forEach(({ name }) => {
585
- fontSizeMap[name] = `var(--emily-text-${name})`;
588
+ fontSizeMap[name] = `var(--text-${name})`;
586
589
  });
587
590
 
588
591
  // Line height hints per size — keeps headings tighter than body text
@@ -827,6 +830,7 @@ function buildFullFramework() {
827
830
  utilityCss += cursorUtilities();
828
831
  utilityCss += accessibilityUtilities();
829
832
  utilityCss += containerUtilities();
833
+ utilityCss += codeUtilities();
830
834
 
831
835
  // Add state, dark mode, and responsive variants to utilities
832
836
  utilityCss = addStateVariants(utilityCss);
@@ -887,6 +891,38 @@ function buildFullFramework() {
887
891
  p, h1, h2, h3, h4, h5, h6 {
888
892
  overflow-wrap: break-word;
889
893
  }
894
+
895
+ /* Code blocks — VSCode Dark+ style by default */
896
+ pre {
897
+ background-color: #1e1e1e;
898
+ color: #d4d4d4;
899
+ padding: 1.25rem;
900
+ border-radius: 0 0 6px;
901
+ overflow-x: auto;
902
+ font-family: "Menlo", "Monaco", "Courier New", monospace;
903
+ font-size: 0.875rem;
904
+ line-height: 1.7;
905
+ border: 1px solid #333;
906
+ }
907
+
908
+ pre code {
909
+ background: none;
910
+ padding: 0;
911
+ border-radius: 0;
912
+ color: inherit;
913
+ font-size: inherit;
914
+ font-family: inherit;
915
+ }
916
+
917
+ /* Inline code */
918
+ code {
919
+ font-family: "Menlo", "Monaco", "Courier New", monospace;
920
+ font-size: 0.875em;
921
+ background-color: #2d2d2d;
922
+ color: #d4d4d4;
923
+ padding: 0.125rem 0.375rem;
924
+ border-radius: 4px;
925
+ }
890
926
  ${bodyFont}`;
891
927
 
892
928
  // @font-face must sit outside @layer for broadest browser compatibility
@@ -989,8 +1025,12 @@ function build(options = {}) {
989
1025
  console.log('✓ File size: ' + (result.outputSize / 1024).toFixed(2) + ' KB');
990
1026
 
991
1027
  if (!options.keepFull && fs.existsSync(cssPath)) {
992
- fs.unlinkSync(cssPath);
993
- console.log('Removed dist/emily.css for production build.');
1028
+ try {
1029
+ fs.unlinkSync(cssPath);
1030
+ console.log('Removed dist/emily.css for production build.');
1031
+ } catch (e) {
1032
+ // Windows FUSE: can't delete, non-fatal
1033
+ }
994
1034
  }
995
1035
 
996
1036
  console.log('Build complete');
@@ -1018,4 +1058,5 @@ module.exports = {
1018
1058
  addStateVariants,
1019
1059
  addResponsiveVariants,
1020
1060
  generateFontCSS,
1061
+ codeUtilities,
1021
1062
  };