Skip to content

Commit a1e7482

Browse files
authored
Merge pull request #51 from vuejs-br/update-codepen-snippet
Update "codepen-snippet.vue"
2 parents a9ef0a7 + 3eaa457 commit a1e7482

File tree

1 file changed

+68
-17
lines changed

1 file changed

+68
-17
lines changed

src/.vuepress/components/common/codepen-snippet.vue

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,99 @@
11
<template>
2-
<p class="codepen" data-height="300" data-theme-id="39028" data-default-tab="result" data-preview="true" data-editable="true"
3-
:data-user="user.slug"
4-
:data-slug-hash="slug"
5-
:data-pen-title="title">
6-
<span>Veja o exemplo <a :href="`https://codepen.io/${user.slug}/pen/${slug}`">
7-
{{ title }}</a> por {{ user.name }} (<a :href="`https://codepen.io/${user.slug}`">@${user.slug}</a>)
8-
no <a href="https://codepen.io">CodePen</a>.</span>
2+
<p
3+
class="codepen"
4+
:data-theme-id="theme"
5+
:data-preview="preview || null"
6+
:data-editable="editable || null"
7+
:data-height="height"
8+
:data-default-tab="tab"
9+
:data-user="user"
10+
:data-slug-hash="slug"
11+
:data-pen-title="title"
12+
:data-embed-version="version"
13+
:style="`height: ${height}px`">
14+
<span>See the Pen <a :href="href">{{ title }}</a>
15+
by {{ name || user }} (<a :href="`https://codepen.io/${user}`">@{{user}}</a>)
16+
on <a href="https://codepen.io">CodePen</a>.</span>
917
</p>
1018
</template>
1119

1220
<script>
1321
export default {
1422
props: {
15-
user: {
16-
type: Object,
17-
default: () => ({
18-
slug: 'vuejs-br',
19-
name: 'Vue.js Brasil'
20-
}),
21-
},
22-
2323
title: {
2424
type: String,
2525
default: null,
26+
required: true,
2627
},
2728
2829
slug: {
2930
type: String,
3031
default: null,
32+
required: true,
33+
},
34+
35+
tab: {
36+
type: String,
37+
default: 'result',
38+
},
39+
40+
team: {
41+
type: Boolean,
42+
default: true,
43+
},
44+
45+
user: {
46+
type: String,
47+
default: 'Vue',
48+
},
49+
50+
name: {
51+
type: String,
52+
default: null,
53+
},
54+
55+
height: {
56+
type: Number,
57+
default: 300,
58+
},
59+
60+
theme: {
61+
type: String,
62+
default: '39028',
63+
},
64+
65+
preview: {
66+
type: Boolean,
67+
default: true,
3168
},
69+
70+
editable: {
71+
type: Boolean,
72+
default: true,
73+
},
74+
75+
version: {
76+
type: String,
77+
default: null,
78+
}
3279
},
3380
mounted() {
3481
const codepenScript = document.createElement('script')
3582
codepenScript.setAttribute('src', 'https://static.codepen.io/assets/embed/ei.js')
3683
codepenScript.async = true
3784
this.$el.appendChild(codepenScript)
38-
}
85+
},
86+
computed: {
87+
href() {
88+
return `https://codepen.io/${this.team ? 'team' : ''}${this.user}/pen/${this.slug}`
89+
}
90+
},
3991
}
4092
</script>
4193

4294
<style lang="scss">
4395
.codepen {
4496
box-sizing: border-box;
45-
height: 300px;
4697
display: flex;
4798
align-items: center;
4899
justify-content: center;

0 commit comments

Comments
 (0)