@latte-macchiat-io/latte-vanilla-components 0.0.325 → 0.0.326
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/package.json
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
// utils/generateResponsive.ts
|
1
2
|
import { queries } from '../styles/mediaqueries';
|
2
3
|
|
3
4
|
type BreakpointKey = 'mobile' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
@@ -44,10 +45,12 @@ export function generateResponsive(
|
|
44
45
|
result[media][cssProp] = toCssValue(token);
|
45
46
|
}
|
46
47
|
} else {
|
48
|
+
// single value => apply to all breakpoints
|
49
|
+
const token = valOrMap as ResponsiveValue;
|
47
50
|
for (const bp of BPS) {
|
48
51
|
const media = queries[bp as keyof typeof queries];
|
49
52
|
if (!result[media]) result[media] = {};
|
50
|
-
result[media][cssProp] = toCssValue(
|
53
|
+
result[media][cssProp] = toCssValue(token);
|
51
54
|
}
|
52
55
|
}
|
53
56
|
}
|
@@ -57,8 +60,16 @@ export function generateResponsive(
|
|
57
60
|
for (const { property, base, offset, operator = '+' } of calcProps) {
|
58
61
|
for (const bp of BPS) {
|
59
62
|
const media = queries[bp as keyof typeof queries];
|
60
|
-
|
61
|
-
|
63
|
+
|
64
|
+
// ✅ TypeScript safe access
|
65
|
+
const baseValue =
|
66
|
+
typeof base === 'object' && !Array.isArray(base) ? ((base as BreakpointMap)[bp] ?? Object.values(base as BreakpointMap)[0]) : base;
|
67
|
+
|
68
|
+
const offsetValue =
|
69
|
+
typeof offset === 'object' && !Array.isArray(offset)
|
70
|
+
? ((offset as BreakpointMap)[bp] ?? Object.values(offset as BreakpointMap)[0])
|
71
|
+
: offset;
|
72
|
+
|
62
73
|
if (!result[media]) result[media] = {};
|
63
74
|
result[media][property] = `calc(${baseValue} ${operator} ${offsetValue})`;
|
64
75
|
}
|