UNPKG

@coreui/react

Version:

UI Components Library for React.js

47 lines (44 loc) 1.8 kB
import { __rest, __assign } from '../../node_modules/tslib/tslib.es6.js'; import React, { forwardRef } from 'react'; import PropTypes from 'prop-types'; import classNames from '../../_virtual/index.js'; import { colorPropType } from '../../props.js'; var BREAKPOINTS = [ 'xxl', 'xl', 'lg', 'md', 'sm', 'xs', ]; var CPlaceholder = forwardRef(function (_a, ref) { var _b; var children = _a.children, animation = _a.animation, _c = _a.as, Component = _c === void 0 ? 'span' : _c, className = _a.className, color = _a.color, size = _a.size, rest = __rest(_a, ["children", "animation", "as", "className", "color", "size"]); var repsonsiveClassNames = []; BREAKPOINTS.forEach(function (bp) { var breakpoint = rest[bp]; delete rest[bp]; var infix = bp === 'xs' ? '' : "-".concat(bp); if (typeof breakpoint === 'number') { repsonsiveClassNames.push("col".concat(infix, "-").concat(breakpoint)); } if (typeof breakpoint === 'boolean') { repsonsiveClassNames.push("col".concat(infix)); } }); return (React.createElement(Component, __assign({ className: classNames(animation ? "placeholder-".concat(animation) : 'placeholder', (_b = {}, _b["bg-".concat(color)] = color, _b["placeholder-".concat(size)] = size, _b), repsonsiveClassNames, className) }, rest, { ref: ref }), children)); }); CPlaceholder.propTypes = { animation: PropTypes.oneOf(['glow', 'wave']), as: PropTypes.elementType, children: PropTypes.node, className: PropTypes.string, color: colorPropType, size: PropTypes.oneOf(['xs', 'sm', 'lg']), }; CPlaceholder.displayName = 'CPlaceholder'; export { CPlaceholder }; //# sourceMappingURL=CPlaceholder.js.map