Sha256: d378d5905af119be3a1f23d3ea7cf67e4c5cc94ece080e9e9b9bfe10785834e5
Contents?: true
Size: 1.34 KB
Versions: 5
Compression:
Stored size: 1.34 KB
Contents
/** * Heroku-Patterns - v0.2.0 - 2017 * * , and the web community. * Licensed under the license. * * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * **/(function () { "use strict"; var diveSync = require('diveSync'), path = require('path'), fs = require('fs-extra'); var media_hunter = function(){ function findMediaQueries(dir, patternlab){ patternlab.mediaQueries = []; diveSync(dir, function(err, file){ if(path.extname(file) === '.css'){ var contents = fs.readFileSync(file, 'utf8'); var safeContents = contents.replace("\r", " ").replace("\n", " "); var matches = safeContents.match(/\((min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/g); for(var i = 0; i < matches.length; i++){ var breakpoint = matches[i].substring(matches[i].indexOf(':') + 1).trimLeft(); if(patternlab.mediaQueries.indexOf(breakpoint) === -1){ patternlab.mediaQueries.push(breakpoint); } } } }); patternlab.mediaQueries.sort(function(a,b){ var integerPartA = a.match(/(?:\d*\.)?\d+/g); var integerPartB = b.match(/(?:\d*\.)?\d+/g); return parseInt(a,10) > parseInt(b,10); }); } return { find_media_queries: function(dir, patternlab){ findMediaQueries(dir, patternlab); } }; }; module.exports = media_hunter; }());
Version data entries
5 entries across 5 versions & 1 rubygems