extract-breakpoints
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -32,18 +32,20 @@ var parser = require('css').parse | ||
mqs | ||
.map(mediaQuery) | ||
.forEach(function (mq) { | ||
if (mq.minWidth > 0) { | ||
if (-1 === breakpoints.indexOf(mq.minWidth)) { | ||
breakpoints.push(mq.minWidth) | ||
} | ||
mqs = mqs.map(mediaQuery) | ||
mqs.forEach(function (mq) { | ||
if (mq.minWidth > 0) { | ||
if (-1 === breakpoints.indexOf(mq.minWidth)) { | ||
breakpoints.push(mq.minWidth) | ||
} | ||
if (mq.maxWidth !== Infinity) { | ||
var minWidth = mq.maxWidth + 1 | ||
} | ||
}) | ||
mqs.forEach(function (mq) { | ||
if (mq.maxWidth !== Infinity) { | ||
var minWidth = mq.maxWidth + 1 | ||
if (-1 === breakpoints.indexOf(mq.maxWidth) && -1 === breakpoints.indexOf(minWidth)) { | ||
breakpoints.push(mq.maxWidth) | ||
} | ||
if (-1 === breakpoints.indexOf(mq.maxWidth) && -1 === breakpoints.indexOf(minWidth)) { | ||
breakpoints.push(mq.maxWidth) | ||
} | ||
}) | ||
} | ||
}) | ||
@@ -50,0 +52,0 @@ return breakpoints.sort(function (a, b) { |
module.exports = function convertValue(value, previous) { | ||
var val = String(value).replace(/^(\d+)(em|px|rem)?$/i, function (m, d, unit) { | ||
var val = String(value).replace(/^([\d.]+)(em|px|rem)?$/i, function (m, d, unit) { | ||
if (! unit) { | ||
@@ -4,0 +4,0 @@ return d |
{ | ||
"name": "extract-breakpoints", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Extract CSS breakpoints from responsive sites", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,2 +16,8 @@ var fs = require('fs') | ||
}) | ||
lab.test('"rem" to "px"', function (done) { | ||
expect(convertValue('20.345rem')).to.equal(325.52) | ||
done() | ||
}) | ||
}) |
@@ -24,2 +24,9 @@ var fs = require('fs') | ||
}) | ||
lab.test('screen and (min-width: 0) and (max-width: 37.4375rem)', function (done) { | ||
expect(parse('screen and (min-width: 0) and (max-width: 37.4375rem)')).to.include({ | ||
maxWidth: 599 | ||
}) | ||
done() | ||
}) | ||
}) |
4718
152