tpa-style-webpack-plugin
Version:
A Webpack plugin that handles wix tpa styles, it separates static css file that injects dynamic style at runtime.
41 lines • 1.63 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { forEach } from './utils';
export var wixStylesColorUtils = {
getFullColorStyles: function (_a) {
var colorStyles = _a.colorStyles, siteColors = _a.siteColors;
var returnValue = {};
// Fix color styles due to '.' to '-' conversion
var fixedColorStyles = {};
for (var key in colorStyles) {
fixedColorStyles[key.replace(/\./g, '-')] = colorStyles[key].value;
}
// Helper functions
// Basic definitions
returnValue.white = '#FFFFFF';
returnValue.black = '#000000';
// Basic template colors
forEach(siteColors, function (_a) {
var reference = _a.reference, value = _a.value;
returnValue[reference] = value;
});
returnValue = __assign(__assign({}, returnValue), fixedColorStyles);
// Fix for a bug in a very specific template
returnValue.background =
(fixedColorStyles.background || {}).value ||
(returnValue['color-1'] === '#FFFFFF' && returnValue['color-2'] === '#F4EFE1')
? returnValue['color-2']
: returnValue['color-1'];
return returnValue;
},
};
//# sourceMappingURL=wixStylesColorUtils.js.map