shru-design-system 0.1.3 → 0.1.4

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.
@@ -139,21 +139,25 @@
139
139
  if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
140
140
  var enteringColor = key === 'color' && prefix === '';
141
141
  var inColorContext = isColorContext || enteringColor;
142
+
142
143
  if (enteringColor) {
143
144
  flattenToCSS(value, '', result, true);
144
145
  } else if (inColorContext) {
145
146
  flattenToCSS(value, '', result, true);
146
147
  } else {
147
- flattenToCSS(value, prefix ? prefix + '-' + key : key, result, false);
148
+ var newPrefix = prefix ? prefix + '-' + key : key;
149
+ flattenToCSS(value, newPrefix, result, false);
148
150
  }
149
151
  } else {
150
- var cssKey = isColorContext || (prefix === '' && key === 'color')
151
- ? '--' + key
152
- : prefix === ''
153
- ? '--' + key
154
- : '--' + prefix + '-' + key;
152
+ var cssKey;
153
+ if (isColorContext || (prefix === '' && key === 'color')) {
154
+ cssKey = '--' + key;
155
+ } else if (prefix === '') {
156
+ cssKey = '--' + key;
157
+ } else {
158
+ cssKey = '--' + prefix + '-' + key;
159
+ }
155
160
 
156
- // Convert hex colors to HSL format for Tailwind compatibility
157
161
  var finalValue = value;
158
162
  if (isColorContext && typeof value === 'string' && isHexColor(value)) {
159
163
  finalValue = hexToHSL(value);
@@ -176,6 +180,14 @@
176
180
  } else if (cssVars['--spacing-component-md']) {
177
181
  mapped['--spacing'] = cssVars['--spacing-component-md'];
178
182
  }
183
+ if (cssVars['--spacing-component-xs']) mapped['--spacing-component-xs'] = cssVars['--spacing-component-xs'];
184
+ if (cssVars['--spacing-component-sm']) mapped['--spacing-component-sm'] = cssVars['--spacing-component-sm'];
185
+ if (cssVars['--spacing-component-md']) mapped['--spacing-component-md'] = cssVars['--spacing-component-md'];
186
+ if (cssVars['--spacing-component-lg']) mapped['--spacing-component-lg'] = cssVars['--spacing-component-lg'];
187
+ if (cssVars['--spacing-component-xl']) mapped['--spacing-component-xl'] = cssVars['--spacing-component-xl'];
188
+ if (cssVars['--duration-fast']) mapped['--duration-fast'] = cssVars['--duration-fast'];
189
+ if (cssVars['--duration-normal']) mapped['--duration-normal'] = cssVars['--duration-normal'];
190
+ if (cssVars['--duration-slow']) mapped['--duration-slow'] = cssVars['--duration-slow'];
179
191
  return mapped;
180
192
  }
181
193
 
package/scripts/init.js CHANGED
@@ -128,6 +128,18 @@ export default {
128
128
  sans: ["var(--font-sans)", "system-ui", "sans-serif"],
129
129
  body: ["var(--font-body)", "var(--font-sans)", "system-ui", "sans-serif"],
130
130
  },
131
+ spacing: {
132
+ 'component-xs': "var(--spacing-component-xs, 0.25rem)",
133
+ 'component-sm': "var(--spacing-component-sm, 0.5rem)",
134
+ 'component-md': "var(--spacing-component-md, 1rem)",
135
+ 'component-lg': "var(--spacing-component-lg, 1.5rem)",
136
+ 'component-xl': "var(--spacing-component-xl, 2rem)",
137
+ },
138
+ transitionDuration: {
139
+ 'fast': "var(--duration-fast, 150ms)",
140
+ 'normal': "var(--duration-normal, 300ms)",
141
+ 'slow': "var(--duration-slow, 500ms)",
142
+ },
131
143
  },
132
144
  },
133
145
  plugins: [],
@@ -314,19 +326,15 @@ function createTokenFiles() {
314
326
  },
315
327
  "base": "0.25rem"
316
328
  },
317
- "typography": {
318
- "font": {
319
- "body": "var(--font-sans)",
320
- "sans": "var(--font-sans)",
321
- "mono": "var(--font-mono)"
322
- }
329
+ "font": {
330
+ "body": "var(--font-sans)",
331
+ "sans": "var(--font-sans)",
332
+ "mono": "var(--font-mono)"
323
333
  },
324
- "shape": {
325
- "radius": {
326
- "button": "0.375rem",
327
- "card": "0.5rem",
328
- "input": "0.375rem"
329
- }
334
+ "radius": {
335
+ "button": "0.375rem",
336
+ "card": "0.5rem",
337
+ "input": "0.375rem"
330
338
  }
331
339
  };
332
340
  fs.writeFileSync(basePath, JSON.stringify(baseJson, null, 2));
@@ -470,11 +478,9 @@ function createTokenFiles() {
470
478
  if (!fs.existsSync(sansThemePath)) {
471
479
  const sansTheme = {
472
480
  "_createdBy": LIBRARY_NAME,
473
- "typography": {
474
- "font": {
475
- "body": "system-ui, -apple-system, sans-serif",
476
- "sans": "system-ui, -apple-system, sans-serif"
477
- }
481
+ "font": {
482
+ "body": "system-ui, -apple-system, sans-serif",
483
+ "sans": "system-ui, -apple-system, sans-serif"
478
484
  }
479
485
  };
480
486
  fs.writeFileSync(sansThemePath, JSON.stringify(sansTheme, null, 2));
@@ -486,11 +492,9 @@ function createTokenFiles() {
486
492
  if (!fs.existsSync(serifThemePath)) {
487
493
  const serifTheme = {
488
494
  "_createdBy": LIBRARY_NAME,
489
- "typography": {
490
- "font": {
491
- "body": "Georgia, serif",
492
- "sans": "Georgia, serif"
493
- }
495
+ "font": {
496
+ "body": "Georgia, serif",
497
+ "sans": "Georgia, serif"
494
498
  }
495
499
  };
496
500
  fs.writeFileSync(serifThemePath, JSON.stringify(serifTheme, null, 2));
@@ -502,12 +506,10 @@ function createTokenFiles() {
502
506
  if (!fs.existsSync(smoothThemePath)) {
503
507
  const smoothTheme = {
504
508
  "_createdBy": LIBRARY_NAME,
505
- "shape": {
506
- "radius": {
507
- "button": "0.5rem",
508
- "card": "0.75rem",
509
- "input": "0.5rem"
510
- }
509
+ "radius": {
510
+ "button": "0.5rem",
511
+ "card": "0.75rem",
512
+ "input": "0.5rem"
511
513
  }
512
514
  };
513
515
  fs.writeFileSync(smoothThemePath, JSON.stringify(smoothTheme, null, 2));
@@ -519,12 +521,10 @@ function createTokenFiles() {
519
521
  if (!fs.existsSync(sharpThemePath)) {
520
522
  const sharpTheme = {
521
523
  "_createdBy": LIBRARY_NAME,
522
- "shape": {
523
- "radius": {
524
- "button": "0",
525
- "card": "0",
526
- "input": "0"
527
- }
524
+ "radius": {
525
+ "button": "0",
526
+ "card": "0",
527
+ "input": "0"
528
528
  }
529
529
  };
530
530
  fs.writeFileSync(sharpThemePath, JSON.stringify(sharpTheme, null, 2));