Skip to content

Commit

Permalink
fix: improve kebab case conversion
Browse files Browse the repository at this point in the history
* Properly kebab ms prefix

Also added test

* Trying to support virtual keyframes

It kinda works but I'm not sure how to generate the CSS from the object correctly.

* Formatted

* Use the correct renderer method to render keyframes.
  • Loading branch information
TheBosZ authored and streamich committed Sep 18, 2018
1 parent 380f65f commit 1819a14
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions addon/__tests__/virtual.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var env = require('./env');
var create = require('../../index').create;
var addonRule = require('../../addon/rule').addon;
var addonVirtual = require('../../addon/virtual').addon;
var addonKeyframes = require('../../addon/keyframes').addon;

function createNano (config) {
var nano = create(config);
Expand Down Expand Up @@ -192,5 +193,33 @@ describe('virtual', function () {
expect(nano.atomic).toHaveBeenCalledTimes(1);
expect(nano.atomic).toHaveBeenCalledWith('&', 'color:blue', undefined);
});

it('doesn\'t break keyframes', function() {
var nano = createNano();
addonKeyframes(nano);

nano.virtual('&', {
animation: 'sk-foldCubeAngle 2.4s infinite linear both',
'@keyframes sk-foldCubeAngle': {
'0%, 10%': {
transform: 'perspective(140px) rotateX(-180deg)',
opacity: 0
},
'25%, 75%': {
transform: 'perspective(140px) rotateX(0deg)',
opacity: 1
},
'90%, 100%': {
transform: 'perspective(140px) rotateY(180deg)',
opacity: 0
}
}
});

if (env.isServer) {
expect(nano.raw).toEqual('._a{animation:sk-foldCubeAngle 2.4s infinite linear both}@-webkit-keyframes sk-foldCubeAngle{0%, 10%{transform:perspective(140px) rotateX(-180deg);opacity:0;}25%, 75%{transform:perspective(140px) rotateX(0deg);opacity:1;}90%, 100%{transform:perspective(140px) rotateY(180deg);opacity:0;}}@-moz-keyframes sk-foldCubeAngle{0%, 10%{transform:perspective(140px) rotateX(-180deg);opacity:0;}25%, 75%{transform:perspective(140px) rotateX(0deg);opacity:1;}90%, 100%{transform:perspective(140px) rotateY(180deg);opacity:0;}}@-o-keyframes sk-foldCubeAngle{0%, 10%{transform:perspective(140px) rotateX(-180deg);opacity:0;}25%, 75%{transform:perspective(140px) rotateX(0deg);opacity:1;}90%, 100%{transform:perspective(140px) rotateY(180deg);opacity:0;}}@keyframes sk-foldCubeAngle{0%, 10%{transform:perspective(140px) rotateX(-180deg);opacity:0;}25%, 75%{transform:perspective(140px) rotateX(0deg);opacity:1;}90%, 100%{transform:perspective(140px) rotateY(180deg);opacity:0;}}');

}
});
});
});
5 changes: 5 additions & 0 deletions addon/virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ exports.addon = function (renderer) {
for (var prop in decls) {
var value = decls[prop];

if (prop.indexOf('keyframes') > -1) {
renderer.putAt('', value, prop);
continue;
}

if ((value instanceof Object) && !(value instanceof Array)) {
if (prop[0] === '@') {
classNames += renderer.virtual(selectorTemplate, value, prop);
Expand Down

1 comment on commit 1819a14

@streamich
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build version: 3.2.1-master.91 🤞 master on CircleCI 🎉

Please sign in to comment.