Skip to content

Commit 1b53cd7

Browse files
committed
feat: add CEmbed component.
1 parent 4c26e19 commit 1b53cd7

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/components/Embed/CEmbed.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { mergeData } from 'vue-functional-data-merge'
2+
3+
export const props = {
4+
type: {
5+
type: String,
6+
default: 'iframe',
7+
validator: type => ['iframe', 'embed', 'video', 'object', 'img'].indexOf(type) !== -1
8+
},
9+
aspect: {
10+
type: String,
11+
default: '16by9',
12+
validator: aspect => ['21by9', '16by9', '4by3', '1by1'].indexOf(aspect) !== -1
13+
},
14+
tag: {
15+
type: String,
16+
default: 'div'
17+
}
18+
}
19+
export default {
20+
functional: true,
21+
props,
22+
render (h, { props, data, children }) {
23+
return h(
24+
props.tag,
25+
{
26+
ref: data.ref,
27+
staticClass: 'embed-responsive',
28+
class:`embed-responsive-${props.aspect}`
29+
},
30+
[h(props.type, mergeData(data, { ref: '', staticClass: 'embed-responsive-item' }), children)]
31+
)
32+
}
33+
}

src/components/Embed/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import CEmbed from './CEmbed'
2+
3+
export {
4+
CEmbed
5+
}

0 commit comments

Comments
 (0)