1 | import React from 'react';
|
2 | import PropTypes from 'prop-types';
|
3 | import classNames from 'classnames';
|
4 | import { mapToCssModules, tagPropType } from './utils';
|
5 | import Col, { getColumnClasses } from './Col';
|
6 |
|
7 | const propTypes = {
|
8 | ...Col.propTypes,
|
9 |
|
10 | color: PropTypes.string,
|
11 |
|
12 | tag: tagPropType,
|
13 |
|
14 | animation: PropTypes.oneOf(['glow', 'wave']),
|
15 | innerRef: PropTypes.oneOfType([
|
16 | PropTypes.object,
|
17 | PropTypes.func,
|
18 | PropTypes.string,
|
19 | ]),
|
20 |
|
21 | size: PropTypes.oneOf(['lg', 'sm', 'xs']),
|
22 | };
|
23 |
|
24 | function Placeholder(props) {
|
25 | let {
|
26 | className,
|
27 | cssModule,
|
28 | color,
|
29 | innerRef,
|
30 | tag: Tag = 'span',
|
31 | animation,
|
32 | size,
|
33 | widths,
|
34 | ...attributes
|
35 | } = props;
|
36 |
|
37 | let { modifiedAttributes, colClasses } = getColumnClasses(
|
38 | attributes,
|
39 | cssModule,
|
40 | widths,
|
41 | );
|
42 |
|
43 | const classes = mapToCssModules(
|
44 | classNames(
|
45 | className,
|
46 | colClasses,
|
47 | 'placeholder' + (animation ? '-' + animation : ''),
|
48 | size ? 'placeholder-' + size : false,
|
49 | color ? 'bg-' + color : false,
|
50 | ),
|
51 | cssModule,
|
52 | );
|
53 |
|
54 | return <Tag {...modifiedAttributes} className={classes} ref={innerRef} />;
|
55 | }
|
56 |
|
57 | Placeholder.propTypes = propTypes;
|
58 |
|
59 | export default Placeholder;
|
60 |
|
\ | No newline at end of file |