From 1236c4b309836e921a5d3f15827fafe37d203105 Mon Sep 17 00:00:00 2001 From: Daniel Lamb Date: Wed, 29 Apr 2015 20:25:09 -0700 Subject: [PATCH] simplified the CSS reset and shaved down the file size --- README.md | 2 +- bower.json | 2 +- console.style.js | 8 +------ console.style.min.js | 2 +- demo/index.html | 2 +- package.json | 2 +- test/spec/console.style.spec.js | 40 ++++++++++++++++----------------- 7 files changed, 26 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index f64ffa8..65041d2 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ As you can see it quickly gets out of hand. You must explicitly reset each style ## There is a better way! -With `console.style` each individual CSS rule is first applied, then automatically reset for you. +With `console.style` first the CSS rules are applied, then all are automatically reset for you. ###[Check out some live examples](http://daniellmb.github.io/console.style/demo/index.html) diff --git a/bower.json b/bower.json index 9e4ee9f..d2255df 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "console.style", - "version": "0.2.0", + "version": "0.2.1", "main": "console.style.js", "ignore": [ ".editorconfig", diff --git a/console.style.js b/console.style.js index a876115..acdc3c7 100644 --- a/console.style.js +++ b/console.style.js @@ -64,8 +64,6 @@ return wrap('', styles.join(';')); }); args[0] = text.replace(rxTags, function(matchT, $1T, $2T, $3T) { - var styles = []; - var resets = []; $2T = $2T || ''; $3T = $3T.replace(rxTokens, ''); switch ($1T) { @@ -76,11 +74,7 @@ $2T += ';font-style:italic'; break; } - $2T.replace(rxRules, function(matchR, $1R, $2R) { - styles.push($1R + ':' + $2R); - resets.push($1R + ':inherit'); - }); - args.push(styles.join(';'), resets.join(';')); + args.push($2T, ''); return '%c' + $3T + '%c'; }); } diff --git a/console.style.min.js b/console.style.min.js index 5c87b2c..b180f03 100644 --- a/console.style.min.js +++ b/console.style.min.js @@ -1 +1 @@ -(function(b,a){'function'===typeof define&&define.amd?define([],a):a()})(this,function(){!function(e){if(e&&e.log){var n,c,i="Black Blue Cyan Gray Green Magenta Red White Yellow".split(" "),t=/<(css|b|i)(?:=['"](.*?)['"])?>(.*?)<\/(?:css|b|i)>/gi,r=/([a-z\-]+)\s?:\s?([^;'"]+);?/gi,s=/%[sdifoO]/g,a=//gi,o="background",l="px",u=function(e){var n=[e];return"string"==typeof e&&(e=e.replace(a,function(e,n){var i,t,s,a,u=["font-size:1px"];return n.replace(r,function(e,n,c){switch(n){case o:case o+"-image":u.push(n+":"+c,o+"-repeat:no-repeat");break;case"width":i=c;break;case"height":t=c,u.push("line-height:"+c)}}),a=Math.ceil(parseInt(i)/2),s=Math.ceil(parseInt(t)/2),u.push(o+"-size:"+i+" "+t),u.push("padding:"+s+l+" "+a+l),c("",u.join(";"))}),n[0]=e.replace(t,function(e,c,i,t){var a=[],o=[];switch(i=i||"",t=t.replace(s,""),c){case"b":i+=";font-weight:bold";break;case"i":i+=";font-style:italic"}return i.replace(r,function(e,n,c){a.push(n+":"+c),o.push(n+":inherit")}),n.push(a.join(";"),o.join(";")),"%c"+t+"%c"})),n};e.colors={},i.forEach(function(n){e.colors[n.toLowerCase()]=function(e){return c(e,"color:"+n)},e.colors["bg"+n]=function(e){return c(e,o+"-color:"+n)}}),e.style=n=function(){var n=[].slice.call(arguments);e.log.apply(e,u(n.shift()).concat(n))},e.style.wrap=c=function(e,n){return''+e+""}}}(window.console);}); +(function(b,a){'function'===typeof define&&define.amd?define([],a):a()})(this,function(){!function(e){if(e&&e.log){var c,n,t="Black Blue Cyan Gray Green Magenta Red White Yellow".split(" "),i=/<(css|b|i)(?:=['"](.*?)['"])?>(.*?)<\/(?:css|b|i)>/gi,s=/([a-z\-]+)\s?:\s?([^;'"]+);?/gi,a=/%[sdifoO]/g,r=//gi,o="background",l="px",u=function(e){var c=[e];return"string"==typeof e&&(e=e.replace(r,function(e,c){var t,i,a,r,u=["font-size:1px"];return c.replace(s,function(e,c,n){switch(c){case o:case o+"-image":u.push(c+":"+n,o+"-repeat:no-repeat");break;case"width":t=n;break;case"height":i=n,u.push("line-height:"+n)}}),r=Math.ceil(parseInt(t)/2),a=Math.ceil(parseInt(i)/2),u.push(o+"-size:"+t+" "+i),u.push("padding:"+a+l+" "+r+l),n("",u.join(";"))}),c[0]=e.replace(i,function(e,n,t,i){switch(t=t||"",i=i.replace(a,""),n){case"b":t+=";font-weight:bold";break;case"i":t+=";font-style:italic"}return c.push(t,""),"%c"+i+"%c"})),c};e.colors={},t.forEach(function(c){e.colors[c.toLowerCase()]=function(e){return n(e,"color:"+c)},e.colors["bg"+c]=function(e){return n(e,o+"-color:"+c)}}),e.style=c=function(){var c=[].slice.call(arguments);e.log.apply(e,u(c.shift()).concat(c))},e.style.wrap=n=function(e,c){return''+e+""}}}(window.console);}); diff --git a/demo/index.html b/demo/index.html index 48a47e3..fc9c20a 100644 --- a/demo/index.html +++ b/demo/index.html @@ -7,7 +7,7 @@

Open the browser console to see what console.style can do for you!

- +