Skip to content

Commit 032fc29

Browse files
committed
chore: CImg: clean component
1 parent e294b4b commit 032fc29

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

src/CImg.js

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
4-
import {tagPropType} from './Shared/helper.js';
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
4+
import { tagPropType } from './Shared/helper.js'
55

66
//component - CoreUI / CImg
7-
8-
const CImg = props=>{
7+
const CImg = props => {
98

109
const {
1110
className,
@@ -22,30 +21,22 @@ const CImg = props=>{
2221
placeholderColor,
2322
fluidGrow,
2423
...attributes
25-
} = props;
24+
} = props
2625

27-
const alignClass = (()=>{
28-
if (align === 'center') {
29-
return 'mx-auto'
30-
} else if (align === 'right') {
31-
return 'float-right'
32-
} else if (align === 'left') {
33-
return 'float-left'
34-
}
35-
return null
36-
})();
26+
const alignClass = align === 'center' ? 'mx-auto' :
27+
align === 'right' ? 'float-right' :
28+
align === 'left' ? 'float-left' : ''
3729

3830
// render
39-
4031
const classes = classNames(
4132
className,
4233
alignClass,
43-
thumbnail ? 'img-thumbnail' : null,
44-
fluid || fluidGrow ? 'img-fluid' : null,
45-
fluidGrow ? 'w-100' : null,
46-
block ? 'd-block' : null,
47-
shape ? shape : null,
48-
);
34+
thumbnail && 'img-thumbnail',
35+
fluid || fluidGrow && 'img-fluid',
36+
fluidGrow && 'w-100',
37+
block && 'd-block',
38+
shape
39+
)
4940

5041
return (
5142
src ?
@@ -55,7 +46,8 @@ const CImg = props=>{
5546
width={width}
5647
height={height}
5748
{...attributes}
58-
ref={innerRef} /> :
49+
ref={innerRef}
50+
/> :
5951
<svg
6052
className={classes}
6153
width={width}
@@ -64,7 +56,7 @@ const CImg = props=>{
6456
{...attributes}
6557
ref={innerRef}
6658
/>
67-
);
59+
)
6860

6961
}
7062

@@ -74,7 +66,6 @@ CImg.propTypes = {
7466
//
7567
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
7668
src: PropTypes.string,
77-
alt: PropTypes.string,
7869
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
7970
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
8071
block: PropTypes.bool,
@@ -90,4 +81,4 @@ CImg.defaultProps = {
9081
placeholderColor: 'transparent'
9182
};
9283

93-
export default CImg;
84+
export default CImg

0 commit comments

Comments
 (0)