Skip to content

Commit ee82fa0

Browse files
committed
fix: CEmbed refactor:
- rename CEmbedObject to CEmbedItem - delete 'custom' functionality - correct propTypes
1 parent d0d000e commit ee82fa0

File tree

4 files changed

+61
-87
lines changed

4 files changed

+61
-87
lines changed

src/CEmbed.js

+15-42
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,46 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import classNames from 'classnames';
4-
import {mapToCssModules, tagPropType} from './Shared/helper.js';
5-
import CEmbedObject from './CEmbedObject';
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
4+
import { mapToCssModules, tagPropType } from './Shared/helper.js'
65

76
//component - CoreUI / CEmbed
87

9-
const CEmbed = props=>{
8+
const CEmbed = props => {
109

1110
const {
1211
tag: Tag,
1312
className,
1413
cssModule,
15-
custom,
1614
innerRef,
1715
//
1816
ratio,
19-
type,
20-
src,
21-
objectClassName,
22-
objectProps,
2317
...attributes
24-
} = props;
18+
} = props
2519

2620
//render
2721

2822
const classes = mapToCssModules(classNames(
29-
className,
30-
ratio ? `embed-responsive-${ratio}` : null,
31-
'embed-responsive'
32-
), cssModule);
33-
34-
const objectClasses = mapToCssModules(classNames(
35-
objectClassName
36-
), cssModule);
37-
38-
if (!custom){
39-
return (
40-
<Tag className={classes} {...attributes} ref={innerRef}>
41-
<CEmbedObject {...objectProps} className={objectClasses} type={type} src={src} />
42-
</Tag>
43-
);
44-
}
23+
className, 'embed-responsive', `embed-responsive-${ratio}`
24+
), cssModule)
4525

4626
return (
47-
<Tag className={classes} {...attributes} ref={innerRef} />
48-
);
27+
<Tag className={classes} {...attributes} ref={innerRef}/>
28+
)
4929

5030
}
5131

5232
CEmbed.propTypes = {
5333
tag: tagPropType,
5434
className: PropTypes.string,
5535
cssModule: PropTypes.object,
56-
custom: PropTypes.bool,
5736
//
5837
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
59-
ratio: PropTypes.string,
60-
objectClassName: PropTypes.string,
61-
objectProps: PropTypes.object,
62-
///
63-
type: PropTypes.string,
64-
src: PropTypes.string,
38+
ratio: PropTypes.oneOf(['21by9', '16by9', '4by3', '1by1']),
6539
};
6640

6741
CEmbed.defaultProps = {
68-
tag: 'span',
69-
ratio: '16by9',
70-
type: 'iframe',
71-
};
42+
tag: 'div',
43+
ratio: '16by9'
44+
}
7245

73-
export default CEmbed;
46+
export default CEmbed

src/CEmbedItem.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
import classNames from 'classnames'
4+
import { mapToCssModules, tagPropType } from './Shared/helper.js'
5+
6+
//component - CoreUI / CEmbedItem
7+
8+
const CEmbedItem = props => {
9+
10+
const {
11+
tag: Tag,
12+
className,
13+
cssModule,
14+
//
15+
innerRef,
16+
...attributes
17+
} = props
18+
19+
//render
20+
21+
const classes = mapToCssModules(classNames(
22+
className,
23+
'embed-responsive-item'
24+
), cssModule)
25+
26+
return (
27+
<Tag className={classes} {...attributes} ref={innerRef}/>
28+
)
29+
30+
}
31+
32+
CEmbedItem.propTypes = {
33+
tag: tagPropType,
34+
className: PropTypes.string,
35+
cssModule: PropTypes.object,
36+
//
37+
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
38+
type: PropTypes.oneOf(['iframe', 'embed', 'video', 'object', 'img'])
39+
};
40+
41+
CEmbedItem.defaultProps = {
42+
tag: 'iframe'
43+
}
44+
45+
export default CEmbedItem

src/CEmbedObject.js

-44
This file was deleted.

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export {default as CToastBody} from './CToastBody';
109109
export {default as CToaster} from './CToaster';
110110
export {default as CCallout} from './CCallout';
111111
export {default as CEmbed} from './CEmbed';
112-
export {default as CEmbedObject} from './CEmbedObject';
112+
export {default as CEmbedItem} from './CEmbedItem';
113113
export {default as CLink} from './CLink';
114114
export {default as CToggler} from './CToggler';
115115
export {default as CImg} from './CImg';

0 commit comments

Comments
 (0)