forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocInstallation.vue
More file actions
152 lines (123 loc) · 3.07 KB
/
DocInstallation.vue
File metadata and controls
152 lines (123 loc) · 3.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
<template lang="pug">
q-card.doc-installation.q-my-lg(flat, bordered)
q-tabs.text-grey-7.bg-white(v-model="currentTab", align="left", indicator-color="primary", dense, :breakpoint="0")
q-tab(
v-for="tab in ['Quasar CLI', 'UMD', 'Vue CLI']"
:key="`installation-${tab}`"
:name="tab"
:label="tab"
)
q-separator
q-tab-panels.bg-code(v-model="currentTab", animated)
q-tab-panel.q-pa-none(name="Quasar CLI")
doc-code {{ QuasarCli }}
q-tab-panel.q-pa-none(name="UMD")
doc-code {{ UMD }}
q-tab-panel.q-pa-none(name="Vue CLI")
doc-code {{ VueCli }}
</template>
<script>
import DocCode from './DocCode.vue'
export default {
name: 'DocInstallation',
components: {
DocCode
},
props: {
components: [ Array, String ],
directives: [ Array, String ],
plugins: [ Array, String ],
config: String
},
data () {
return {
currentTab: 'Quasar CLI'
}
},
methods: {
nameAsString (name, indent, quotes = true) {
const wrapper = quotes
? str => `'${str}'`
: str => str
return Array.isArray(name)
? name.map(wrapper).join(',\n' + ''.padStart(indent, ' '))
: wrapper(name)
}
},
computed: {
quasarConf () {
return this.config !== void 0
? `${this.config}: { /* look at QUASARCONFOPTIONS from the API card (bottom of page) */ }`
: void 0
},
QuasarCli () {
const parts = []
;[ 'components', 'directives' ].forEach(type => {
if (this[type] !== void 0) {
parts.push(`// NOT needed if using auto-import feature:
${type}: [
${this.nameAsString(this[type], 6)}
]`)
}
})
if (this.plugins !== void 0) {
parts.push(`plugins: [
${this.nameAsString(this.plugins, 6)}
]`)
}
if (this.quasarConf !== void 0) {
parts.push(`config: {
${this.quasarConf}
}`)
}
return `// quasar.conf.js
return {
framework: {
${parts.join(',\n ')}
}
}`
},
UMD () {
const config = this.quasarConf !== void 0
? `
// Optional;
// Place the global quasarConfig Object in a script tag BEFORE your Quasar script tag
window.quasarConfig = {
${this.quasarConf}
}`
: ''
const content = `/*
* No installation step is necessary.
* It gets installed by default.
*/`
return content + config
},
VueCli () {
const types = [], imports = []
;[ 'components', 'directives', 'plugins' ].forEach(type => {
if (this[type] !== void 0) {
imports.push(this.nameAsString(this[type], 2, false))
types.push(`${type}: {
${this.nameAsString(this[type], 4, false)}
}`)
}
})
if (this.quasarConf !== void 0) {
types.push(`config: {
${this.quasarConf}
}`)
}
return `// main.js
// This is needed ONLY if NOT chosen to import everything from Quasar
// when you installed vue-cli-plugin-quasar.
import {
Quasar,
${imports.join(',\n ')}
} from 'quasar'
Vue.use(Quasar, {
${types.join(',\n ')}
})`
}
}
}
</script>