@hkdigital/lib-core 0.3.14 → 0.3.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.
Files changed (44) hide show
  1. package/README.md +12 -3
  2. package/dist/config/README.md +4 -4
  3. package/dist/design/README.md +136 -66
  4. package/dist/design/config/{design-config.d.ts → design-tokens.d.ts} +23 -10
  5. package/dist/design/config/design-tokens.js +107 -0
  6. package/dist/design/generators/index.d.ts +51 -0
  7. package/dist/design/generators/index.js +89 -0
  8. package/dist/design/index.d.ts +3 -4
  9. package/dist/design/index.js +24 -41
  10. package/dist/design/plugins/skeleton.d.ts +4 -2
  11. package/dist/design/plugins/skeleton.js +3 -2
  12. package/dist/design/themes/hkdev/components/buttons/button-text.css +19 -25
  13. package/dist/design/utils/clamp.js +1 -1
  14. package/dist/design/utils/root-vars.d.ts +50 -39
  15. package/dist/design/utils/root-vars.js +127 -29
  16. package/dist/logging/index.d.ts +2 -3
  17. package/dist/logging/index.js +3 -4
  18. package/dist/logging/internal/adapters/console.js +3 -7
  19. package/dist/logging/internal/adapters/pino.js +21 -11
  20. package/dist/logging/internal/factories/client.js +1 -1
  21. package/dist/logging/internal/factories/server.js +1 -1
  22. package/dist/logging/internal/logger/Logger.d.ts +2 -2
  23. package/dist/logging/internal/logger/Logger.js +3 -3
  24. package/dist/services/index.d.ts +0 -2
  25. package/dist/services/index.js +0 -3
  26. package/dist/services/typedef.d.ts +2 -0
  27. package/dist/services/typedef.js +2 -0
  28. package/dist/typedef/index.d.ts +0 -1
  29. package/dist/typedef/index.js +0 -1
  30. package/dist/ui/components/game-box/GameBox.svelte +1 -1
  31. package/dist/ui/primitives/buttons/button-text/TextButton.svelte +1 -1
  32. package/dist/ui/primitives/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +7 -7
  33. package/dist/ui/primitives/index.d.ts +1 -0
  34. package/dist/ui/primitives/index.js +1 -2
  35. package/package.json +2 -2
  36. package/dist/design/config/design-config.js +0 -73
  37. package/dist/design/tailwind-theme-extend.d.ts +0 -23
  38. package/dist/design/tailwind-theme-extend.js +0 -158
  39. package/dist/logging/internal/factories/universal.d.ts +0 -9
  40. package/dist/logging/internal/factories/universal.js +0 -22
  41. /package/dist/logging/{internal/constants.d.ts → constants.d.ts} +0 -0
  42. /package/dist/logging/{internal/constants.js → constants.js} +0 -0
  43. /package/dist/logging/{internal/typedef.d.ts → typedef.d.ts} +0 -0
  44. /package/dist/logging/{internal/typedef.js → typedef.js} +0 -0
