@hkdigital/lib-sveltekit 0.1.7 → 0.1.9

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.
@@ -24,7 +24,7 @@
24
24
  * scaleW?: number,
25
25
  * scaleH?: number,
26
26
  * scaleUI?: number,
27
- * scaleTextContent?: number,
27
+ * scaleTextBase?: number,
28
28
  * scaleTextHeading?: number,
29
29
  * scaleTextUI?: number,
30
30
  * children?: import('svelte').Snippet,
@@ -47,7 +47,7 @@
47
47
  scaleW = $bindable(0),
48
48
  scaleH = $bindable(0),
49
49
  scaleUI = $bindable(0),
50
- scaleTextContent = $bindable(0),
50
+ scaleTextBase = $bindable(0),
51
51
  scaleTextHeading = $bindable(0),
52
52
  scaleTextUI = $bindable(0),
53
53
 
@@ -97,17 +97,14 @@
97
97
  try {
98
98
  // Get clamp parameters from CSS variables
99
99
  const uiParams = getClampParams('scale-ui');
100
- const contentParams = getClampParams('scale-text-content');
100
+ const baseParams = getClampParams('scale-text-base');
101
101
  const headingParams = getClampParams('scale-text-heading');
102
102
  const textUIParams = getClampParams('scale-text-ui');
103
103
 
104
104
  // Apply scaling according to extracted clamp parameters
105
105
  scaleUI = clamp(uiParams.min, scaleViewport, uiParams.max);
106
- scaleTextContent = clamp(
107
- contentParams.min,
108
- scaleViewport,
109
- contentParams.max
110
- );
106
+
107
+ scaleTextBase = clamp(baseParams.min, scaleViewport, baseParams.max);
111
108
  scaleTextHeading = clamp(
112
109
  headingParams.min,
113
110
  scaleViewport,
@@ -124,7 +121,7 @@
124
121
 
125
122
  // Fallback to simple scaling without clamping
126
123
  scaleUI = scaleViewport;
127
- scaleTextContent = scaleViewport;
124
+ scaleTextBase = scaleViewport;
128
125
  scaleTextHeading = scaleViewport;
129
126
  scaleTextUI = scaleViewport;
130
127
  }
@@ -135,7 +132,7 @@
135
132
  --scale-h: ${scaleH};
136
133
  --scale-viewport: ${scaleViewport};
137
134
  --scale-ui: ${scaleUI};
138
- --scale-text-content: ${scaleTextContent};
135
+ --scale-text-base: ${scaleTextBase};
139
136
  --scale-text-heading: ${scaleTextHeading};
140
137
  --scale-text-ui: ${scaleTextUI};
141
138
  `;
@@ -15,7 +15,7 @@ type VirtualViewport = {
15
15
  scaleW?: number;
16
16
  scaleH?: number;
17
17
  scaleUI?: number;
18
- scaleTextContent?: number;
18
+ scaleTextBase?: number;
19
19
  scaleTextHeading?: number;
20
20
  scaleTextUI?: number;
21
21
  children?: Snippet<[]>;
@@ -35,8 +35,8 @@ declare const VirtualViewport: import("svelte").Component<{
35
35
  scaleW?: number;
36
36
  scaleH?: number;
37
37
  scaleUI?: number;
38
- scaleTextContent?: number;
38
+ scaleTextBase?: number;
39
39
  scaleTextHeading?: number;
40
40
  scaleTextUI?: number;
41
41
  children?: import("svelte").Snippet;
42
- }, {}, "designWidth" | "designHeight" | "scaleViewport" | "scaleW" | "scaleH" | "scaleUI" | "scaleTextContent" | "scaleTextHeading" | "scaleTextUI">;
42
+ }, {}, "designWidth" | "designHeight" | "scaleViewport" | "scaleW" | "scaleH" | "scaleUI" | "scaleTextBase" | "scaleTextHeading" | "scaleTextUI">;
@@ -7,7 +7,7 @@ export namespace CLAMPING {
7
7
  let min: number;
8
8
  let max: number;
9
9
  }
10
- namespace textContent {
10
+ namespace textBase {
11
11
  let min_1: number;
12
12
  export { min_1 as min };
13
13
  let max_1: number;
@@ -28,12 +28,12 @@ export namespace CLAMPING {
28
28
  }
29
29
  export const TEXT_POINT_SIZES: number[];
30
30
  export const VIEWPORT_POINT_SIZES: number[];
31
- export namespace TEXT_CONTENT_SIZES {
31
+ export namespace TEXT_BASE_SIZES {
32
32
  namespace sm {
33
33
  let size: number;
34
34
  let lineHeight: number;
35
35
  }
36
- namespace base {
36
+ namespace md {
37
37
  let size_1: number;
38
38
  export { size_1 as size };
39
39
  let lineHeight_1: number;
@@ -86,13 +86,13 @@ export namespace TEXT_UI_SIZES {
86
86
  export { lineHeight_8 as lineHeight };
87
87
  }
88
88
  export { sm_1 as sm };
89
- export namespace base_1 {
89
+ export namespace md_1 {
90
90
  let size_9: number;
91
91
  export { size_9 as size };
92
92
  let lineHeight_9: number;
93
93
  export { lineHeight_9 as lineHeight };
94
94
  }
95
- export { base_1 as base };
95
+ export { md_1 as md };
96
96
  export namespace lg_1 {
97
97
  let size_10: number;
98
98
  export { size_10 as size };
@@ -112,10 +112,11 @@ export namespace RADIUS_SIZES {
112
112
  export { size_12 as size };
113
113
  }
114
114
  export { sm_2 as sm };
115
- export namespace md {
115
+ export namespace md_2 {
116
116
  let size_13: number;
117
117
  export { size_13 as size };
118
118
  }
119
+ export { md_2 as md };
119
120
  export namespace lg_2 {
120
121
  let size_14: number;
121
122
  export { size_14 as size };
@@ -9,7 +9,7 @@ export const DESIGN = {
9
9
 
10
10
  export const CLAMPING = {
11
11
  ui: { min: 0.3, max: 2 },
12
- textContent: { min: 0.75, max: 1.5 },
12
+ textBase: { min: 0.75, max: 1.5 },
13
13
  textHeading: { min: 0.75, max: 2.25 },
14
14
  textUi: { min: 0.5, max: 1.25 }
15
15
  };
@@ -25,9 +25,9 @@ export const VIEWPORT_POINT_SIZES = [
25
25
  200
26
26
  ];
27
27
 
28
- export const TEXT_CONTENT_SIZES = {
28
+ export const TEXT_BASE_SIZES = {
29
29
  sm: { size: 14, lineHeight: 1.5 },
30
- base: { size: 16, lineHeight: 1.5 },
30
+ md: { size: 16, lineHeight: 1.5 },
31
31
  lg: { size: 18, lineHeight: 1.4 }
32
32
  };
33
33
 
@@ -41,7 +41,7 @@ export const TEXT_HEADING_SIZES = {
41
41
 
42
42
  export const TEXT_UI_SIZES = {
43
43
  sm: { size: 14, lineHeight: 1.1 },
44
- base: { size: 16, lineHeight: 1.1 },
44
+ md: { size: 16, lineHeight: 1.1 },
45
45
  lg: { size: 18, lineHeight: 1.1 }
46
46
  };
47
47
 
@@ -21,3 +21,11 @@ export const outlineWidth: {
21
21
  export const outlineOffset: {
22
22
  [key: string]: string;
23
23
  };
24
+ export const fontFamily: {
25
+ [x: string]: string;
26
+ };
27
+ export const textColor: {
28
+ [x: string]: {
29
+ [x: string]: string;
30
+ };
31
+ };
@@ -31,22 +31,22 @@
31
31
  * --scale-h: 0.09259vh (Viewport Height Point)
32
32
  * --scale-viewport: min(var(--scale-w), var(--scale-h)) (Viewport Point)
33
33
  * --scale-ui: clamp(0.3, var(--scale-viewport), 2) (UI Point)
34
- * --scale-text-content: clamp(0.75, var(--scale-viewport), 1.5) (Content Text)
34
+ * --scale-text-base: clamp(0.75, var(--scale-viewport), 1.5) (Base Text)
35
35
  * --scale-text-heading: clamp(0.75, var(--scale-viewport), 2.25) (Heading Text)
36
36
  * --scale-text-ui: clamp(0.5, var(--scale-viewport), 1.25) (UI Text)
37
37
  *
38
38
  * --
39
39
  *
40
- * UI Points (p) - Clamped scaling values
40
+ * UI Points (up) - Clamped scaling values
41
41
  * Based on viewport scaling with minimum and maximum bounds
42
42
  * to ensure usability across all screen sizes
43
43
  *
44
44
  * > PREFERRED METHOD FOR UI ELEMENT SCALING
45
45
  *
46
46
  * Examples:
47
- * 5p = 5px at design size (clamps between 1.5px and 10px)
48
- * 10p = 10px at design size (clamps between 3px and 20px)
49
- * 20p = 20px at design size (clamps between 6px and 40px)
47
+ * 5up = 5px at design size (clamps between 1.5px and 10px)
48
+ * 10up = 10px at design size (clamps between 3px and 20px)
49
+ * 20up = 20px at design size (clamps between 6px and 40px)
50
50
  *
51
51
  * Used for:
52
52
  * - Component padding and margins
@@ -55,32 +55,30 @@
55
55
  *
56
56
  * --
57
57
  *
58
- * Text-Based Spacing Units (ut, ct, ht)
58
+ * Text-Based Spacing Units (ut, bt, ht)
59
59
  * Scaled by their respective text scaling variables
60
60
  *
61
61
  * > PREFERRED METHOD FOR TEXT-RELATED SPACING
62
62
  *
63
63
  * Examples:
64
64
  * 4ut = calc(4px * var(--scale-text-ui)) // UI text spacing
65
- * 4ct = calc(4px * var(--scale-text-content)) // Content text spacing
65
+ * 4bt = calc(4px * var(--scale-text-base)) // Base text spacing
66
66
  * 4ht = calc(4px * var(--scale-text-heading)) // Heading text spacing
67
67
  *
68
68
  * Used for:
69
69
  * - ut: Button padding, form spacing, UI component margins
70
- * - ct: Paragraph margins, list spacing, content gaps
70
+ * - bt: Paragraph margins, list spacing, base gaps
71
71
  * - ht: Heading margins, title spacing
72
72
  *
73
73
  * --
74
74
  *
75
- * Viewport Points (vp, wp, hp) - Responsive scaling values
76
- * vp: Uses min of width/height scaling
75
+ * Viewport Points (wp, hp) - Responsive scaling values
77
76
  * wp: Uses width-based scaling (1920px reference)
78
77
  * hp: Uses height-based scaling (1080px reference)
79
78
  *
80
79
  * > ALTERNATIVE SCALING METHODS
81
80
  *
82
81
  * Examples:
83
- * 10vp = calc(10px * var(--scale-viewport))
84
82
  * 10wp = calc(10px * var(--scale-w))
85
83
  * 10hp = calc(10px * var(--scale-h))
86
84
  *
@@ -94,13 +92,15 @@ import {
94
92
  generateViewportBasedSpacing,
95
93
  generateTextStyles,
96
94
  generateBorderRadiusStyles,
97
- generateWidthStyles
95
+ generateWidthStyles,
96
+ generateFontFamilyStyles,
97
+ generateTextColorStyles
98
98
  } from '../util/design-system/tailwind.js';
99
99
 
100
100
  import {
101
101
  TEXT_POINT_SIZES,
102
102
  VIEWPORT_POINT_SIZES,
103
- TEXT_CONTENT_SIZES,
103
+ TEXT_BASE_SIZES,
104
104
  TEXT_HEADING_SIZES,
105
105
  TEXT_UI_SIZES,
106
106
  RADIUS_SIZES,
@@ -125,7 +125,7 @@ export const fontSize = {
125
125
  ...TEXT_BASED_SPACING,
126
126
 
127
127
  // Named styles
128
- ...generateTextStyles(TEXT_CONTENT_SIZES, 'content'),
128
+ ...generateTextStyles(TEXT_BASE_SIZES, 'base'),
129
129
  ...generateTextStyles(TEXT_HEADING_SIZES, 'heading'),
130
130
  ...generateTextStyles(TEXT_UI_SIZES, 'ui')
131
131
  };
@@ -155,6 +155,16 @@ export const outlineOffset = {
155
155
  ...generateWidthStyles(STROKE_WIDTH_SIZES, '')
156
156
  };
157
157
 
158
+ // Add UI font family extension
159
+ export const fontFamily = {
160
+ ...generateFontFamilyStyles()
161
+ };
162
+
163
+ // Add UI text color extension
164
+ export const textColor = {
165
+ ...generateTextColorStyles()
166
+ };
167
+
158
168
  // console.log('borderWidth', borderWidth);
159
169
  // console.log('outlineWidth', outlineWidth);
160
170
  // console.log('outlineOffset', outlineOffset);
@@ -25,7 +25,7 @@
25
25
  }
26
26
 
27
27
  & > .content-box .p {
28
- @apply text-content-base;
28
+ @apply text-base-md;
29
29
  }
30
30
 
31
31
  & > .content-box:has( + .footer-box )
@@ -38,4 +38,4 @@
38
38
  }
39
39
 
40
40
 
41
- }
41
+ }
@@ -5,10 +5,11 @@
5
5
  /* Type-based styling for text buttons */
6
6
  [data-component="button"][data-type="text"] {
7
7
  /* Typography settings */
8
- @apply text-ui-base uppercase;
8
+ @apply font-ui text-ui-md;
9
+ @apply uppercase;
9
10
  @apply whitespace-nowrap;
10
11
 
11
- /* Adjust padding to better fit text */
12
+ /* Size specific adjustments */
12
13
  /*&[data-size="sm"] {
13
14
  @apply px-8ut py-8ut;
14
15
  }
@@ -6,15 +6,15 @@
6
6
  [data-component="icon"][data-type="steeze"] {
7
7
 
8
8
  &[data-size="sm"] {
9
- @apply w-16ct h-16ct;
9
+ @apply w-16bt h-16bt;
10
10
  }
11
11
 
12
12
  &[data-size="md"] {
13
- @apply w-28ct h-28ct;
13
+ @apply w-28bt h-28bt;
14
14
  }
15
15
 
16
16
  &[data-size="lg"] {
17
- @apply w-50ct h-50ct;
17
+ @apply w-50bt h-50bt;
18
18
  }
19
19
 
20
20
  }
@@ -42,6 +42,14 @@ declare namespace theme {
42
42
  '--anchor-text-decoration-hover': string;
43
43
  '--anchor-text-decoration-active': string;
44
44
  '--anchor-text-decoration-focus': string;
45
+ '--ui-font-color': string;
46
+ '--ui-font-color-dark': string;
47
+ '--ui-font-family': string;
48
+ '--ui-font-size': string;
49
+ '--ui-line-height': string;
50
+ '--ui-font-weight': string;
51
+ '--ui-font-style': string;
52
+ '--ui-letter-spacing': string;
45
53
  '--space-scale-factor': string;
46
54
  '--radii-default': string;
47
55
  '--radii-container': string;
@@ -41,6 +41,16 @@ const theme = {
41
41
  '--anchor-text-decoration-hover': 'underline',
42
42
  '--anchor-text-decoration-active': 'none',
43
43
  '--anchor-text-decoration-focus': 'none',
44
+
45
+ '--ui-font-color': 'var(--color-surface-950)',
46
+ '--ui-font-color-dark': 'var(--color-surface-50)',
47
+ '--ui-font-family': 'Source Sans Pro, system-ui, sans-serif',
48
+ '--ui-font-size': 'inherit',
49
+ '--ui-line-height': 'inherit',
50
+ '--ui-font-weight': 'normal',
51
+ '--ui-font-style': 'normal',
52
+ '--ui-letter-spacing': '0em',
53
+
44
54
  '--space-scale-factor': '1',
45
55
  '--radii-default': '6px',
46
56
  '--radii-container': '12px',
@@ -9,9 +9,9 @@ export function getClampParams(varName: string): any;
9
9
  /**
10
10
  * CSS clamp function implementation
11
11
  *
12
- * @param {number} value - Value to clamp
13
12
  * @param {number} min - Minimum value
13
+ * @param {number} value - Value to clamp
14
14
  * @param {number} max - Maximum value
15
15
  * @returns {number} Clamped value
16
16
  */
17
- export function clamp(value: number, min: number, max: number): number;
17
+ export function clamp(min: number, value: number, max: number): number;
@@ -56,11 +56,11 @@ export function getClampParams(varName) {
56
56
  /**
57
57
  * CSS clamp function implementation
58
58
  *
59
- * @param {number} value - Value to clamp
60
59
  * @param {number} min - Minimum value
60
+ * @param {number} value - Value to clamp
61
61
  * @param {number} max - Maximum value
62
62
  * @returns {number} Clamped value
63
63
  */
64
- export function clamp(value, min, max) {
64
+ export function clamp(min, value, max) {
65
65
  return Math.max(min, Math.min(value, max));
66
66
  }
@@ -9,9 +9,9 @@
9
9
  * @param {Object} clamping.ui - UI clamping configuration
10
10
  * @param {number} clamping.ui.min - Minimum UI scaling factor
11
11
  * @param {number} clamping.ui.max - Maximum UI scaling factor
12
- * @param {Object} clamping.textContent - Content text scaling configuration
13
- * @param {number} clamping.textContent.min - Minimum content text scaling
14
- * @param {number} clamping.textContent.max - Maximum content text scaling
12
+ * @param {Object} clamping.textBase - Base text scaling configuration
13
+ * @param {number} clamping.textBase.min - Minimum base text scaling
14
+ * @param {number} clamping.textBase.max - Maximum base text scaling
15
15
  * @param {Object} clamping.textHeading - Heading text clamping configuration
16
16
  * @param {number} clamping.textHeading.min - Minimum heading text scaling
17
17
  * @param {number} clamping.textHeading.max - Maximum heading text scaling
@@ -44,7 +44,7 @@ export function rootDesignVarsHTML(design: {
44
44
  min: number;
45
45
  max: number;
46
46
  };
47
- textContent: {
47
+ textBase: {
48
48
  min: number;
49
49
  max: number;
50
50
  };
@@ -11,9 +11,9 @@ import { getRootCssVar } from '../../css/css-vars.js';
11
11
  * @param {Object} clamping.ui - UI clamping configuration
12
12
  * @param {number} clamping.ui.min - Minimum UI scaling factor
13
13
  * @param {number} clamping.ui.max - Maximum UI scaling factor
14
- * @param {Object} clamping.textContent - Content text scaling configuration
15
- * @param {number} clamping.textContent.min - Minimum content text scaling
16
- * @param {number} clamping.textContent.max - Maximum content text scaling
14
+ * @param {Object} clamping.textBase - Base text scaling configuration
15
+ * @param {number} clamping.textBase.min - Minimum base text scaling
16
+ * @param {number} clamping.textBase.max - Maximum base text scaling
17
17
  * @param {Object} clamping.textHeading - Heading text clamping configuration
18
18
  * @param {number} clamping.textHeading.min - Minimum heading text scaling
19
19
  * @param {number} clamping.textHeading.max - Maximum heading text scaling
@@ -51,7 +51,7 @@ export function rootDesignVarsHTML(design, clamping) {
51
51
 
52
52
  /* Scaling factors with configurable clamping */
53
53
  --scale-ui: clamp(${clamping.ui.min}, var(--scale-viewport), ${clamping.ui.max});
54
- --scale-text-content: clamp(${clamping.textContent.min}, var(--scale-viewport), ${clamping.textContent.max});
54
+ --scale-text-base: clamp(${clamping.textBase.min}, var(--scale-viewport), ${clamping.textBase.max});
55
55
  --scale-text-heading: clamp(${clamping.textHeading.min}, var(--scale-viewport), ${clamping.textHeading.max});
56
56
  --scale-text-ui: clamp(${clamping.textUi.min}, var(--scale-viewport), ${clamping.textUi.max});
57
57
  }</style>`;
@@ -90,8 +90,8 @@ export function getAllRootScalingVars() {
90
90
  parseFloat(styles.getPropertyValue('--scale-viewport').trim()) || 0,
91
91
 
92
92
  scaleUI: parseFloat(styles.getPropertyValue('--scale-ui').trim()) || 0,
93
- scaleTextContent:
94
- parseFloat(styles.getPropertyValue('--scale-text-content').trim()) || 0,
93
+ scaleTextBase:
94
+ parseFloat(styles.getPropertyValue('--scale-text-base').trim()) || 0,
95
95
  scaleTextHeading:
96
96
  parseFloat(styles.getPropertyValue('--scale-text-heading').trim()) || 0,
97
97
  scaleTextUI:
@@ -9,9 +9,9 @@
9
9
  * @param {Object} clamping.ui - UI element scaling constraints
10
10
  * @param {number} clamping.ui.min - Minimum UI scale factor
11
11
  * @param {number} clamping.ui.max - Maximum UI scale factor
12
- * @param {Object} clamping.textContent - Content text scaling constraints
13
- * @param {number} clamping.textContent.min - Minimum content text scale factor
14
- * @param {number} clamping.textContent.max - Maximum content text scale factor
12
+ * @param {Object} clamping.textBase - Base text scaling constraints
13
+ * @param {number} clamping.textBase.min - Minimum base text scale factor
14
+ * @param {number} clamping.textBase.max - Maximum base text scale factor
15
15
  * @param {Object} clamping.textHeading - Heading text scaling constraints
16
16
  * @param {number} clamping.textHeading.min - Minimum heading text scale factor
17
17
  * @param {number} clamping.textHeading.max - Maximum heading text scale factor
@@ -29,7 +29,7 @@ export function enableScalingUI(design: {
29
29
  min: number;
30
30
  max: number;
31
31
  };
32
- textContent: {
32
+ textBase: {
33
33
  min: number;
34
34
  max: number;
35
35
  };
@@ -11,9 +11,9 @@ import { clamp } from '../css/clamp.js';
11
11
  * @param {Object} clamping.ui - UI element scaling constraints
12
12
  * @param {number} clamping.ui.min - Minimum UI scale factor
13
13
  * @param {number} clamping.ui.max - Maximum UI scale factor
14
- * @param {Object} clamping.textContent - Content text scaling constraints
15
- * @param {number} clamping.textContent.min - Minimum content text scale factor
16
- * @param {number} clamping.textContent.max - Maximum content text scale factor
14
+ * @param {Object} clamping.textBase - Base text scaling constraints
15
+ * @param {number} clamping.textBase.min - Minimum base text scale factor
16
+ * @param {number} clamping.textBase.max - Maximum base text scale factor
17
17
  * @param {Object} clamping.textHeading - Heading text scaling constraints
18
18
  * @param {number} clamping.textHeading.min - Minimum heading text scale factor
19
19
  * @param {number} clamping.textHeading.max - Maximum heading text scale factor
@@ -41,23 +41,23 @@ export function enableScalingUI(design, clamping) {
41
41
  const scaleViewport = Math.min(scaleW, scaleH);
42
42
 
43
43
  // Apply clamping to different element types
44
- const scaleUI = clamp(scaleViewport, clamping.ui.min, clamping.ui.max);
44
+ const scaleUI = clamp(clamping.ui.min, scaleViewport, clamping.ui.max);
45
45
 
46
- const scaleTextContent = clamp(
46
+ const scaleTextBase = clamp(
47
+ clamping.textBase.min,
47
48
  scaleViewport,
48
- clamping.textContent.min,
49
- clamping.textContent.max
49
+ clamping.textBase.max
50
50
  );
51
51
 
52
52
  const scaleTextHeading = clamp(
53
- scaleViewport,
54
53
  clamping.textHeading.min,
54
+ scaleViewport,
55
55
  clamping.textHeading.max
56
56
  );
57
57
 
58
58
  const scaleTextUi = clamp(
59
- scaleViewport,
60
59
  clamping.textUi.min,
60
+ scaleViewport,
61
61
  clamping.textUi.max
62
62
  );
63
63
 
@@ -70,8 +70,8 @@ export function enableScalingUI(design, clamping) {
70
70
  );
71
71
  document.documentElement.style.setProperty('--scale-ui', String(scaleUI));
72
72
  document.documentElement.style.setProperty(
73
- '--scale-text-content',
74
- String(scaleTextContent)
73
+ '--scale-text-base',
74
+ String(scaleTextBase)
75
75
  );
76
76
  document.documentElement.style.setProperty(
77
77
  '--scale-text-heading',
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Creates utility classes for UI font styling that work with Skeleton themes
3
+ *
4
+ * This plugin adds utility classes for UI typography that reference CSS
5
+ * variables defined in your Skeleton theme, allowing consistent styling of UI
6
+ * elements across your application.
7
+ *
8
+ * @note Important Configuration Requirements:
9
+ * 1. Add UI font variables to your theme file:
10
+ * - `--ui-font-family`: Font family for UI elements
11
+ * (falls back to `--base-font-family`)
12
+ * - `--ui-font-color`: Text color for UI elements
13
+ * (falls back to `--base-font-color`)
14
+ * - `--ui-font-color-dark`: Dark mode text color
15
+ * (falls back to `--base-font-color-dark`)
16
+ *
17
+ * 2. This plugin generates the following utility classes:
18
+ * - `font-ui`: Applies UI font family
19
+ * - `text-ui`: Applies UI text color
20
+ * - `text-ui-dark`: Applies UI dark mode text color (with .dark selector)
21
+ *
22
+ * @example
23
+ * // tailwind.config.js
24
+ * import { customUtilitiesPlugin }
25
+ * from './src/lib/util/design-system/skeleton.js';
26
+ *
27
+ * export default {
28
+ * plugins: [
29
+ * customUtilitiesPlugin,
30
+ * skeleton({
31
+ * themes: [defaultThemes.cerberus, customThemes.yourTheme]
32
+ * })
33
+ * ]
34
+ * };
35
+ *
36
+ * @param {Object} api - Tailwind plugin API
37
+ * @param {Function} api.addUtilities - Function to add utilities
38
+ */
39
+ export function customUtilitiesPlugin({ addUtilities }: {
40
+ addUtilities: Function;
41
+ }): void;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Creates utility classes for UI font styling that work with Skeleton themes
3
+ *
4
+ * This plugin adds utility classes for UI typography that reference CSS
5
+ * variables defined in your Skeleton theme, allowing consistent styling of UI
6
+ * elements across your application.
7
+ *
8
+ * @note Important Configuration Requirements:
9
+ * 1. Add UI font variables to your theme file:
10
+ * - `--ui-font-family`: Font family for UI elements
11
+ * (falls back to `--base-font-family`)
12
+ * - `--ui-font-color`: Text color for UI elements
13
+ * (falls back to `--base-font-color`)
14
+ * - `--ui-font-color-dark`: Dark mode text color
15
+ * (falls back to `--base-font-color-dark`)
16
+ *
17
+ * 2. This plugin generates the following utility classes:
18
+ * - `font-ui`: Applies UI font family
19
+ * - `text-ui`: Applies UI text color
20
+ * - `text-ui-dark`: Applies UI dark mode text color (with .dark selector)
21
+ *
22
+ * @example
23
+ * // tailwind.config.js
24
+ * import { customUtilitiesPlugin }
25
+ * from './src/lib/util/design-system/skeleton.js';
26
+ *
27
+ * export default {
28
+ * plugins: [
29
+ * customUtilitiesPlugin,
30
+ * skeleton({
31
+ * themes: [defaultThemes.cerberus, customThemes.yourTheme]
32
+ * })
33
+ * ]
34
+ * };
35
+ *
36
+ * @param {Object} api - Tailwind plugin API
37
+ * @param {Function} api.addUtilities - Function to add utilities
38
+ */
39
+ export function customUtilitiesPlugin({ addUtilities }) {
40
+ const utilities = {
41
+ '.font-ui': {
42
+ 'font-family': 'var(--ui-font-family, var(--base-font-family))'
43
+ },
44
+ '.text-base-color': {
45
+ color: 'var(--base-font-color)'
46
+ },
47
+ '.text-base-color-dark': {
48
+ color: 'var(--base-font-color-dark)'
49
+ },
50
+ '.text-heading-color': {
51
+ color: 'var(--heading-font-color)'
52
+ },
53
+ '.text-heading-color-dark': {
54
+ color: 'var(--heading-font-color-dark)'
55
+ },
56
+ '.text-ui-color': {
57
+ color: 'var(--ui-font-color, var(--base-font-color))'
58
+ },
59
+ '.text-ui-color-dark': {
60
+ color: 'var(--ui-font-color-dark, var(--base-font-color-dark))'
61
+ }
62
+ };
63
+
64
+ addUtilities(utilities);
65
+ }
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Generates text-based spacing units with with different scaling
3
- * units (ut, ct, ht)
3
+ * units (ut, bt, ht)
4
4
  *
5
5
  * @param {number[]} values
6
6
  * Array of pixel values to generate text-based spacing units for
7
7
  *
8
8
  * @returns {{[key: string]: string}}
9
- * Generated text-based spacing units with ut, ct, and ht suffixes
9
+ * Generated text-based spacing units with ut, bt, and ht suffixes
10
10
  *
11
11
  * @throws {Error} If values is not an array or contains non-numeric values
12
12
  *
@@ -16,8 +16,8 @@
16
16
  * // {
17
17
  * // '1ut': 'calc(1px * var(--scale-text-ui))',
18
18
  * // '2ut': 'calc(2px * var(--scale-text-ui))',
19
- * // '1ct': 'calc(1px * var(--scale-text-content))',
20
- * // '2ct': 'calc(2px * var(--scale-text-content))',
19
+ * // '1bt': 'calc(1px * var(--scale-text-base))',
20
+ * // '2bt': 'calc(2px * var(--scale-text-base))',
21
21
  * // '1ht': 'calc(1px * var(--scale-text-heading))',
22
22
  * // '2ht': 'calc(2px * var(--scale-text-heading))'
23
23
  * // }
@@ -27,15 +27,15 @@ export function generateTextBasedSpacing(values: number[]): {
27
27
  };
28
28
  /**
29
29
  * Generates viewport-based spacing units with different scaling
30
- * units (p, vp, wp, hp)
30
+ * units (up, wp, hp)
31
31
  *
32
32
  * @param {number[]} values
33
33
  * Array of pixel values to generate viewport-based spacing units for
34
34
  *
35
35
  * @returns {Object.<string, string>}
36
36
  * Generated viewport-based spacing units:
37
- * - p: UI points (clamped scaling)
38
- * - vp: Viewport points (min of width/height)
37
+ * - up: UI points (clamped scaling)
38
+ * - p: UI points (deprecated, will be removed in future versions)
39
39
  * - wp: Width points
40
40
  * - hp: Height points
41
41
  *
@@ -45,8 +45,8 @@ export function generateTextBasedSpacing(values: number[]): {
45
45
  * generateViewportBasedSpacing([1, 2, 4])
46
46
  * // Returns:
47
47
  * // {
48
- * // '1p': 'calc(1px * var(--scale-ui))',
49
- * // '1vp': 'calc(1px * var(--scale-viewport))',
48
+ * // '1up': 'calc(1px * var(--scale-ui))',
49
+ * // '1p': 'calc(1px * var(--scale-ui))', // deprecated
50
50
  * // '1wp': 'calc(1px * var(--scale-w))',
51
51
  * // '1hp': 'calc(1px * var(--scale-h))'
52
52
  * // }
@@ -56,13 +56,13 @@ export function generateViewportBasedSpacing(values: number[]): {
56
56
  };
57
57
  /**
58
58
  * Generates semantic text style definitions for a specific text category
59
- * (content, UI, or heading). Each style includes a scaled font size and
59
+ * (base, UI, or heading). Each style includes a scaled font size and
60
60
  * line height.
61
61
  *
62
62
  * @param {{[key: string]: {size: number, lineHeight?: number}}} sizes
63
63
  * Set of text sizes to generate styles for
64
64
  *
65
- * @param {'content' | 'ui' | 'heading'} category
65
+ * @param {'base' | 'ui' | 'heading'} category
66
66
  * Text category to generate styles for
67
67
  *
68
68
  * @returns {{[key: string]: [string, {lineHeight: number}]}}
@@ -71,21 +71,21 @@ export function generateViewportBasedSpacing(values: number[]): {
71
71
  * @throws {Error} If a size has an invalid size or lineHeight
72
72
  *
73
73
  * @example
74
- * const TEXT_CONTENT_SIZES = {
74
+ * const TEXT_BASE_SIZES = {
75
75
  * sm: { size: 16, lineHeight: 1.5 },
76
76
  * base: { size: 20, lineHeight: 1.5 },
77
77
  * lg: { size: 24, lineHeight: 1.4 }
78
78
  * };
79
79
  *
80
- * generateTextStyles(TEXT_CONTENT_SIZES, 'content');
80
+ * generateTextStyles(TEXT_BASE_SIZES, 'base');
81
81
  * // Returns:
82
82
  * // {
83
- * // 'content-sm':
84
- * // ['calc(16px * var(--scale-text-content))', { lineHeight: 1.5 }],
85
- * // 'content-base':
86
- * // ['calc(20px * var(--scale-text-content))', { lineHeight: 1.5 }],
87
- * // 'content-lg':
88
- * // ['calc(24px * var(--scale-text-content))', { lineHeight: 1.4 }]
83
+ * // 'base-sm':
84
+ * // ['calc(16px * var(--scale-text-base))', { lineHeight: 1.5 }],
85
+ * // 'base-base':
86
+ * // ['calc(20px * var(--scale-text-base))', { lineHeight: 1.5 }],
87
+ * // 'base-lg':
88
+ * // ['calc(24px * var(--scale-text-base))', { lineHeight: 1.4 }]
89
89
  * // }
90
90
  */
91
91
  export function generateTextStyles(sizes: {
@@ -93,7 +93,7 @@ export function generateTextStyles(sizes: {
93
93
  size: number;
94
94
  lineHeight?: number;
95
95
  };
96
- }, category: "content" | "ui" | "heading"): {
96
+ }, category: "base" | "ui" | "heading"): {
97
97
  [key: string]: [string, {
98
98
  lineHeight: number;
99
99
  }];
@@ -174,3 +174,38 @@ export function generateWidthStyles(sizes: {
174
174
  }, prefix?: string, scaleVar?: string): {
175
175
  [key: string]: string;
176
176
  };
177
+ /**
178
+ * Generates font family styles for different text categories
179
+ * with fallbacks to base properties when needed
180
+ *
181
+ * @returns {Object.<string, string>} Generated font family styles
182
+ *
183
+ * @example
184
+ * // Returns:
185
+ * // {
186
+ * // 'ui': 'var(--ui-font-family, var(--base-font-family))'
187
+ * // }
188
+ */
189
+ export function generateFontFamilyStyles(): {
190
+ [x: string]: string;
191
+ };
192
+ /**
193
+ * Generates text color styles for different text categories
194
+ * with fallbacks to base properties when needed
195
+ *
196
+ * @returns {Object.<string, Object.<string, string>>} Generated text color styles
197
+ *
198
+ * @example
199
+ * // Returns:
200
+ * // {
201
+ * // 'ui': {
202
+ * // 'DEFAULT': 'var(--ui-font-color, var(--base-font-color))',
203
+ * // 'dark': 'var(--ui-font-color-dark, var(--base-font-color-dark))'
204
+ * // }
205
+ * // }
206
+ */
207
+ export function generateTextColorStyles(): {
208
+ [x: string]: {
209
+ [x: string]: string;
210
+ };
211
+ };
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Generates text-based spacing units with with different scaling
3
- * units (ut, ct, ht)
3
+ * units (ut, bt, ht)
4
4
  *
5
5
  * @param {number[]} values
6
6
  * Array of pixel values to generate text-based spacing units for
7
7
  *
8
8
  * @returns {{[key: string]: string}}
9
- * Generated text-based spacing units with ut, ct, and ht suffixes
9
+ * Generated text-based spacing units with ut, bt, and ht suffixes
10
10
  *
11
11
  * @throws {Error} If values is not an array or contains non-numeric values
12
12
  *
@@ -16,8 +16,8 @@
16
16
  * // {
17
17
  * // '1ut': 'calc(1px * var(--scale-text-ui))',
18
18
  * // '2ut': 'calc(2px * var(--scale-text-ui))',
19
- * // '1ct': 'calc(1px * var(--scale-text-content))',
20
- * // '2ct': 'calc(2px * var(--scale-text-content))',
19
+ * // '1bt': 'calc(1px * var(--scale-text-base))',
20
+ * // '2bt': 'calc(2px * var(--scale-text-base))',
21
21
  * // '1ht': 'calc(1px * var(--scale-text-heading))',
22
22
  * // '2ht': 'calc(2px * var(--scale-text-heading))'
23
23
  * // }
@@ -35,8 +35,8 @@ export function generateTextBasedSpacing(values) {
35
35
  // Generate UI text spacing units
36
36
  units[`${value}ut`] = `calc(${value}px * var(--scale-text-ui))`;
37
37
 
38
- // Generate content text spacing units
39
- units[`${value}ct`] = `calc(${value}px * var(--scale-text-content))`;
38
+ // Generate base text spacing units
39
+ units[`${value}bt`] = `calc(${value}px * var(--scale-text-base))`;
40
40
 
41
41
  // Generate heading text spacing units
42
42
  units[`${value}ht`] = `calc(${value}px * var(--scale-text-heading))`;
@@ -47,15 +47,15 @@ export function generateTextBasedSpacing(values) {
47
47
 
48
48
  /**
49
49
  * Generates viewport-based spacing units with different scaling
50
- * units (p, vp, wp, hp)
50
+ * units (up, wp, hp)
51
51
  *
52
52
  * @param {number[]} values
53
53
  * Array of pixel values to generate viewport-based spacing units for
54
54
  *
55
55
  * @returns {Object.<string, string>}
56
56
  * Generated viewport-based spacing units:
57
- * - p: UI points (clamped scaling)
58
- * - vp: Viewport points (min of width/height)
57
+ * - up: UI points (clamped scaling)
58
+ * - p: UI points (deprecated, will be removed in future versions)
59
59
  * - wp: Width points
60
60
  * - hp: Height points
61
61
  *
@@ -65,8 +65,8 @@ export function generateTextBasedSpacing(values) {
65
65
  * generateViewportBasedSpacing([1, 2, 4])
66
66
  * // Returns:
67
67
  * // {
68
- * // '1p': 'calc(1px * var(--scale-ui))',
69
- * // '1vp': 'calc(1px * var(--scale-viewport))',
68
+ * // '1up': 'calc(1px * var(--scale-ui))',
69
+ * // '1p': 'calc(1px * var(--scale-ui))', // deprecated
70
70
  * // '1wp': 'calc(1px * var(--scale-w))',
71
71
  * // '1hp': 'calc(1px * var(--scale-h))'
72
72
  * // }
@@ -81,13 +81,13 @@ export function generateViewportBasedSpacing(values) {
81
81
  throw new Error(`Invalid spacing value: ${value}. Must be a number.`);
82
82
  }
83
83
 
84
- // Viewport points (min of width/height)
85
- units[`${value}vp`] = `calc(${value}px * var(--scale-viewport))`;
86
84
  // Width points
87
85
  units[`${value}wp`] = `calc(${value}px * var(--scale-w))`;
88
86
  // Height points
89
87
  units[`${value}hp`] = `calc(${value}px * var(--scale-h))`;
90
- // UI points
88
+ // UI points (standard)
89
+ units[`${value}up`] = `calc(${value}px * var(--scale-ui))`;
90
+ // UI points (deprecated)
91
91
  units[`${value}p`] = `calc(${value}px * var(--scale-ui))`;
92
92
  return units;
93
93
  }, {});
@@ -95,13 +95,13 @@ export function generateViewportBasedSpacing(values) {
95
95
 
96
96
  /**
97
97
  * Generates semantic text style definitions for a specific text category
98
- * (content, UI, or heading). Each style includes a scaled font size and
98
+ * (base, UI, or heading). Each style includes a scaled font size and
99
99
  * line height.
100
100
  *
101
101
  * @param {{[key: string]: {size: number, lineHeight?: number}}} sizes
102
102
  * Set of text sizes to generate styles for
103
103
  *
104
- * @param {'content' | 'ui' | 'heading'} category
104
+ * @param {'base' | 'ui' | 'heading'} category
105
105
  * Text category to generate styles for
106
106
  *
107
107
  * @returns {{[key: string]: [string, {lineHeight: number}]}}
@@ -110,21 +110,21 @@ export function generateViewportBasedSpacing(values) {
110
110
  * @throws {Error} If a size has an invalid size or lineHeight
111
111
  *
112
112
  * @example
113
- * const TEXT_CONTENT_SIZES = {
113
+ * const TEXT_BASE_SIZES = {
114
114
  * sm: { size: 16, lineHeight: 1.5 },
115
115
  * base: { size: 20, lineHeight: 1.5 },
116
116
  * lg: { size: 24, lineHeight: 1.4 }
117
117
  * };
118
118
  *
119
- * generateTextStyles(TEXT_CONTENT_SIZES, 'content');
119
+ * generateTextStyles(TEXT_BASE_SIZES, 'base');
120
120
  * // Returns:
121
121
  * // {
122
- * // 'content-sm':
123
- * // ['calc(16px * var(--scale-text-content))', { lineHeight: 1.5 }],
124
- * // 'content-base':
125
- * // ['calc(20px * var(--scale-text-content))', { lineHeight: 1.5 }],
126
- * // 'content-lg':
127
- * // ['calc(24px * var(--scale-text-content))', { lineHeight: 1.4 }]
122
+ * // 'base-sm':
123
+ * // ['calc(16px * var(--scale-text-base))', { lineHeight: 1.5 }],
124
+ * // 'base-base':
125
+ * // ['calc(20px * var(--scale-text-base))', { lineHeight: 1.5 }],
126
+ * // 'base-lg':
127
+ * // ['calc(24px * var(--scale-text-base))', { lineHeight: 1.4 }]
128
128
  * // }
129
129
  */
130
130
  export function generateTextStyles(sizes, category) {
@@ -132,8 +132,8 @@ export function generateTextStyles(sizes, category) {
132
132
  throw new Error('sizes must be an object');
133
133
  }
134
134
 
135
- if (!['content', 'ui', 'heading'].includes(category)) {
136
- throw new Error('category must be one of: content, ui, heading');
135
+ if (!['base', 'ui', 'heading'].includes(category)) {
136
+ throw new Error('category must be one of: base, ui, heading');
137
137
  }
138
138
 
139
139
  return Object.entries(sizes).reduce((result, [variant, config]) => {
@@ -287,3 +287,49 @@ export function generateWidthStyles(
287
287
  return result;
288
288
  }, {});
289
289
  }
290
+
291
+ /**
292
+ * Generates font family styles for different text categories
293
+ * with fallbacks to base properties when needed
294
+ *
295
+ * @returns {Object.<string, string>} Generated font family styles
296
+ *
297
+ * @example
298
+ * // Returns:
299
+ * // {
300
+ * // 'ui': 'var(--ui-font-family, var(--base-font-family))'
301
+ * // }
302
+ */
303
+ export function generateFontFamilyStyles() {
304
+ return {
305
+ // UI font family with fallback to base font family
306
+ ui: 'var(--ui-font-family, var(--base-font-family))'
307
+ };
308
+ }
309
+
310
+ /**
311
+ * Generates text color styles for different text categories
312
+ * with fallbacks to base properties when needed
313
+ *
314
+ * @returns {Object.<string, Object.<string, string>>} Generated text color styles
315
+ *
316
+ * @example
317
+ * // Returns:
318
+ * // {
319
+ * // 'ui': {
320
+ * // 'DEFAULT': 'var(--ui-font-color, var(--base-font-color))',
321
+ * // 'dark': 'var(--ui-font-color-dark, var(--base-font-color-dark))'
322
+ * // }
323
+ * // }
324
+ */
325
+ export function generateTextColorStyles() {
326
+ return {
327
+ // UI text color with fallbacks
328
+ ui: {
329
+ // Default color (light mode)
330
+ DEFAULT: 'var(--ui-font-color, var(--base-font-color))',
331
+ // Dark mode color
332
+ dark: 'var(--ui-font-color-dark, var(--base-font-color-dark))'
333
+ }
334
+ };
335
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"