@hkdigital/lib-sveltekit 0.1.0 → 0.1.1
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/dist/components/area/HkArea.svelte +1 -1
- package/dist/components/area/HkGridArea.svelte +1 -1
- package/dist/components/boxes/game-box/GameBox.svelte +112 -0
- package/dist/components/boxes/game-box/GameBox.svelte.d.ts +13 -0
- package/dist/components/boxes/game-box/gamebox.util.d.ts +32 -0
- package/dist/components/boxes/game-box/gamebox.util.js +83 -0
- package/dist/components/boxes/index.d.ts +2 -0
- package/dist/components/boxes/index.js +2 -0
- package/dist/components/boxes/virtual-viewport/VirtualViewport.svelte +199 -0
- package/dist/components/boxes/virtual-viewport/VirtualViewport.svelte.d.ts +20 -0
- package/dist/components/buttons/button/Button.svelte +75 -0
- package/dist/components/buttons/button/Button.svelte.d.ts +19 -0
- package/dist/components/buttons/button-text/TextButton.svelte +21 -0
- package/dist/components/buttons/button-text/TextButton.svelte.d.ts +5 -0
- package/dist/components/buttons/index.d.ts +2 -1
- package/dist/components/buttons/index.js +2 -1
- package/dist/components/hkdev/blocks/TextBlock.svelte +47 -0
- package/dist/components/hkdev/blocks/TextBlock.svelte.d.ts +11 -0
- package/dist/components/hkdev/buttons/CheckButton.svelte +63 -0
- package/dist/components/hkdev/buttons/CheckButton.svelte.d.ts +16 -0
- package/dist/components/icon/HkIcon.svelte +1 -1
- package/dist/components/icon/HkTabIcon.svelte +6 -2
- package/dist/components/image/EnhancedImage.svelte__ +1 -1
- package/dist/components/image/ResponsiveImage.svelte +1 -1
- package/dist/components/image/ResponsiveImage.svelte__ +1 -1
- package/dist/components/inputs/text-input/TestTextInput.svelte__ +2 -2
- package/dist/components/inputs/text-input/TextInput.svelte +1 -1
- package/dist/components/inputs/text-input/TextInput.svelte___ +1 -1
- package/dist/components/layout/HkGridLayers.svelte +1 -1
- package/dist/components/panels/plain-panel/PlainPanel.svelte +1 -1
- package/dist/components/rows/panel-grid-row/PanelGridRow.svelte +1 -1
- package/dist/components/rows/panel-row-2/PanelRow2.svelte +1 -1
- package/dist/components/tab-bar/HkTabBar.svelte +1 -1
- package/dist/components/tab-bar/HkTabBarSelector.svelte +1 -1
- package/dist/design-system/design-config.d.ts +156 -0
- package/dist/design-system/design-config.js +73 -0
- package/dist/design-system/tailwind-theme-extend.d.ts +23 -0
- package/dist/design-system/tailwind-theme-extend.js +151 -0
- package/dist/themes/hkdev/components/blocks/text-block.postcss +41 -0
- package/dist/themes/hkdev/components/buttons/button-text.postcss +34 -0
- package/dist/themes/hkdev/components/buttons/button.postcss +138 -0
- package/dist/themes/hkdev/components/buttons/button.postcss__ +40 -0
- package/dist/themes/hkdev/components/buttons/button.postcss___ +91 -0
- package/dist/themes/hkdev/components.postcss +8 -2
- package/dist/themes/hkdev/globals.postcss +5 -6
- package/dist/util/css/css-vars.d.ts +24 -0
- package/dist/util/css/css-vars.js +83 -0
- package/dist/util/css/index.d.ts +1 -0
- package/dist/util/css/index.js +1 -0
- package/dist/util/design-system/components/states.d.ts +15 -0
- package/dist/util/design-system/components/states.js +22 -0
- package/dist/util/design-system/css/clamp.d.ts +17 -0
- package/dist/util/design-system/css/clamp.js +66 -0
- package/dist/util/design-system/css/root-design-vars.d.ts +77 -0
- package/dist/util/design-system/css/root-design-vars.js +100 -0
- package/dist/util/design-system/index.d.ts +5 -0
- package/dist/util/design-system/index.js +5 -0
- package/dist/util/design-system/layout/scaling.d.ts +44 -0
- package/dist/util/design-system/layout/scaling.js +97 -0
- package/dist/util/design-system/tailwind.d.ts +176 -0
- package/dist/util/design-system/tailwind.js +289 -0
- package/package.json +1 -1
- package/dist/components/buttons/plain-button/PlainButton.svelte +0 -37
- package/dist/components/buttons/plain-button/PlainButton.svelte.d.ts +0 -10
- package/dist/config/tailwind.extend.d.ts +0 -56
- package/dist/config/tailwind.extend.js +0 -64
- package/dist/themes/hkdev/components/buttons/plain-button.postcss +0 -73
@@ -0,0 +1,100 @@
|
|
1
|
+
import { getRootCssVar } from '../../css/css-vars.js';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Generates a complete HTML style tag with CSS custom properties for
|
5
|
+
* the design system based on provided configuration.
|
6
|
+
*
|
7
|
+
* @param {Object} design - Design dimensions configuration
|
8
|
+
* @param {number} design.width - The design width in pixels
|
9
|
+
* @param {number} design.height - The design height in pixels
|
10
|
+
* @param {Object} clamping - Scaling configuration parameters
|
11
|
+
* @param {Object} clamping.ui - UI clamping configuration
|
12
|
+
* @param {number} clamping.ui.min - Minimum UI scaling factor
|
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
|
17
|
+
* @param {Object} clamping.textHeading - Heading text clamping configuration
|
18
|
+
* @param {number} clamping.textHeading.min - Minimum heading text scaling
|
19
|
+
* @param {number} clamping.textHeading.max - Maximum heading text scaling
|
20
|
+
* @param {Object} clamping.textUi - UI text clamping configuration
|
21
|
+
* @param {number} clamping.textUi.min - Minimum UI text scaling
|
22
|
+
* @param {number} clamping.textUi.max - Maximum UI text scaling
|
23
|
+
*
|
24
|
+
* @returns {string} Complete HTML style tag with design system CSS variables
|
25
|
+
*
|
26
|
+
* @example
|
27
|
+
* // +layout.svelte
|
28
|
+
* <script>
|
29
|
+
* import { DESIGN, CLAMPING } from '../../../tailwind/extend/clamping/config.js';
|
30
|
+
*
|
31
|
+
* import { rootDesignVarsHTML } from '../index.js';
|
32
|
+
* </script>
|
33
|
+
*
|
34
|
+
* <svelte:head>
|
35
|
+
* {@html rootDesignVarsHTML(DESIGN, CLAMPING)}
|
36
|
+
* </svelte:head>
|
37
|
+
*
|
38
|
+
* // Generates style tag for use in svelte:head
|
39
|
+
* // <style>:root { --design-width: 1920; ... }</style>
|
40
|
+
*/
|
41
|
+
export function rootDesignVarsHTML(design, clamping) {
|
42
|
+
return `<style>:root {
|
43
|
+
/* Design dimensions */
|
44
|
+
--design-width: ${design.width};
|
45
|
+
--design-height: ${design.height};
|
46
|
+
|
47
|
+
/* Base clamping units */
|
48
|
+
--scale-w: 1;
|
49
|
+
--scale-h: 1;
|
50
|
+
--scale-viewport: min(var(--scale-w), var(--scale-h));
|
51
|
+
|
52
|
+
/* Scaling factors with configurable clamping */
|
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});
|
55
|
+
--scale-text-heading: clamp(${clamping.textHeading.min}, var(--scale-viewport), ${clamping.textHeading.max});
|
56
|
+
--scale-text-ui: clamp(${clamping.textUi.min}, var(--scale-viewport), ${clamping.textUi.max});
|
57
|
+
}</style>`;
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Get design width from CSS variables
|
62
|
+
*
|
63
|
+
* @returns {number} Design width
|
64
|
+
*/
|
65
|
+
export function getRootCssDesignWidth() {
|
66
|
+
return getRootCssVar('design-width');
|
67
|
+
}
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Get design height from CSS variables
|
71
|
+
*
|
72
|
+
* @returns {number} Design height
|
73
|
+
*/
|
74
|
+
export function getRootCssDesignHeight() {
|
75
|
+
return getRootCssVar('design-height');
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Retrieves all current scaling factors from CSS variables
|
80
|
+
*
|
81
|
+
* @returns {Object} An object containing all scaling factors
|
82
|
+
*/
|
83
|
+
export function getAllRootScalingVars() {
|
84
|
+
const styles = getComputedStyle(document.documentElement);
|
85
|
+
|
86
|
+
return {
|
87
|
+
scaleW: parseFloat(styles.getPropertyValue('--scale-w').trim()) || 0,
|
88
|
+
scaleH: parseFloat(styles.getPropertyValue('--scale-h').trim()) || 0,
|
89
|
+
scaleViewport:
|
90
|
+
parseFloat(styles.getPropertyValue('--scale-viewport').trim()) || 0,
|
91
|
+
|
92
|
+
scaleUI: parseFloat(styles.getPropertyValue('--scale-ui').trim()) || 0,
|
93
|
+
scaleTextContent:
|
94
|
+
parseFloat(styles.getPropertyValue('--scale-text-content').trim()) || 0,
|
95
|
+
scaleTextHeading:
|
96
|
+
parseFloat(styles.getPropertyValue('--scale-text-heading').trim()) || 0,
|
97
|
+
scaleTextUI:
|
98
|
+
parseFloat(styles.getPropertyValue('--scale-text-ui').trim()) || 0
|
99
|
+
};
|
100
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/**
|
2
|
+
* Manages responsive design scaling by calculating and applying scale factors
|
3
|
+
* based on viewport dimensions and design system requirements.
|
4
|
+
*
|
5
|
+
* @param {Object} design - The base design dimensions
|
6
|
+
* @param {number} design.width - The reference design width
|
7
|
+
* @param {number} design.height - The reference design height
|
8
|
+
* @param {Object} clamping - The min/max values for various scale factors
|
9
|
+
* @param {Object} clamping.ui - UI element scaling constraints
|
10
|
+
* @param {number} clamping.ui.min - Minimum UI scale factor
|
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
|
15
|
+
* @param {Object} clamping.textHeading - Heading text scaling constraints
|
16
|
+
* @param {number} clamping.textHeading.min - Minimum heading text scale factor
|
17
|
+
* @param {number} clamping.textHeading.max - Maximum heading text scale factor
|
18
|
+
* @param {Object} clamping.textUi - UI text scaling constraints
|
19
|
+
* @param {number} clamping.textUi.min - Minimum UI text scale factor
|
20
|
+
* @param {number} clamping.textUi.max - Maximum UI text scale factor
|
21
|
+
*
|
22
|
+
* @returns {()=>void} A cleanup function that removes the event listener
|
23
|
+
*/
|
24
|
+
export function enableScalingUI(design: {
|
25
|
+
width: number;
|
26
|
+
height: number;
|
27
|
+
}, clamping: {
|
28
|
+
ui: {
|
29
|
+
min: number;
|
30
|
+
max: number;
|
31
|
+
};
|
32
|
+
textContent: {
|
33
|
+
min: number;
|
34
|
+
max: number;
|
35
|
+
};
|
36
|
+
textHeading: {
|
37
|
+
min: number;
|
38
|
+
max: number;
|
39
|
+
};
|
40
|
+
textUi: {
|
41
|
+
min: number;
|
42
|
+
max: number;
|
43
|
+
};
|
44
|
+
}): () => void;
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import { clamp } from '../css/clamp.js';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Manages responsive design scaling by calculating and applying scale factors
|
5
|
+
* based on viewport dimensions and design system requirements.
|
6
|
+
*
|
7
|
+
* @param {Object} design - The base design dimensions
|
8
|
+
* @param {number} design.width - The reference design width
|
9
|
+
* @param {number} design.height - The reference design height
|
10
|
+
* @param {Object} clamping - The min/max values for various scale factors
|
11
|
+
* @param {Object} clamping.ui - UI element scaling constraints
|
12
|
+
* @param {number} clamping.ui.min - Minimum UI scale factor
|
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
|
17
|
+
* @param {Object} clamping.textHeading - Heading text scaling constraints
|
18
|
+
* @param {number} clamping.textHeading.min - Minimum heading text scale factor
|
19
|
+
* @param {number} clamping.textHeading.max - Maximum heading text scale factor
|
20
|
+
* @param {Object} clamping.textUi - UI text scaling constraints
|
21
|
+
* @param {number} clamping.textUi.min - Minimum UI text scale factor
|
22
|
+
* @param {number} clamping.textUi.max - Maximum UI text scale factor
|
23
|
+
*
|
24
|
+
* @returns {()=>void} A cleanup function that removes the event listener
|
25
|
+
*/
|
26
|
+
export function enableScalingUI(design, clamping) {
|
27
|
+
/**
|
28
|
+
* Updates CSS scale variables based on current viewport dimensions
|
29
|
+
* and design system constraints
|
30
|
+
*/
|
31
|
+
function updateScaleValues() {
|
32
|
+
try {
|
33
|
+
const vw = window.innerWidth;
|
34
|
+
const vh = window.innerHeight;
|
35
|
+
|
36
|
+
// Calculate scale factors based on viewport size relative to design dimensions
|
37
|
+
const scaleW = vw / design.width;
|
38
|
+
const scaleH = vh / design.height;
|
39
|
+
|
40
|
+
// Use the smaller scale factor to ensure content fits within viewport
|
41
|
+
const scaleViewport = Math.min(scaleW, scaleH);
|
42
|
+
|
43
|
+
// Apply clamping to different element types
|
44
|
+
const scaleUI = clamp(scaleViewport, clamping.ui.min, clamping.ui.max);
|
45
|
+
|
46
|
+
const scaleTextContent = clamp(
|
47
|
+
scaleViewport,
|
48
|
+
clamping.textContent.min,
|
49
|
+
clamping.textContent.max
|
50
|
+
);
|
51
|
+
|
52
|
+
const scaleTextHeading = clamp(
|
53
|
+
scaleViewport,
|
54
|
+
clamping.textHeading.min,
|
55
|
+
clamping.textHeading.max
|
56
|
+
);
|
57
|
+
|
58
|
+
const scaleTextUi = clamp(
|
59
|
+
scaleViewport,
|
60
|
+
clamping.textUi.min,
|
61
|
+
clamping.textUi.max
|
62
|
+
);
|
63
|
+
|
64
|
+
// Set CSS custom properties for use in the design system
|
65
|
+
document.documentElement.style.setProperty('--scale-w', String(scaleW));
|
66
|
+
document.documentElement.style.setProperty('--scale-h', String(scaleH));
|
67
|
+
document.documentElement.style.setProperty(
|
68
|
+
'--scale-viewport',
|
69
|
+
String(scaleViewport)
|
70
|
+
);
|
71
|
+
document.documentElement.style.setProperty('--scale-ui', String(scaleUI));
|
72
|
+
document.documentElement.style.setProperty(
|
73
|
+
'--scale-text-content',
|
74
|
+
String(scaleTextContent)
|
75
|
+
);
|
76
|
+
document.documentElement.style.setProperty(
|
77
|
+
'--scale-text-heading',
|
78
|
+
String(scaleTextHeading)
|
79
|
+
);
|
80
|
+
document.documentElement.style.setProperty(
|
81
|
+
'--scale-text-ui',
|
82
|
+
String(scaleTextUi)
|
83
|
+
);
|
84
|
+
} catch (error) {
|
85
|
+
console.error('Error updating design scale values:', error);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
// Initialize scales and attach resize listener
|
90
|
+
updateScaleValues();
|
91
|
+
window.addEventListener('resize', updateScaleValues);
|
92
|
+
|
93
|
+
// Return cleanup function
|
94
|
+
return function cleanup() {
|
95
|
+
window.removeEventListener('resize', updateScaleValues);
|
96
|
+
};
|
97
|
+
}
|
@@ -0,0 +1,176 @@
|
|
1
|
+
/**
|
2
|
+
* Generates text-based spacing units with with different scaling
|
3
|
+
* units (ut, ct, ht)
|
4
|
+
*
|
5
|
+
* @param {number[]} values
|
6
|
+
* Array of pixel values to generate text-based spacing units for
|
7
|
+
*
|
8
|
+
* @returns {{[key: string]: string}}
|
9
|
+
* Generated text-based spacing units with ut, ct, and ht suffixes
|
10
|
+
*
|
11
|
+
* @throws {Error} If values is not an array or contains non-numeric values
|
12
|
+
*
|
13
|
+
* @example
|
14
|
+
* generateTextBasedSpacing([1, 2, 4, 8])
|
15
|
+
* // Returns:
|
16
|
+
* // {
|
17
|
+
* // '1ut': 'calc(1px * var(--scale-text-ui))',
|
18
|
+
* // '2ut': 'calc(2px * var(--scale-text-ui))',
|
19
|
+
* // '1ct': 'calc(1px * var(--scale-text-content))',
|
20
|
+
* // '2ct': 'calc(2px * var(--scale-text-content))',
|
21
|
+
* // '1ht': 'calc(1px * var(--scale-text-heading))',
|
22
|
+
* // '2ht': 'calc(2px * var(--scale-text-heading))'
|
23
|
+
* // }
|
24
|
+
*/
|
25
|
+
export function generateTextBasedSpacing(values: number[]): {
|
26
|
+
[key: string]: string;
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* Generates viewport-based spacing units with different scaling
|
30
|
+
* units (p, vp, wp, hp)
|
31
|
+
*
|
32
|
+
* @param {number[]} values
|
33
|
+
* Array of pixel values to generate viewport-based spacing units for
|
34
|
+
*
|
35
|
+
* @returns {Object.<string, string>}
|
36
|
+
* Generated viewport-based spacing units:
|
37
|
+
* - p: UI points (clamped scaling)
|
38
|
+
* - vp: Viewport points (min of width/height)
|
39
|
+
* - wp: Width points
|
40
|
+
* - hp: Height points
|
41
|
+
*
|
42
|
+
* @throws {Error} If values is not an array or contains non-numeric values
|
43
|
+
*
|
44
|
+
* @example
|
45
|
+
* generateViewportBasedSpacing([1, 2, 4])
|
46
|
+
* // Returns:
|
47
|
+
* // {
|
48
|
+
* // '1p': 'calc(1px * var(--scale-ui))',
|
49
|
+
* // '1vp': 'calc(1px * var(--scale-viewport))',
|
50
|
+
* // '1wp': 'calc(1px * var(--scale-w))',
|
51
|
+
* // '1hp': 'calc(1px * var(--scale-h))'
|
52
|
+
* // }
|
53
|
+
*/
|
54
|
+
export function generateViewportBasedSpacing(values: number[]): {
|
55
|
+
[x: string]: string;
|
56
|
+
};
|
57
|
+
/**
|
58
|
+
* Generates semantic text style definitions for a specific text category
|
59
|
+
* (content, UI, or heading). Each style includes a scaled font size and
|
60
|
+
* line height.
|
61
|
+
*
|
62
|
+
* @param {{[key: string]: {size: number, lineHeight?: number}}} sizes
|
63
|
+
* Set of text sizes to generate styles for
|
64
|
+
*
|
65
|
+
* @param {'content' | 'ui' | 'heading'} category
|
66
|
+
* Text category to generate styles for
|
67
|
+
*
|
68
|
+
* @returns {{[key: string]: [string, {lineHeight: number}]}}
|
69
|
+
* Generated text styles in Tailwind format
|
70
|
+
*
|
71
|
+
* @throws {Error} If a size has an invalid size or lineHeight
|
72
|
+
*
|
73
|
+
* @example
|
74
|
+
* const TEXT_CONTENT_SIZES = {
|
75
|
+
* sm: { size: 16, lineHeight: 1.5 },
|
76
|
+
* base: { size: 20, lineHeight: 1.5 },
|
77
|
+
* lg: { size: 24, lineHeight: 1.4 }
|
78
|
+
* };
|
79
|
+
*
|
80
|
+
* generateTextStyles(TEXT_CONTENT_SIZES, 'content');
|
81
|
+
* // Returns:
|
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 }]
|
89
|
+
* // }
|
90
|
+
*/
|
91
|
+
export function generateTextStyles(sizes: {
|
92
|
+
[key: string]: {
|
93
|
+
size: number;
|
94
|
+
lineHeight?: number;
|
95
|
+
};
|
96
|
+
}, category: "content" | "ui" | "heading"): {
|
97
|
+
[key: string]: [string, {
|
98
|
+
lineHeight: number;
|
99
|
+
}];
|
100
|
+
};
|
101
|
+
/**
|
102
|
+
* Generates border radius styles with UI scaling
|
103
|
+
*
|
104
|
+
* @param {{[key: string]: string | {size: number}}} sizes
|
105
|
+
* Set of radius sizes to generate, either as:
|
106
|
+
* - Object with size property (e.g., { size: 10 })
|
107
|
+
* - Direct string value (e.g., '0px', '9999px')
|
108
|
+
*
|
109
|
+
* @returns {Object.<string, string>}
|
110
|
+
* Generated border radius styles in Tailwind format
|
111
|
+
*
|
112
|
+
* @throws {Error} If a value has an invalid type
|
113
|
+
*
|
114
|
+
* @example
|
115
|
+
* const RADIUS_SIZES = {
|
116
|
+
* none: '0px',
|
117
|
+
* sm: { size: 10 },
|
118
|
+
* md: { size: 15 },
|
119
|
+
* full: '9999px'
|
120
|
+
* };
|
121
|
+
*
|
122
|
+
* generateBorderRadiusStyles(RADIUS_SIZES)
|
123
|
+
* // Returns:
|
124
|
+
* // {
|
125
|
+
* // 'none': '0px',
|
126
|
+
* // 'sm': 'calc(10px * var(--scale-ui))',
|
127
|
+
* // 'md': 'calc(15px * var(--scale-ui))',
|
128
|
+
* // 'full': '9999px'
|
129
|
+
* // }
|
130
|
+
*/
|
131
|
+
export function generateBorderRadiusStyles(sizes: {
|
132
|
+
[key: string]: string | {
|
133
|
+
size: number;
|
134
|
+
};
|
135
|
+
}): {
|
136
|
+
[x: string]: string;
|
137
|
+
};
|
138
|
+
/**
|
139
|
+
* Generates width styles for various CSS properties with UI scaling and explicit naming
|
140
|
+
*
|
141
|
+
* @param {{[key: string]: {size: number}}} sizes
|
142
|
+
* Set of width sizes to generate
|
143
|
+
*
|
144
|
+
* @param {string} [prefix='width']
|
145
|
+
* Prefix to add before each variant name (default: 'width')
|
146
|
+
*
|
147
|
+
* @param {string} scaleVar
|
148
|
+
* CSS variable to use for scaling (default: '--scale-ui')
|
149
|
+
*
|
150
|
+
* @returns {{[key: string]: string}}
|
151
|
+
* Generated width styles in Tailwind format
|
152
|
+
*
|
153
|
+
* @throws {Error} If a size has an invalid type
|
154
|
+
*
|
155
|
+
* @example
|
156
|
+
* const WIDTH_SIZES = {
|
157
|
+
* thin: { size: 1 },
|
158
|
+
* normal: { size: 2 },
|
159
|
+
* thick: { size: 4 }
|
160
|
+
* };
|
161
|
+
*
|
162
|
+
* generateWidthStyles(WIDTH_SIZES, 'width')
|
163
|
+
* // Returns:
|
164
|
+
* // {
|
165
|
+
* // 'width-thin': 'calc(1px * var(--scale-ui))',
|
166
|
+
* // 'width-normal': 'calc(2px * var(--scale-ui))',
|
167
|
+
* // 'width-thick': 'calc(4px * var(--scale-ui))'
|
168
|
+
* // }
|
169
|
+
*/
|
170
|
+
export function generateWidthStyles(sizes: {
|
171
|
+
[key: string]: {
|
172
|
+
size: number;
|
173
|
+
};
|
174
|
+
}, prefix?: string, scaleVar?: string): {
|
175
|
+
[key: string]: string;
|
176
|
+
};
|