Skip to content

Commit

Permalink
feat: improve snake nesting .s
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 24, 2018
1 parent ee296ed commit 1e2409e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
60 changes: 60 additions & 0 deletions addon/__tests__/snake.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,64 @@ describe('snake', function () {
background: 'red'
});
});

it('.relative', function () {
var nano = createNano();

expect(nano.s.rel.obj).toEqual({
position: 'relative',
});
});

describe('accents', function () {
it('semantic', function () {
var nano = createNano();

expect(nano.s.bold.italic.underline.obj).toEqual({
fontStyle: 'italic',
fontWeight: 'bold',
textDecoration: 'underline',
});
});

it('shorhand', function () {
var nano = createNano();

expect(nano.s.b.i.u.obj).toEqual({
fontStyle: 'italic',
fontWeight: 'bold',
textDecoration: 'underline',
});
});
});

describe('.s', function () {
it('any value', function () {
var nano = createNano();

expect(nano.s.s('box-shadow', '0 0 3px black').obj).toEqual({
'box-shadow': '0 0 3px black',
});
});

it('nesting', function () {
var nano = createNano();

expect(nano.s.s(':hover', nano.s.u.obj).obj).toEqual({
':hover': {
textDecoration: 'underline'
}
});
});

it('nesting shorthand', function () {
var nano = createNano();

expect(nano.s.s(':hover', nano.s.u).obj).toEqual({
':hover': {
textDecoration: 'underline'
}
});
});
});
});
6 changes: 5 additions & 1 deletion addon/snake.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports.addon = function (renderer, rules) {

var defaultRules = renderer.assign({}, atoms, {
s: function (prop, value) {
this[prop] = value;
this[prop] = (value instanceof Object) ? (value.obj || value) : value;
},

bgWhite: function () {
Expand All @@ -19,6 +19,10 @@ exports.addon = function (renderer, rules) {
this.backgroundColor = '#000';
},

rel: function () {
this.position = 'relative';
},

pointer: function () {
this.cursor = 'pointer';
},
Expand Down

0 comments on commit 1e2409e

Please sign in to comment.