-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(less): pixel pattern element size match to appearance, closes #1
- Loading branch information
Mateusz Derks
committed
Dec 20, 2014
1 parent
9613853
commit f003116
Showing
12 changed files
with
277 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ node_modules | |
|
||
# Users Environment Variables | ||
.lock-wscript | ||
bower_components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: nodejs | ||
before_script: | ||
- npm install | ||
- npm install -g grunt-cli | ||
- npm install -g bower | ||
- bower install | ||
script: | ||
- npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "pixel-pattern-generator", | ||
"version": "0.0.2", | ||
"homepage": "https://ertrzyiks.github.io/pixel-pattern-generator", | ||
"authors": [ | ||
"Mateusz Derks <mateusz.derks@gmail.com>" | ||
], | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"spec", | ||
"docs", | ||
"tasks" | ||
], | ||
"devDependencies": { | ||
"less-1.7.5": "less#1.7.5", | ||
"less-2.0.0": "less#2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
function loadFile(url, done) { | ||
var xhr = new XMLHttpRequest(); | ||
|
||
xhr.onload = function(){ | ||
return done(null, this.responseText); | ||
}; | ||
|
||
xhr.onerror = function(err){ | ||
return done(err, this.responseText); | ||
}; | ||
|
||
xhr.open("GET", url, true); | ||
xhr.send(); | ||
} | ||
|
||
function renderLess(code, done) { | ||
var parser; | ||
|
||
if ('function' === typeof less.render) { | ||
less | ||
.render(code) | ||
.then(function (result) { | ||
done(null, result.css); | ||
}) | ||
.catch(function (err) { | ||
done(err); | ||
}); | ||
} else { | ||
parser = new (less.Parser); | ||
parser.parse(code, function (e, tree) { | ||
if (e) { | ||
return done(e); | ||
} | ||
|
||
done(null, tree.toCSS()); | ||
}); | ||
} | ||
} | ||
|
||
function renderLessWithLibrary(code, done) { | ||
loadFile('src/less/pixel-pattern.less', function (err, libcode) { | ||
renderLess(libcode + '\n' + code, done); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
describe('Pixel Pattern Generator', function () { | ||
describe('pixel-pattern-set-pixel', function () { | ||
it('should render 0,0 pixel background color', function (done) { | ||
renderLessWithLibrary('.mypixel{ .pixel-pattern-set-pixel(0, 0, #ff0000); }', function (err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toContain('background-color: #ff0000;'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should render other pixels as shadow', function (done) { | ||
renderLessWithLibrary('.mypixel{ .pixel-pattern-set-pixel(1, 0, #ff0000); }', function (err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toContain('0em 1em #ff0000'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('pixel-pattern', function () { | ||
it('should render all pixels', function (done) { | ||
renderLessWithLibrary('.mypixel{ .pixel-pattern(1 0 #ff0000, 0 1 #00ff00); }', function (err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toContain('0em 1em #ff0000, 1em 0em #00ff00;'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should force container width to contain all pixels', function (done) { | ||
renderLessWithLibrary('.mypixel{ .pixel-pattern(0 10 #ff0000, 15 0 #00ff00); }', function (err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toContain('width: 11em;'); | ||
expect(css).toContain('height: 16em;'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('pixel-pattern-size', function () { | ||
it('should set font size in pixels', function (done) { | ||
renderLessWithLibrary('.mypixel{ .pixel-pattern-size(25px); }', function (err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toContain('font-size: 25px;') | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should set font size in ems', function (done) { | ||
renderLessWithLibrary('.mypixel{ .pixel-pattern-size(2em); }', function (err, css) { | ||
expect(err).toBe(null); | ||
expect(css).toContain('font-size: 2em;'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters