esm-styles 0.1.0 → 0.1.2
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/index.js +1 -1
- package/dist/lib/getCss.js +9 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,5 +14,5 @@ export { jsKeyToCssKey, isEndValue } from './lib/utils/common.js';
|
|
|
14
14
|
export { processMediaQueries } from './lib/utils/media.js';
|
|
15
15
|
export { obj2css, prettifyCss } from './lib/utils/obj2css.js';
|
|
16
16
|
export function greet() {
|
|
17
|
-
return '
|
|
17
|
+
return 'esm-styles 0.1.2';
|
|
18
18
|
}
|
package/dist/lib/getCss.js
CHANGED
|
@@ -22,7 +22,7 @@ export function getCss(object, mediaQueries = {}, mediaPrefixes = {}, auto) {
|
|
|
22
22
|
const layerStatements = [];
|
|
23
23
|
let layerObject = {};
|
|
24
24
|
let containerObject = {};
|
|
25
|
-
|
|
25
|
+
const mediaObject = {};
|
|
26
26
|
let prefixObject = {};
|
|
27
27
|
// Process the object by traversing it and handling different node types
|
|
28
28
|
traverseObject(object, (node, path, _, __) => {
|
|
@@ -119,10 +119,14 @@ export function getCss(object, mediaQueries = {}, mediaPrefixes = {}, auto) {
|
|
|
119
119
|
console.warn(`Warning: Media query type ${key} is unknown`);
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
// Store the media query with the selector and node
|
|
123
|
+
// This way we collect all the rules for each media query
|
|
124
|
+
const mediaQueryKey = '@media ' + mediaQuery;
|
|
125
|
+
if (!mediaObject[mediaQueryKey]) {
|
|
126
|
+
mediaObject[mediaQueryKey] = {};
|
|
127
|
+
}
|
|
128
|
+
// Add the selector and its rules to this media query
|
|
129
|
+
mediaObject[mediaQueryKey] = mergeDeep(mediaObject[mediaQueryKey], { [selector]: node });
|
|
126
130
|
}
|
|
127
131
|
break;
|
|
128
132
|
}
|