forked from vuematerial/vue-material
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleBox.vue
More file actions
173 lines (148 loc) · 4.07 KB
/
ExampleBox.vue
File metadata and controls
173 lines (148 loc) · 4.07 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
<div class="example-box">
<md-card class="example-box-card">
<md-toolbar md-theme="white" class="md-dense">
<h3 class="md-title">{{ cardTitle }}</h3>
</md-toolbar>
<md-card-area>
<md-tabs md-right :md-dynamic-height="false" class="md-transparent example-tabs">
<md-tab class="example-content" md-label="Demo" md-active>
<slot name="demo"></slot>
</md-tab>
<md-tab class="code-content" md-label="Code">
<slot name="code"></slot>
</md-tab>
</md-tabs>
</md-card-area>
<!-- <button type="button" class="md-codepen" @click="editOnCodepen">
<img src="assets/codepen.png" alt="Edit on Codepen">
<md-tooltip md-direction="left">Edit on codepen</md-tooltip>
</button> -->
</md-card>
<!-- <form action="http://codepen.io/pen/define" method="POST" target="_blank" v-if="codeBlocks.length" ref="form">
<input type="hidden" name="data" :value="codeString">
</form>
<pre ref="initialJs">
Vue.use(VueMaterial)
Vue.material.theme.register('default', {
primary: 'blue',
accent: 'pink'
})
var App = new Vue({
el: '#app'
})
</pre>
<pre ref="initialHtml">
<div id="app">
### TEMPLATE ###
</div>
</pre> -->
</div>
</template>
<style lang="scss">
.example-box .code-content {
.code-block {
margin: -16px;
+ .code-block {
margin-top: 40px;
}
}
}
.md-tooltip.md-codepen-tooltip {
margin-left: -4px;
}
</style>
<style lang="scss" scoped>
.example-box {
margin-bottom: 16px;
}
.md-title {
position: relative;
z-index: 3;
}
.example-tabs {
margin-top: -48px;
@media (max-width: 480px) {
margin-top: -1px;
background-color: #fff;
}
}
.example-box-card {
position: relative;
overflow: hidden;
&:hover .md-codepen {
opacity: .54;
transform: translate3D(0, 0, 0);
transition: .4s cubic-bezier(.25, .8, .25, 1);
}
}
.md-codepen {
margin: 0;
padding: 4px;
cursor: pointer;
position: absolute;
right: 4px;
bottom: 4px;
border: none;
background: none;
opacity: .26;
transform: translate3D(120%, 0, 0);
transition: .3s cubic-bezier(.55, 0, .55, .2);
img {
width: 32px;
}
}
pre {
display: none;
}
</style>
<script>
export default {
props: {
cardTitle: String
},
data: () => ({
codeBlocks: [],
codeString: ''
}),
methods: {
editOnCodepen() {
let data = {
title: 'Vue Material - ' + this.cardTitle,
private: false,
head: '<meta name="viewport" content="width=device-width">',
html_pre_processor: 'none',
js_pre_processor: 'none',
js: this.$refs.initialJs.innerHTML,
css_pre_processor: 'scss',
css_starter: 'neither',
css_prefix_free: false,
css_external: [
'http://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic',
'http://fonts.googleapis.com/icon?family=Material+Icons',
'https://cdn.rawgit.com/marcosmoura/vue-material/master/dist/vue-material.css'
].join(';'),
js_external: [
'https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.3/vue.min.js',
'https://cdn.rawgit.com/marcosmoura/vue-material/master/dist/vue-material.js'
].join(';')
};
this.codeBlocks.forEach((block) => {
if (block.lang === 'xml') {
let initialHtml = this.$refs.initialHtml.innerHTML;
data.html = initialHtml.replace('### TEMPLATE ###', block.code);
} else if (block.lang === 'javascript') {
data.js = data.js += block.code;
} else {
data.css = block.code;
}
});
this.codeString = JSON.stringify(data).replace(/"/g, '"').replace(/'/g, ''');
this.$nextTick(() => {
console.log(this.$refs.initialJs);
this.$refs.form.submit();
});
}
}
};
</script>