@@ -9,7 +9,7 @@ Description:
9
9
<q-menu class =" dropdown" :offset =" [0, 15]" >
10
10
<div class =" column items-center" >
11
11
<p class =" center" >Export:</p >
12
- <q-btn class =" menu-btn" no-caps color =" secondary" label =" Project" @click =" exportProject" />
12
+ <q-btn class =" menu-btn" no-caps color =" secondary" label =" Vue Project" @click =" exportProject" />
13
13
<q-btn class =" menu-btn" id =" export-component-nav-btn" no-caps color =" secondary" label =" Active Component"
14
14
@click =" useExportComponentBound" :disabled =" !activeComponent.trim()" />
15
15
</div >
@@ -152,28 +152,31 @@ export default {
152
152
let nestedString = " " ;
153
153
154
154
childrenArray .forEach ((child ) => {
155
- nestedString += indented;
156
- if (! child .text ) {
157
- nestedString += ` <${ child} />\n ` ;
158
- } else {
159
- nestedString += htmlElementMap[child .text ][0 ];
160
- if (child .class !== " " ) {
161
- nestedString += " " + " class = " + ` "${ child .class } "` ;
162
- }
163
- if (child .text === " img" || child .text === " input" || child .text === " link" ) {
164
- nestedString += " />" ;
165
- } else { nestedString += " >" ; }
166
-
167
- if (child .children .length ) {
168
- nestedString += " \n " ;
169
- nestedString += writeNested (child .children , indented);
170
- nestedString += indented + htmlElementMap[child .text ][1 ];
171
- nestedString += " \n " ;
155
+ nestedString += indented;
156
+ if (! child .text ) {
157
+ nestedString += ` <${ child} />\n ` ;
172
158
} else {
173
- nestedString += htmlElementMap[child .text ][1 ] + " \n " ;
159
+ nestedString += htmlElementMap[child .text ][0 ];
160
+ if (child .class !== " " ) {
161
+ nestedString += " " + " class = " + ` "${ child .class } "` ;
162
+ }
163
+ if (child .binding !== " " ) {
164
+ nestedString += " " + " v-model = " + ` "${ child .binding } "` ;
165
+ }
166
+ if (child .text === " img" || child .text === " input" || child .text === " link" ) {
167
+ nestedString += " />" ;
168
+ } else { nestedString += " >" ; }
169
+
170
+ if (child .children .length ) {
171
+ nestedString += " \n " ;
172
+ nestedString += writeNested (child .children , indented);
173
+ nestedString += indented + htmlElementMap[child .text ][1 ];
174
+ nestedString += " \n " ;
175
+ } else {
176
+ nestedString += htmlElementMap[child .text ][1 ] + " \n " ;
177
+ }
174
178
}
175
- }
176
- });
179
+ });
177
180
return nestedString;
178
181
}
179
182
// iterate through component's htmllist
@@ -190,6 +193,9 @@ export default {
190
193
if (el .class !== " " ) {
191
194
outputStr += " " + " class = " + ` "${ el .class } "` ;
192
195
}
196
+ if (el .binding !== " " ) {
197
+ outputStr += " " + " v-model = " + ` "${ el .binding } "` ;
198
+ }
193
199
outputStr += " >" ;
194
200
if (el .children .length ) {
195
201
outputStr += " \n " ;
@@ -223,6 +229,7 @@ export default {
223
229
*/
224
230
writeTemplate (componentName , children ) {
225
231
let str = " " ;
232
+
226
233
if (componentName === " App" ) {
227
234
str += ` <div id="app">\n\t\t <div id="nav">\n ` ;
228
235
children .forEach ((name ) => {
@@ -233,12 +240,19 @@ export default {
233
240
}
234
241
});
235
242
str += " \t\t\t <router-view></router-view>\n\t\t </div>\n " ;
236
- } else {
237
- str += ` <div>\n ` ;
238
243
}
239
244
// writes the HTML tag boilerplate
240
245
let templateTagStr = this .writeTemplateTag (componentName);
241
- return ` <template>\n\t ${ str}${ templateTagStr} \t </div>\n </template>` ;
246
+
247
+ if (this .componentMap [componentName].htmlAttributes ) {
248
+ if (this .componentMap [componentName].htmlAttributes .class !== " " && this .componentMap [componentName].htmlAttributes .id !== " " ) {
249
+ return ` <template>\n <div id = "${ this .componentMap [componentName].htmlAttributes .id } " class = "${ this .componentMap [componentName].htmlAttributes .class } ">\n ${ templateTagStr} </div>\n </template>` ;
250
+ } else if (this .componentMap [componentName].htmlAttributes .class !== " " && this .componentMap [componentName].htmlAttributes .id === " " ) {
251
+ return ` <template>\n <div class = "${ this .componentMap [componentName].htmlAttributes .class } ">\n ${ templateTagStr} </div>\n </template>` ;
252
+ } else if (this .componentMap [componentName].htmlAttributes .class === " " && this .componentMap [componentName].htmlAttributes .id !== " " )
253
+ return ` <template>\n <div id = "${ this .componentMap [componentName].htmlAttributes .id } ">\n ${ templateTagStr} </div>\n </template>` ;
254
+ else return ` <template>\n <div>\n\t ${ str}${ templateTagStr} </div>\n </template>` ;
255
+ } else return ` <template>\n <div>\n\t ${ str}${ templateTagStr} </div>\n </template>`
242
256
},
243
257
/**
244
258
* @description imports child components into <script>
@@ -277,15 +291,23 @@ export default {
277
291
});
278
292
// if true add data section and populate with props
279
293
let data = " " ;
294
+ data += " data () {\n return {" ;
280
295
if (currentComponent .props .length ) {
281
- data += " data () {\n return {" ;
282
296
currentComponent .props .forEach ((prop ) => {
283
297
data += ` \n ${ prop} : "PLACEHOLDER FOR VALUE",` ;
284
298
});
299
+ }
300
+ this .routes .HomeView .forEach ((element ) => {
301
+ element .htmlList .forEach ((html ) => {
302
+ if (html .binding !== ' ' ) {
303
+ data += ` \n ${ html .binding } : "PLACEHOLDER FOR VALUE",` ;
304
+ }
305
+ })
306
+ })
285
307
data += " \n " ;
286
308
data += " }\n " ;
287
309
data += " },\n " ;
288
- }
310
+
289
311
// if true add computed section and populate with state
290
312
let computed = " " ;
291
313
if (currentComponent .state .length ) {
@@ -331,6 +353,7 @@ export default {
331
353
return output;
332
354
} else {
333
355
let str = " " ;
356
+
334
357
children .forEach ((name ) => {
335
358
str += ` import ${ name} from '@/components/${ name} .vue';\n ` ;
336
359
});
@@ -350,12 +373,37 @@ export default {
350
373
* if component is 'App', writes css, else returns <style scoped>
351
374
*/
352
375
writeStyle (componentName ) {
353
- let style =
354
- componentName !== " App"
355
- ? " "
356
- : ` #app {\n\t font-family: 'Avenir', Helvetica, Arial, sans-serif;\n\t -webkit-font-smoothing: antialiased;\n\t -moz-osx-font-smoothing: grayscale;\n\t text-align: center;\n\t color: #2C3E50;\n\t margin-top: 60px;\n }\n ` ;
357
- return ` \n\n <style scoped>\n ${ style} </style>` ;
376
+ let htmlArray = this .componentMap [componentName].htmlList ;
377
+ let styleString = " " ;
378
+
379
+ this .routes .HomeView .forEach ((element ) => {
380
+ if (element .htmlAttributes .class !== " " ) {
381
+ styleString += ` .${ element .htmlAttributes .class } {\n background-color: ${ element .color } ;
382
+ width: ${ element .w } px;
383
+ height: ${ element .h } px;
384
+ z-index: ${ element .z } ;
385
+ }\n `
386
+ }
387
+ })
388
+
389
+
390
+
391
+
392
+
393
+ for (const html of htmlArray) {
394
+ if (html .class !== ' ' ) {
395
+ styleString += ` .${ html .class } {\n height: ${ html .h } %;
396
+ width: ${ html .w } %;
397
+ top: ${ html .x } %;
398
+ left: ${ html .y } %;
399
+ z-index: ${ html .z } ;
400
+ }\n `
401
+ }
402
+ }
403
+
404
+ return ` \n\n <style scoped>\n ${ styleString} </style >` ;
358
405
},
406
+
359
407
// creates index html
360
408
createIndexFile (location ) {
361
409
let str = ` <!DOCTYPE html>\n <html lang="en">\n\n <head>` ;
@@ -617,4 +665,10 @@ export default {
617
665
#export - component - nav - btn {
618
666
margin -bottom : 20px;
619
667
}
668
+
669
+ .menu - btn{
670
+ width: 60 % ;
671
+ margin: 10px 0px ;
672
+ max- height: 55px ! important;
673
+ }
620
674
< / style>
0 commit comments