package/README.md CHANGED
@@ -88,10 +88,19 @@ For detailed configuration options, see the [config documentation](./src/lib/con
88
88
 
89
89
  ### Import JS, Svelte files and Typedefs
90
90
 
91
- Most subfolders have an index.js that export all functionality and typedefs.
91
+ Main folders in lib have an index.js, but may also have a more specific export file e.g. http.js or cache.js (@see $lib/network).
92
92
 
93
- ```svelte
94
- import { CHAR } from '@hkdigital/lib-core/constants/regexp/index.js';
93
+ Main folders (should) have a typedef.js that can be used in JSdoc comments.
94
+
95
+ ```js
96
+ // Import Latin char constant for use in regular expressions
97
+ import { LCHAR } from '@hkdigital/lib-core/constants/regexp/index.js';
98
+ ```
99
+
100
+ ```js
101
+ /**
102
+ * @param {import('@hkdigital/lib-core/network/typedef.js').JsonGetOptions} JsonGetOptions
103
+ */
95
104
  ```
96
105
 
97
106
  ### Import CSS
@@ -12,7 +12,7 @@ The `vite.js` provides generators for common Vite setups used across HKdigital p
12
12
  // vite.config.js
13
13
  import { defineConfig } from 'vitest/config';
14
14
  import { sveltekit } from '@sveltejs/kit/vite';
15
- import { generateViteConfig } from '@hkdigital/lib-sveltekit/config/vite.js';
15
+ import { generateViteConfig } from '@hkdigital/lib-core/config/vite.js';
16
16
 
17
17
  export default defineConfig(
18
18
  await generateViteConfig({
@@ -106,7 +106,7 @@ pnpm add -D vite-imagetools
106
106
  For TypeScript and JavaScript projects using VS Code or other TypeScript-aware editors, add to your `app.d.ts`:
107
107
 
108
108
  ```typescript
109
- import '@hkdigital/lib-sveltekit/config/imagetools.d.ts';
109
+ import '@hkdigital/lib-core/config/imagetools.d.ts';
110
110
  ```
111
111
 
112
112
  **Why this is needed:**
@@ -157,7 +157,7 @@ import { resolve } from 'path';
157
157
  import {
158
158
  generateDefaultDirectives,
159
159
  generateResponseConfigs
160
- } from '@hkdigital/lib-sveltekit/config/imagetools-config.js';
160
+ } from '@hkdigital/lib-core/config/imagetools-config.js';
161
161
 
162
162
  const packageJson = JSON.parse(
163
163
  readFileSync(resolve('./package.json'), 'utf-8')
@@ -189,7 +189,7 @@ export default defineConfig({
189
189
  // vite.config.js
190
190
  import { defineConfig } from 'vitest/config';
191
191
  import { sveltekit } from '@sveltejs/kit/vite';
192
- import { generateViteConfig } from '@hkdigital/lib-sveltekit/config/vite.js';
192
+ import { generateViteConfig } from '@hkdigital/lib-core/config/vite.js';
193
193
 
194
194
  export default defineConfig(
195
195
  await generateViteConfig()
@@ -9,19 +9,17 @@ A comprehensive, responsive design system built for SvelteKit applications. This
9
9
  ```javascript
10
10
  // tailwind.config.js
11
11
  import {
12
- spacing,
13
- fontSize,
14
- borderRadius,
12
+ generateTailwindThemeExtensions,
13
+ designTokens,
15
14
  customUtilitiesPlugin
16
15
  } from '@hkdigital/lib-core/design/index.js';
17
16
 
17
+ const themeExtensions = generateTailwindThemeExtensions(designTokens);
18
+
19
+ /** @type {import('tailwindcss').Config} \*/
18
20
  export default {
19
21
  theme: {
20
- extend: {
21
- spacing,
22
- fontSize,
23
- borderRadius
24
- }
22
+ extend: themeExtensions
25
23
  },
26
24
  plugins: [
27
25
  customUtilitiesPlugin
@@ -29,14 +27,14 @@ export default {
29
27
  };
30
28
  ```
31
29
 
32
- ```svelte
30
+ ```html
33
31
  <!-- +layout.svelte -->
34
32
  <script>
35
- import { DESIGN, CLAMPING, rootDesignVarsHTML } from '@hkdigital/lib-core/design';
33
+ import { designTokens, designTokensToRootCssVars } from '@hkdigital/lib-core/design/index.js';
36
34
  </script>
37
35
 
38
36
  <svelte:head>
39
- {@html rootDesignVarsHTML(DESIGN, CLAMPING)}
37
+ {@html designTokensToRootCssVars(designTokens)}
40
38
  </svelte:head>
41
39
 
42
40
  {@render children()}
@@ -185,7 +183,7 @@ import {
185
183
  getRootCssDesignWidth,
186
184
  getRootCssDesignHeight,
187
185
  getAllRootScalingVars
188
- } from '@hkdigital/lib-core/design';
186
+ } from '@hkdigital/lib-core/design/index.js';
189
187
 
190
188
  // Get current design dimensions
191
189
  const designWidth = getRootCssDesignWidth(); // 1024
@@ -199,7 +197,7 @@ const scales = getAllRootScalingVars();
199
197
  ### Clamp Utilities
200
198
 
201
199
  ```javascript
202
- import { clamp, getClampParams } from '@hkdigital/lib-core/design';
200
+ import { clamp, getClampParams } from '@hkdigital/lib-core/design/index.js';
203
201
 
204
202
  // Mathematical clamp function
205
203
  const value = clamp(0.5, 0.3, 2.0); // Returns 0.5 (clamped between 0.5 and 2.0)
@@ -212,7 +210,7 @@ const params = getClampParams('scale-ui');
212
210
  ### Component State Classes
213
211
 
214
212
  ```javascript
215
- import { toStateClasses } from '@hkdigital/lib-core/design';
213
+ import { toStateClasses } from '@hkdigital/lib-core/design/index.js';
216
214
 
217
215
  // Generate state classes from object
218
216
  const classes = toStateClasses({
@@ -236,10 +234,10 @@ const classes = toStateClasses({
236
234
  #### Viewport-Based Scaling
237
235
 
238
236
  ```javascript
239
- import { enableScalingUI } from '@hkdigital/lib-core/design';
237
+ import { enableScalingUI, designTokens } from '@hkdigital/lib-core/design/index.js';
240
238
 
241
239
  // Enable automatic viewport scaling
242
- const cleanup = enableScalingUI(DESIGN, CLAMPING);
240
+ const cleanup = enableScalingUI(designTokens.DESIGN, designTokens.CLAMPING);
243
241
 
244
242
  // Call cleanup when component is destroyed
245
243
  onDestroy(cleanup);
@@ -248,23 +246,23 @@ onDestroy(cleanup);
248
246
  #### Container-Based Scaling
249
247
 
250
248
  ```javascript
251
- import { enableContainerScaling } from '@hkdigital/lib-core/design';
249
+ import { enableContainerScaling, designTokens } from '@hkdigital/lib-core/design/index.js';
252
250
 
253
251
  let containerElement;
254
252
 
255
253
  // Enable scaling for specific container
256
254
  const cleanup = enableContainerScaling({
257
255
  container: containerElement,
258
- design: DESIGN,
259
- clamping: CLAMPING,
256
+ design: designTokens.DESIGN,
257
+ clamping: designTokens.CLAMPING,
260
258
  useResizeObserver: true
261
259
  });
262
260
 
263
261
  // Optional custom dimension getter
264
262
  const cleanupCustom = enableContainerScaling({
265
263
  container: containerElement,
266
- design: DESIGN,
267
- clamping: CLAMPING,
264
+ design: designTokens.DESIGN,
265
+ clamping: designTokens.CLAMPING,
268
266
  getDimensions: () => ({ width: 800, height: 600 })
269
267
  });
270
268
  ```
@@ -273,7 +271,7 @@ const cleanupCustom = enableContainerScaling({
273
271
  <!-- Svelte component example -->
274
272
  <script>
275
273
  import { onMount, onDestroy } from 'svelte';
276
- import { enableContainerScaling, DESIGN, CLAMPING } from '@hkdigital/lib-core/design';
274
+ import { enableContainerScaling, designTokens } from '@hkdigital/lib-core/design/index.js';
277
275
 
278
276
  let containerElement;
279
277
  let cleanup;
@@ -281,8 +279,8 @@ const cleanupCustom = enableContainerScaling({
281
279
  onMount(() => {
282
280
  cleanup = enableContainerScaling({
283
281
  container: containerElement,
284
- design: DESIGN,
285
- clamping: CLAMPING
282
+ design: designTokens.DESIGN,
283
+ clamping: designTokens.CLAMPING
286
284
  });
287
285
  });
288
286
 
@@ -302,59 +300,107 @@ const cleanupCustom = enableContainerScaling({
302
300
  ### Custom Design Configuration
303
301
 
304
302
  ```javascript
305
- // your-project/src/lib/design/design-config.js
306
- import {
307
- generateTextBasedSpacing,
308
- generateTextStyles
309
- } from '@hkdigital/lib-core/design';
310
-
311
- // Custom design dimensions
312
- export const CUSTOM_DESIGN = {
313
- width: 1440,
314
- height: 900
315
- };
303
+ // your-project/src/lib/design/design-tokens.js
304
+ export const designTokens = {
305
+ DESIGN: {
306
+ width: 1440,
307
+ height: 900
308
+ },
309
+
310
+ CLAMPING: {
311
+ ui: { min: 0.4, max: 1.8 },
312
+ textBase: { min: 0.8, max: 1.4 },
313
+ textHeading: { min: 0.8, max: 2.0 },
314
+ textUi: { min: 0.6, max: 1.2 }
315
+ },
316
+
317
+ TEXT_POINT_SIZES: [4, 8, 12, 16, 20, 24, 32],
318
+ VIEWPORT_POINT_SIZES: [10, 20, 30, 40, 50, 100, 200],
319
+
320
+ TEXT_BASE_SIZES: {
321
+ sm: { size: 12, lineHeight: 1.4 },
322
+ md: { size: 16, lineHeight: 1.4 },
323
+ lg: { size: 20, lineHeight: 1.4 }
324
+ },
316
325
 
317
- // Custom text sizes
318
- export const CUSTOM_TEXT_SIZES = {
319
- sm: { size: 12, lineHeight: 1.4 },
320
- md: { size: 16, lineHeight: 1.4 },
321
- lg: { size: 20, lineHeight: 1.4 }
326
+ TEXT_HEADING_SIZES: {
327
+ h1: { size: 36, lineHeight: 1.2 },
328
+ h2: { size: 30, lineHeight: 1.2 },
329
+ h3: { size: 26, lineHeight: 1.2 }
330
+ },
331
+
332
+ TEXT_UI_SIZES: {
333
+ sm: { size: 12, lineHeight: 1.2 },
334
+ md: { size: 14, lineHeight: 1.2 },
335
+ lg: { size: 16, lineHeight: 1.2 }
336
+ },
337
+
338
+ RADIUS_SIZES: {
339
+ none: '0px',
340
+ sm: { size: 8 },
341
+ md: { size: 16 },
342
+ lg: { size: 24 },
343
+ full: '9999px'
344
+ },
345
+
346
+ BORDER_WIDTH_SIZES: {
347
+ thin: { size: 1 },
348
+ normal: { size: 2 },
349
+ thick: { size: 3 }
350
+ },
351
+
352
+ STROKE_WIDTH_SIZES: {
353
+ thin: { size: 1 },
354
+ normal: { size: 2 },
355
+ thick: { size: 3 }
356
+ }
322
357
  };
323
358
 
324
- // Generate custom extensions
325
- export const customSpacing = generateTextBasedSpacing([8, 12, 16, 24, 32]);
326
- export const customFontSize = generateTextStyles(CUSTOM_TEXT_SIZES, 'base');
359
+ // your-project/tailwind.config.js
360
+ import { generateTailwindThemeExtensions, customUtilitiesPlugin } from '@hkdigital/lib-core/design/index.js';
361
+ import { designTokens } from './src/lib/design/design-tokens.js';
362
+
363
+ const themeExtensions = generateTailwindThemeExtensions(designTokens);
364
+
365
+ export default {
366
+ theme: {
367
+ extend: themeExtensions
368
+ },
369
+ plugins: [customUtilitiesPlugin]
370
+ };
327
371
  ```
328
372
 
329
373
  ### Available Generator Functions
330
374
 
375
+ Individual generator functions are available for advanced customization:
376
+
331
377
  ```javascript
332
378
  import {
333
- generateTextBasedSpacing, // ut/bt/ht spacing units
334
- generateViewportBasedSpacing, // up/wp/hp spacing units
335
- generateTextStyles, // Complete typography styles
336
- generateBorderRadiusStyles, // Border radius with scaling
337
- generateWidthStyles // Border/stroke width with scaling
338
- } from '@hkdigital/lib-core/design';
379
+ generateTailwindThemeExtensions, // Complete theme extension generator
380
+ generateTextBasedSpacing, // ut/bt/ht spacing units
381
+ generateViewportBasedSpacing, // up/wp/hp spacing units
382
+ generateTextStyles, // Complete typography styles
383
+ generateBorderRadiusStyles, // Border radius with scaling
384
+ generateWidthStyles // Border/stroke width with scaling
385
+ } from '@hkdigital/lib-core/design/index.js';
386
+
387
+ // Example: Generate only spacing for a custom configuration
388
+ const customSpacing = generateTextBasedSpacing([4, 8, 12, 16, 24]);
339
389
  ```
340
390
 
341
- ### Configuration Objects
391
+ ### Default Design Tokens
342
392
 
343
- All configuration objects are exported for customization:
393
+ The default design tokens are available for reference or as a starting point:
344
394
 
345
395
  ```javascript
346
- import {
347
- DESIGN, // { width: 1024, height: 768 }
348
- CLAMPING, // Min/max scale bounds
349
- TEXT_POINT_SIZES, // [1, 2, 4, 6, 8, 10, ...]
350
- VIEWPORT_POINT_SIZES, // [1, 2, 4, 5, 6, 10, ...]
351
- TEXT_BASE_SIZES, // { sm: {...}, md: {...}, lg: {...} }
352
- TEXT_HEADING_SIZES, // { h1: {...}, h2: {...}, ... }
353
- TEXT_UI_SIZES, // { sm: {...}, md: {...}, lg: {...} }
354
- RADIUS_SIZES, // Border radius configurations
355
- BORDER_WIDTH_SIZES, // Border width configurations
356
- STROKE_WIDTH_SIZES // Stroke width configurations
357
- } from '@hkdigital/lib-core/design';
396
+ import { designTokens } from '@hkdigital/lib-core/design/index.js';
397
+
398
+ console.log(designTokens.DESIGN); // { width: 1024, height: 768 }
399
+ console.log(designTokens.CLAMPING); // Min/max scale bounds
400
+ console.log(designTokens.TEXT_POINT_SIZES); // [1, 2, 4, 6, 8, 10, ...]
401
+ console.log(designTokens.VIEWPORT_POINT_SIZES); // [1, 2, 4, 5, 6, 10, ...]
402
+ console.log(designTokens.TEXT_BASE_SIZES); // { sm: {...}, md: {...}, lg: {...} }
403
+ // ... and all other token configurations
358
404
  ```
359
405
 
360
406
  ## Best practices
@@ -393,11 +439,35 @@ If migrating from the old structure:
393
439
 
394
440
  ```javascript
395
441
  // OLD
396
- import { DESIGN } from '$lib/design/design-config.js';
397
- import { customUtilitiesPlugin } from '$lib/design/skeleton.js';
442
+ import {
443
+ spacing,
444
+ fontSize,
445
+ borderRadius,
446
+ customUtilitiesPlugin
447
+ } from '@hkdigital/lib-core/design/index.js';
448
+
449
+ export default {
450
+ theme: {
451
+ extend: { spacing, fontSize, borderRadius }
452
+ },
453
+ plugins: [customUtilitiesPlugin]
454
+ };
398
455
 
399
456
  // NEW
400
- import { DESIGN, customUtilitiesPlugin } from '@hkdigital/lib-core/design';
457
+ import {
458
+ generateTailwindThemeExtensions,
459
+ designTokens,
460
+ customUtilitiesPlugin
461
+ } from '@hkdigital/lib-core/design/index.js';
462
+
463
+ const themeExtensions = generateTailwindThemeExtensions(designTokens);
464
+
465
+ export default {
466
+ theme: {
467
+ extend: themeExtensions
468
+ },
469
+ plugins: [customUtilitiesPlugin]
470
+ };
401
471
  ```
402
472
 
403
473
  ---
@@ -1,8 +1,20 @@
1
- export namespace DESIGN {
1
+ export namespace designTokens {
2
+ export { DESIGN };
3
+ export { CLAMPING };
4
+ export { TEXT_POINT_SIZES };
5
+ export { VIEWPORT_POINT_SIZES };
6
+ export { TEXT_BASE_SIZES };
7
+ export { TEXT_HEADING_SIZES };
8
+ export { TEXT_UI_SIZES };
9
+ export { RADIUS_SIZES };
10
+ export { BORDER_WIDTH_SIZES };
11
+ export { STROKE_WIDTH_SIZES };
12
+ }
13
+ declare namespace DESIGN {
2
14
  let width: number;
3
15
  let height: number;
4
16
  }
5
- export namespace CLAMPING {
17
+ declare namespace CLAMPING {
6
18
  namespace ui {
7
19
  let min: number;
8
20
  let max: number;
@@ -26,9 +38,9 @@ export namespace CLAMPING {
26
38
  export { max_3 as max };
27
39
  }
28
40
  }
29
- export const TEXT_POINT_SIZES: number[];
30
- export const VIEWPORT_POINT_SIZES: number[];
31
- export namespace TEXT_BASE_SIZES {
41
+ declare const TEXT_POINT_SIZES: number[];
42
+ declare const VIEWPORT_POINT_SIZES: number[];
43
+ declare namespace TEXT_BASE_SIZES {
32
44
  namespace sm {
33
45
  let size: number;
34
46
  let lineHeight: number;
@@ -46,7 +58,7 @@ export namespace TEXT_BASE_SIZES {
46
58
  export { lineHeight_2 as lineHeight };
47
59
  }
48
60
  }
49
- export namespace TEXT_HEADING_SIZES {
61
+ declare namespace TEXT_HEADING_SIZES {
50
62
  namespace h1 {
51
63
  let size_3: number;
52
64
  export { size_3 as size };
@@ -78,7 +90,7 @@ export namespace TEXT_HEADING_SIZES {
78
90
  export { lineHeight_7 as lineHeight };
79
91
  }
80
92
  }
81
- export namespace TEXT_UI_SIZES {
93
+ declare namespace TEXT_UI_SIZES {
82
94
  export namespace sm_1 {
83
95
  let size_8: number;
84
96
  export { size_8 as size };
@@ -101,7 +113,7 @@ export namespace TEXT_UI_SIZES {
101
113
  }
102
114
  export { lg_1 as lg };
103
115
  }
104
- export namespace RADIUS_SIZES {
116
+ declare namespace RADIUS_SIZES {
105
117
  export let none: string;
106
118
  export namespace xs {
107
119
  let size_11: number;
@@ -124,7 +136,7 @@ export namespace RADIUS_SIZES {
124
136
  export { lg_2 as lg };
125
137
  export let full: string;
126
138
  }
127
- export namespace BORDER_WIDTH_SIZES {
139
+ declare namespace BORDER_WIDTH_SIZES {
128
140
  namespace thin {
129
141
  let size_15: number;
130
142
  export { size_15 as size };
@@ -138,7 +150,7 @@ export namespace BORDER_WIDTH_SIZES {
138
150
  export { size_17 as size };
139
151
  }
140
152
  }
141
- export namespace STROKE_WIDTH_SIZES {
153
+ declare namespace STROKE_WIDTH_SIZES {
142
154
  export namespace thin_1 {
143
155
  let size_18: number;
144
156
  export { size_18 as size };
@@ -155,3 +167,4 @@ export namespace STROKE_WIDTH_SIZES {
155
167
  }
156
168
  export { thick_1 as thick };
157
169
  }
170
+ export {};
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @fileoverview HKdigital Design Tokens
3
+ *
4
+ * Default design system tokens for the HKdigital design system.
5
+ * These tokens define all the design values used to generate Tailwind theme extensions.
6
+ *
7
+ * Users can create their own design-tokens.js file with custom values
8
+ * and pass it to generateTailwindThemeExtensions().
9
+ */
10
+
11
+ /* == Design dimensions == */
12
+
13
+ const DESIGN = {
14
+ width: 1024,
15
+ height: 768
16
+ };
17
+
18
+ /* == Scaling-clamping behaviour == */
19
+
20
+ const CLAMPING = {
21
+ ui: { min: 0.3, max: 2 },
22
+ textBase: { min: 0.75, max: 1.5 },
23
+ textHeading: { min: 0.75, max: 2.25 },
24
+ textUi: { min: 0.5, max: 1.25 }
25
+ };
26
+
27
+ /* == Text == */
28
+
29
+ const TEXT_POINT_SIZES = [
30
+ 1, 2, 4, 6, 8, 10, 11, 12, 16, 20, 24, 28, 32, 36, 50
31
+ ];
32
+
33
+ const VIEWPORT_POINT_SIZES = [
34
+ 1, 2, 4, 5, 6, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180,
35
+ 200
36
+ ];
37
+
38
+ const TEXT_BASE_SIZES = {
39
+ sm: { size: 14, lineHeight: 1.25 },
40
+ md: { size: 16, lineHeight: 1.25 },
41
+ lg: { size: 18, lineHeight: 1.25 }
42
+ };
43
+
44
+ const TEXT_HEADING_SIZES = {
45
+ h1: { size: 32, lineHeight: 1.25 },
46
+ h2: { size: 28, lineHeight: 1.25 },
47
+ h3: { size: 24, lineHeight: 1.25 },
48
+ h4: { size: 20, lineHeight: 1.25 },
49
+ h5: { size: 16, lineHeight: 1.25 }
50
+ };
51
+
52
+ const TEXT_UI_SIZES = {
53
+ sm: { size: 14, lineHeight: 1 },
54
+ md: { size: 16, lineHeight: 1 },
55
+ lg: { size: 18, lineHeight: 1 }
56
+ };
57
+
58
+ /* == Border radius == */
59
+
60
+ const RADIUS_SIZES = {
61
+ none: '0px',
62
+ xs: { size: 5 },
63
+ sm: { size: 10 },
64
+ md: { size: 25 },
65
+ lg: { size: 35 },
66
+ full: '9999px'
67
+ };
68
+
69
+ /* == Border width == */
70
+
71
+ const BORDER_WIDTH_SIZES = {
72
+ thin: { size: 1 },
73
+ normal: { size: 2 },
74
+ thick: { size: 4 }
75
+ };
76
+
77
+ /* == Stroke width == */
78
+
79
+ const STROKE_WIDTH_SIZES = {
80
+ thin: { size: 1 },
81
+ normal: { size: 2 },
82
+ thick: { size: 4 }
83
+ };
84
+
85
+ /**
86
+ * Complete design tokens configuration
87
+ *
88
+ * @example Usage with generateTailwindThemeExtensions
89
+ * ```javascript
90
+ * import { generateTailwindThemeExtensions } from '@hkdigital/lib-core/design/index.js';
91
+ * import { designTokens } from '@hkdigital/lib-core/design/config/design-tokens.js';
92
+ *
93
+ * const themeExtensions = generateTailwindThemeExtensions(designTokens);
94
+ * ```
95
+ */
96
+ export const designTokens = {
97
+ DESIGN,
98
+ CLAMPING,
99
+ TEXT_POINT_SIZES,
100
+ VIEWPORT_POINT_SIZES,
101
+ TEXT_BASE_SIZES,
102
+ TEXT_HEADING_SIZES,
103
+ TEXT_UI_SIZES,
104
+ RADIUS_SIZES,
105
+ BORDER_WIDTH_SIZES,
106
+ STROKE_WIDTH_SIZES
107
+ };
@@ -1,3 +1,54 @@
1
+ /**
2
+ * Generate complete Tailwind CSS theme extensions from design configuration
3
+ *
4
+ * Takes design configuration objects and generates complete Tailwind theme extensions.
5
+ * Users can define their own design-config.js with custom values and pass them here.
6
+ *
7
+ * @param {Object} designConfig - Design configuration object
8
+ * @param {Object} designConfig.TEXT_POINT_SIZES - Array of text point sizes for spacing
9
+ * @param {Object} designConfig.VIEWPORT_POINT_SIZES - Array of viewport point sizes
10
+ * @param {Object} designConfig.TEXT_BASE_SIZES - Base text size configurations
11
+ * @param {Object} designConfig.TEXT_HEADING_SIZES - Heading text size configurations
12
+ * @param {Object} designConfig.TEXT_UI_SIZES - UI text size configurations
13
+ * @param {Object} designConfig.RADIUS_SIZES - Border radius configurations
14
+ * @param {Object} designConfig.BORDER_WIDTH_SIZES - Border width configurations
15
+ * @param {Object} designConfig.STROKE_WIDTH_SIZES - Stroke width configurations
16
+ *
17
+ * @returns {Object} Complete Tailwind theme extension object
18
+ *
19
+ * @example Basic usage
20
+ * ```javascript
21
+ * // your-project/src/lib/design/design-config.js
22
+ * export const DESIGN = { width: 1440, height: 900 };
23
+ * export const TEXT_BASE_SIZES = {
24
+ * sm: { size: 12, lineHeight: 1.3 },
25
+ * md: { size: 16, lineHeight: 1.4 }
26
+ * };
27
+ * // ... other exports
28
+ *
29
+ * // your-project/tailwind.config.js
30
+ * import { generateTailwindThemeExtensions } from '@hkdigital/lib-core/design/index.js';
31
+ * import { customUtilitiesPlugin } from '@hkdigital/lib-core/design/index.js';
32
+ * import * as designConfig from './src/lib/design/design-config.js';
33
+ *
34
+ * export default {
35
+ * theme: {
36
+ * extend: generateTailwindThemeExtensions(designConfig)
37
+ * },
38
+ * plugins: [customUtilitiesPlugin]
39
+ * };
40
+ * ```
41
+ */
42
+ export function generateTailwindThemeExtensions({ TEXT_POINT_SIZES, VIEWPORT_POINT_SIZES, TEXT_BASE_SIZES, TEXT_HEADING_SIZES, TEXT_UI_SIZES, RADIUS_SIZES, BORDER_WIDTH_SIZES, STROKE_WIDTH_SIZES }: {
43
+ TEXT_POINT_SIZES: any;
44
+ VIEWPORT_POINT_SIZES: any;
45
+ TEXT_BASE_SIZES: any;
46
+ TEXT_HEADING_SIZES: any;
47
+ TEXT_UI_SIZES: any;
48
+ RADIUS_SIZES: any;
49
+ BORDER_WIDTH_SIZES: any;
50
+ STROKE_WIDTH_SIZES: any;
51
+ }): any;
1
52
  /**
2
53
  * Generates text-based spacing units with with different scaling
3
54
  * units (ut, bt, ht)