Skip to content
Browse files

Merge branch 'master' of git://github.com/Harrison/retinajs into Harr…

…ison-master
  • Loading branch information...
2 parents fe791bc + 0a44042 commit ee6f6d750df3bbe52c4d15e15af2bc3c3e3f80ae Casey O'Hara committed Aug 20, 2012
Showing with 50 additions and 4 deletions.
  1. +2 −1 package.json
  2. +3 −3 src/retina.less
  3. +18 −0 test/fixtures/desired_output.css
  4. +10 −0 test/fixtures/test.less
  5. +17 −0 test/retina_less.test.js
View
3 package.json
@@ -3,7 +3,8 @@
"version": "0.0.2",
"devDependencies": {
"mocha": "*",
- "should": "*"
+ "should": "*",
+ "less": "*"
},
"main": "./src/retina",
"scripts": {
View
6 src/retina.less
@@ -5,10 +5,10 @@
.at2x(@path, @w: auto, @h: auto) {
background-image: url(@path);
- @at2x_path: ~`"@{path}".replace(/\.\w+$/, function(match) { return "@2x" + match; })`;
+ @at2x_path: ~`@{path}.replace(/\.\w+$/, function(match) { return "@2x" + match; })`;
@media @highdpi {
- background-image: url(@at2x_path);
+ background-image: url("@{at2x_path}");
background-size: @w @h;
}
-}
+}
View
18 test/fixtures/desired_output.css
@@ -0,0 +1,18 @@
+body {
+ background-image: url('/path/to/image.png');
+}
+@media (-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx) {
+ body {
+ background-image: url("/path/to/image@2x.png");
+ background-size: 200px 100px;
+ }
+}
+header {
+ background-image: url("/path/to/header.png");
+}
+@media (-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx) {
+ header {
+ background-image: url("/path/to/header@2x.png");
+ background-size: 600px 50px;
+ }
+}
View
10 test/fixtures/test.less
@@ -0,0 +1,10 @@
+@import 'src/retina';
+
+// Single quoted
+body {
+ .at2x('/path/to/image.png', 200px, 100px);
+}
+// Double quoted
+header {
+ .at2x("/path/to/header.png", 600px, 50px);
+}
View
17 test/retina_less.test.js
@@ -0,0 +1,17 @@
+var fs = require('fs');
+var less = require('less');
+
+describe('retina.less', function() {
+
+ describe('.at2x()', function(){
+ it('compiles correctly', function(done){
+ var desired_output = fs.readFileSync('test/fixtures/desired_output.css', 'utf8');
+ var input = fs.readFileSync('test/fixtures/test.less', 'utf8');
+ less.render(input, function (e, actual_output) {
+ actual_output.should.equal(desired_output);
+ done();
+ });
+ });
+ });
+
+});

0 comments on commit ee6f6d7

Please sign in to comment.
Something went wrong with that request. Please try again.