jobiqo-cl
Version:
[](https://circleci.com/gh/jobiqo/jobiqo-cl)
89 lines (79 loc) • 5.23 kB
JavaScript
import { createElement } from 'react';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(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);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
var uid = (function () {
return Math.random()
.toString(36)
.substring(2);
});
var Svg = (function (_a) {
var rtl = _a.rtl, speed = _a.speed, interval = _a.interval, style = _a.style, width = _a.width, height = _a.height, baseUrl = _a.baseUrl, gradientRatio = _a.gradientRatio, animate = _a.animate, ariaLabel = _a.ariaLabel, children = _a.children, className = _a.className, uniquekey = _a.uniquekey, primaryColor = _a.primaryColor, primaryOpacity = _a.primaryOpacity, secondaryColor = _a.secondaryColor, secondaryOpacity = _a.secondaryOpacity, preserveAspectRatio = _a.preserveAspectRatio, props = __rest(_a, ["rtl", "speed", "interval", "style", "width", "height", "baseUrl", "gradientRatio", "animate", "ariaLabel", "children", "className", "uniquekey", "primaryColor", "primaryOpacity", "secondaryColor", "secondaryOpacity", "preserveAspectRatio"]);
var idClip = uniquekey ? uniquekey + "-idClip" : uid();
var idGradient = uniquekey ? uniquekey + "-idGradient" : uid();
var rtlStyle = rtl ? { transform: 'scaleX(-1)' } : {};
var keyTimes = "0; " + interval + "; 1";
var dur = speed + "s";
return (createElement("svg", __assign({ role: "img", style: __assign({}, style, rtlStyle), className: className, "aria-label": ariaLabel ? ariaLabel : null, viewBox: "0 0 " + width + " " + height, preserveAspectRatio: preserveAspectRatio }, props),
ariaLabel ? createElement("title", null, ariaLabel) : null,
createElement("rect", { x: "0", y: "0", width: width, height: height, clipPath: "url(" + baseUrl + "#" + idClip + ")", style: { fill: "url(" + baseUrl + "#" + idGradient + ")" } }),
createElement("defs", null,
createElement("clipPath", { id: idClip }, children),
createElement("linearGradient", { id: idGradient },
createElement("stop", { offset: "0%", stopColor: primaryColor, stopOpacity: primaryOpacity }, animate && (createElement("animate", { attributeName: "offset", values: -gradientRatio + "; " + -gradientRatio + "; 1", keyTimes: keyTimes, dur: dur, repeatCount: "indefinite" }))),
createElement("stop", { offset: "50%", stopColor: secondaryColor, stopOpacity: secondaryOpacity }, animate && (createElement("animate", { attributeName: "offset", values: -gradientRatio / 2 + "; " + -gradientRatio / 2 + "; " + (1 +
gradientRatio / 2), keyTimes: keyTimes, dur: dur, repeatCount: "indefinite" }))),
createElement("stop", { offset: "100%", stopColor: primaryColor, stopOpacity: primaryOpacity }, animate && (createElement("animate", { attributeName: "offset", values: "0; 0; " + (1 + gradientRatio), keyTimes: keyTimes, dur: dur, repeatCount: "indefinite" })))))));
});
var defaultProps = {
animate: true,
ariaLabel: 'Loading interface...',
baseUrl: '',
gradientRatio: 2,
height: 130,
interval: 0.25,
preserveAspectRatio: 'none',
primaryColor: '#f0f0f0',
primaryOpacity: 1,
rtl: false,
secondaryColor: '#e0e0e0',
secondaryOpacity: 1,
speed: 2,
style: {},
width: 400,
};
var InitialComponent = function (props) { return (createElement("rect", { x: "0", y: "0", rx: "5", ry: "5", width: props.width, height: props.height })); };
var ContentLoader = function (props) {
var mergedProps = __assign({}, defaultProps, props);
var children = props.children ? (props.children) : (createElement(InitialComponent, __assign({}, mergedProps)));
return createElement(Svg, __assign({}, mergedProps), children);
};
export default ContentLoader;