stylecow-plugin-custom-media
Advanced tools
Comparing version 1.1.0 to 1.1.1
29
index.js
module.exports = function (stylecow) { | ||
//Save all custom-media in the root | ||
var allCustomMedia = {}; | ||
//Reset customMedia variable | ||
stylecow.addTask({ | ||
position: 'before', | ||
fn: function (root) { | ||
allCustomMedia = {}; | ||
} | ||
}); | ||
//Save all custom-media | ||
stylecow.addTask({ | ||
filter: { | ||
@@ -10,5 +20,3 @@ type: 'AtRule', | ||
fn: function (customMedia) { | ||
var root = customMedia.getParent('Root'); | ||
root.setData('@custom-media-' + customMedia.get('ExtensionName').name, customMedia.get('MediaQueries')); | ||
allCustomMedia[customMedia.get('ExtensionName').name] = customMedia.get('MediaQuery'); | ||
customMedia.detach(); | ||
@@ -28,6 +36,13 @@ } | ||
.forEach(function (extension) { | ||
var mediaqueries = extension.getData('@custom-media-' + extension.name); | ||
var mediaquery = allCustomMedia[extension.name]; | ||
if (mediaqueries) { | ||
extension.getParent('ConditionalExpression').replaceWith(mediaqueries.clone()); | ||
if (mediaquery) { | ||
var expression = extension.getParent('ConditionalExpression'); | ||
mediaquery.forEach(function (child) { | ||
expression.before(child.clone()); | ||
}); | ||
expression.detach(); | ||
//extension.getParent('ConditionalExpression').replaceWith(mediaqueries.clone()); | ||
} | ||
@@ -34,0 +49,0 @@ }); |
{ | ||
"name": "stylecow-plugin-custom-media", | ||
"description": "Stylecow plugin to work with @custom-media", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"author": "Oscar Otero <oom@oscarotero.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/stylecow/stylecow-plugin-custom-media", |
@@ -15,29 +15,19 @@ { | ||
{ | ||
"class": "MediaQueries", | ||
"class": "ConditionalExpression", | ||
"children": [ | ||
{ | ||
"class": "MediaQuery", | ||
"class": "ConditionalFeature", | ||
"name": "max-width", | ||
"vendor": null, | ||
"children": [ | ||
{ | ||
"class": "ConditionalExpression", | ||
"class": "Value", | ||
"children": [ | ||
{ | ||
"class": "ConditionalFeature", | ||
"name": "max-width", | ||
"vendor": null, | ||
"class": "Unit", | ||
"name": "em", | ||
"children": [ | ||
{ | ||
"class": "Value", | ||
"children": [ | ||
{ | ||
"class": "Unit", | ||
"name": "em", | ||
"children": [ | ||
{ | ||
"class": "Number", | ||
"name": 30 | ||
} | ||
] | ||
} | ||
] | ||
"class": "Number", | ||
"name": 30 | ||
} | ||
@@ -44,0 +34,0 @@ ] |
@@ -15,29 +15,19 @@ { | ||
{ | ||
"class": "MediaQueries", | ||
"class": "ConditionalExpression", | ||
"children": [ | ||
{ | ||
"class": "MediaQuery", | ||
"class": "ConditionalFeature", | ||
"name": "min-width", | ||
"vendor": null, | ||
"children": [ | ||
{ | ||
"class": "ConditionalExpression", | ||
"class": "Value", | ||
"children": [ | ||
{ | ||
"class": "ConditionalFeature", | ||
"name": "min-width", | ||
"vendor": null, | ||
"class": "Unit", | ||
"name": "px", | ||
"children": [ | ||
{ | ||
"class": "Value", | ||
"children": [ | ||
{ | ||
"class": "Unit", | ||
"name": "px", | ||
"children": [ | ||
{ | ||
"class": "Number", | ||
"name": 100 | ||
} | ||
] | ||
} | ||
] | ||
"class": "Number", | ||
"name": 100 | ||
} | ||
@@ -58,29 +48,19 @@ ] | ||
{ | ||
"class": "MediaQueries", | ||
"class": "ConditionalExpression", | ||
"children": [ | ||
{ | ||
"class": "MediaQuery", | ||
"class": "ConditionalFeature", | ||
"name": "max-width", | ||
"vendor": null, | ||
"children": [ | ||
{ | ||
"class": "ConditionalExpression", | ||
"class": "Value", | ||
"children": [ | ||
{ | ||
"class": "ConditionalFeature", | ||
"name": "max-width", | ||
"vendor": null, | ||
"class": "Unit", | ||
"name": "px", | ||
"children": [ | ||
{ | ||
"class": "Value", | ||
"children": [ | ||
{ | ||
"class": "Unit", | ||
"name": "px", | ||
"children": [ | ||
{ | ||
"class": "Number", | ||
"name": 1000 | ||
} | ||
] | ||
} | ||
] | ||
"class": "Number", | ||
"name": 1000 | ||
} | ||
@@ -87,0 +67,0 @@ ] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19979
22
659