UNPKG

@coreui/react-pro

Version:

UI Components Library for React.js

48 lines (44 loc) 1.66 kB
'use strict'; var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js'); var React = require('react'); var PropTypes = require('prop-types'); var index = require('../../_virtual/index.js'); var props = require('../../props.js'); const BREAKPOINTS = [ 'xxl', 'xl', 'lg', 'md', 'sm', 'xs', ]; const CPlaceholder = React.forwardRef((_a, ref) => { var { children, animation, as: Component = 'span', className, color, size } = _a, rest = tslib_es6.__rest(_a, ["children", "animation", "as", "className", "color", "size"]); const repsonsiveClassNames = []; BREAKPOINTS.forEach((bp) => { const breakpoint = rest[bp]; delete rest[bp]; const infix = bp === 'xs' ? '' : `-${bp}`; if (typeof breakpoint === 'number') { repsonsiveClassNames.push(`col${infix}-${breakpoint}`); } if (typeof breakpoint === 'boolean') { repsonsiveClassNames.push(`col${infix}`); } }); return (React.createElement(Component, Object.assign({ className: index.default(animation ? `placeholder-${animation}` : 'placeholder', { [`bg-${color}`]: color, [`placeholder-${size}`]: size, }, repsonsiveClassNames, className) }, rest, { ref: ref }), children)); }); CPlaceholder.propTypes = { animation: PropTypes.oneOf(['glow', 'wave']), as: PropTypes.elementType, children: PropTypes.node, className: PropTypes.string, color: props.colorPropType, size: PropTypes.oneOf(['xs', 'sm', 'lg']), }; CPlaceholder.displayName = 'CPlaceholder'; exports.CPlaceholder = CPlaceholder; //# sourceMappingURL=CPlaceholder.js.map