fela-plugin-embedded
Advanced tools
Comparing version 5.0.6 to 5.1.0
@@ -0,1 +1,3 @@ | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
@@ -5,2 +7,14 @@ | ||
function renderFontFace(_ref, renderer) { | ||
var fontFamily = _ref.fontFamily, | ||
src = _ref.src, | ||
otherProps = _objectWithoutProperties(_ref, ['fontFamily', 'src']); | ||
if (typeof fontFamily === 'string' && Array.isArray(src)) { | ||
return renderer.renderFont(fontFamily, src, otherProps); | ||
} | ||
// TODO: warning - invalid font data | ||
} | ||
function embedded(style, type, renderer) { | ||
@@ -10,17 +24,27 @@ var _loop = function _loop(property) { | ||
if (property === 'fontFace' && isObject(value)) { | ||
var fontFamily = value.fontFamily, | ||
src = value.src, | ||
otherProps = _objectWithoutProperties(value, ['fontFamily', 'src']); | ||
if (typeof fontFamily === 'string' && Array.isArray(src)) { | ||
style.fontFamily = renderer.renderFont(fontFamily, src, otherProps); | ||
delete style.fontFace; | ||
if (property === 'fontFace' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { | ||
if (Array.isArray(value)) { | ||
style.fontFamily = value.map(function (fontFace) { | ||
return renderFontFace(fontFace, renderer); | ||
}) | ||
// we filter font faces to remove invalid formats | ||
.filter(function (fontFace) { | ||
return fontFace; | ||
}).join(','); | ||
} else { | ||
// TODO: warning - invalid font data | ||
style.fontFamily = renderFontFace(value, renderer); | ||
} | ||
} else if (property === 'animationName' && isObject(value)) { | ||
style[property] = renderer.renderKeyframe(function () { | ||
return value; | ||
}); | ||
delete style.fontFace; | ||
} else if (property === 'animationName' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { | ||
if (Array.isArray(value)) { | ||
style[property] = value.map(function (frame) { | ||
return renderer.renderKeyframe(function () { | ||
return frame; | ||
}); | ||
}).join(','); | ||
} else { | ||
style[property] = renderer.renderKeyframe(function () { | ||
return value; | ||
}); | ||
} | ||
} else if (isObject(value)) { | ||
@@ -27,0 +51,0 @@ embedded(value, type, renderer); |
@@ -7,2 +7,4 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _felaUtils = require('fela-utils'); | ||
@@ -12,2 +14,14 @@ | ||
function renderFontFace(_ref, renderer) { | ||
var fontFamily = _ref.fontFamily, | ||
src = _ref.src, | ||
otherProps = _objectWithoutProperties(_ref, ['fontFamily', 'src']); | ||
if (typeof fontFamily === 'string' && Array.isArray(src)) { | ||
return renderer.renderFont(fontFamily, src, otherProps); | ||
} | ||
// TODO: warning - invalid font data | ||
} | ||
function embedded(style, type, renderer) { | ||
@@ -17,17 +31,27 @@ var _loop = function _loop(property) { | ||
if (property === 'fontFace' && (0, _felaUtils.isObject)(value)) { | ||
var fontFamily = value.fontFamily, | ||
src = value.src, | ||
otherProps = _objectWithoutProperties(value, ['fontFamily', 'src']); | ||
if (typeof fontFamily === 'string' && Array.isArray(src)) { | ||
style.fontFamily = renderer.renderFont(fontFamily, src, otherProps); | ||
delete style.fontFace; | ||
if (property === 'fontFace' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { | ||
if (Array.isArray(value)) { | ||
style.fontFamily = value.map(function (fontFace) { | ||
return renderFontFace(fontFace, renderer); | ||
}) | ||
// we filter font faces to remove invalid formats | ||
.filter(function (fontFace) { | ||
return fontFace; | ||
}).join(','); | ||
} else { | ||
// TODO: warning - invalid font data | ||
style.fontFamily = renderFontFace(value, renderer); | ||
} | ||
} else if (property === 'animationName' && (0, _felaUtils.isObject)(value)) { | ||
style[property] = renderer.renderKeyframe(function () { | ||
return value; | ||
}); | ||
delete style.fontFace; | ||
} else if (property === 'animationName' && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { | ||
if (Array.isArray(value)) { | ||
style[property] = value.map(function (frame) { | ||
return renderer.renderKeyframe(function () { | ||
return frame; | ||
}); | ||
}).join(','); | ||
} else { | ||
style[property] = renderer.renderKeyframe(function () { | ||
return value; | ||
}); | ||
} | ||
} else if ((0, _felaUtils.isObject)(value)) { | ||
@@ -34,0 +58,0 @@ embedded(value, type, renderer); |
{ | ||
"name": "fela-plugin-embedded", | ||
"version": "5.0.6", | ||
"version": "5.1.0", | ||
"description": "Fela plugin that resolves embedded keyframes and font faces", | ||
@@ -24,7 +24,7 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"fela-utils": "^5.0.4" | ||
"fela-utils": "^5.0.5" | ||
}, | ||
"devDependencies": { | ||
"fela": "^5.0.4" | ||
"fela": "^5.1.0" | ||
} | ||
} |
7749
106
Updatedfela-utils@^5.0.5