forked from reactstrap/reactstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardImg.js
More file actions
49 lines (41 loc) · 936 Bytes
/
Copy pathCardImg.js
File metadata and controls
49 lines (41 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { mapToCssModules } from './utils';
const propTypes = {
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
top: PropTypes.bool,
bottom: PropTypes.bool,
className: PropTypes.string,
cssModule: PropTypes.object,
};
const defaultProps = {
tag: 'img'
};
const CardImg = (props) => {
const {
className,
cssModule,
top,
bottom,
tag: Tag,
...attributes
} = props;
let cardImgClassName = 'card-img';
if (top) {
cardImgClassName = 'card-img-top';
}
if (bottom) {
cardImgClassName = 'card-img-bottom';
}
const classes = mapToCssModules(classNames(
className,
cardImgClassName
), cssModule);
return (
<Tag {...attributes} className={classes} />
);
};
CardImg.propTypes = propTypes;
CardImg.defaultProps = defaultProps;
export default CardImg;