lucid-ui
Version:
A UI component library from Xandr.
84 lines • 4.74 kB
JavaScript
"use strict";
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);
};
var __rest = (this && this.__rest) || function (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 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoadingIcon = exports.loadingIconPropTypes = exports.durations = void 0;
var lodash_1 = __importDefault(require("lodash"));
var react_1 = __importDefault(require("react"));
var prop_types_1 = __importDefault(require("prop-types"));
var Icon_1 = __importDefault(require("../Icon"));
var style_helpers_1 = require("../../../util/style-helpers");
var cx = style_helpers_1.lucidClassNames.bind('&-LoadingIcon');
var durations;
(function (durations) {
durations["fast"] = "0.75s";
durations["normal"] = "1.25s";
durations["slow"] = "4s";
})(durations = exports.durations || (exports.durations = {}));
exports.loadingIconPropTypes = {
/** The speed of rotation of the spinner. */
speed: prop_types_1.default.oneOf(['fast', 'normal', 'slow']),
/** Size variations of the icons. \`size\` directly effects height and width
but the developer should also be conscious of the relationship with
\`viewBox\`. */
size: prop_types_1.default.number,
/** Size handles width and height, whereas \`width\` can manually override the width that would be set by size. */
width: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.string]),
/** Size handles width and height, whereas \`height\` can manually override the height that would be set by size. */
height: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.string]),
/** Any valid SVG aspect ratio. */
aspectRatio: prop_types_1.default.string,
/** Adds styling that makes the icon appear clickable. */
isClickable: prop_types_1.default.bool,
/** Adds styling that makes the icon appear disabled. Also forces
isClickable to be false. */
isDisabled: prop_types_1.default.bool,
/** Called when the user clicks the \`Icon\`. Signature:
\`({event, props}) => {}\` */
onClick: prop_types_1.default.func,
/** Called when the user clicks an active, clickable \`Icon\`. Signature:
\`({event, props}) => {}\` */
onSelect: prop_types_1.default.func,
/** Any valid React children. */
children: prop_types_1.default.element,
/** Classes that are appended to the component defaults. This prop is run
through the \`classnames\` library. */
className: prop_types_1.default.string,
};
var LoadingIcon = function (_a) {
var className = _a.className, _b = _a.speed, speed = _b === void 0 ? 'normal' : _b, style = _a.style, isDisabled = _a.isDisabled, passThroughs = __rest(_a, ["className", "speed", "style", "isDisabled"]);
var animationDuration = "".concat(durations[speed] || durations.normal);
return (react_1.default.createElement(Icon_1.default, __assign({}, lodash_1.default.omit(passThroughs, ['initialState', 'viewbox', 'color']), { viewBox: '0 0 100 100', className: cx('&', className), style: __assign({ animationDuration: animationDuration }, style), isDisabled: isDisabled }),
react_1.default.createElement("rect", { x: '0', y: '0', width: '100', height: '100', fill: 'none' }),
react_1.default.createElement("circle", { className: cx('&-circle'), cx: '50', cy: '50', r: '40' }),
react_1.default.createElement("circle", { style: { animationDuration: animationDuration }, className: cx('&-spinner', { '&-spinner-is-disabled': isDisabled }), cx: '50', cy: '50', r: '40' })));
};
exports.LoadingIcon = LoadingIcon;
exports.LoadingIcon.displayName = 'LoadingIcon';
exports.LoadingIcon.propTypes = exports.loadingIconPropTypes;
exports.LoadingIcon.defaultProps = Icon_1.default.defaultProps;
exports.default = exports.LoadingIcon;
//# sourceMappingURL=LoadingIcon.js.map