@@ -12,14 +12,8 @@ Description:
12
12
Select a component
13
13
</div >
14
14
<div v-else >{{ `${this.activeComponent}.vue` }}</div >
15
- <prism-editor
16
- v-model =" code"
17
- :highlight =" highlighter"
18
- line-numbers
19
- class =" my-editor"
20
- readonly
21
- />
22
- </div >
15
+ <prism-editor v-model =" code" :highlight =" highlighter" line-numbers class =" my-editor" readonly />
16
+ </div >
23
17
</template >
24
18
25
19
<script >
@@ -48,14 +42,14 @@ export default {
48
42
... mapState ([" componentMap" , " activeComponent" , " activeComponentObj" , " exportAsTypescript" ]),
49
43
},
50
44
methods: {
51
- snippetInvoke (){
52
- if (this .activeComponent !== ' ' ){
45
+ snippetInvoke () {
46
+ if (this .activeComponent !== ' ' ) {
53
47
this .code = this .createCodeSnippet (
54
48
this .componentMap [this .activeComponent ].componentName ,
55
49
this .componentMap [this .activeComponent ].children
56
50
)
57
- } else {
58
- this .code = ' Your component boilerplate will be displayed here.'
51
+ } else {
52
+ this .code = ' Your component boilerplate will be displayed here.'
59
53
}
60
54
},
61
55
// highlighter does not work: OverVue 6.0;
@@ -95,30 +89,30 @@ export default {
95
89
" list-ul" : [" <ul" , " </ul>" ],
96
90
input: [" <input" , " " ], // single
97
91
navbar: [" <nav" , " </nav>" ],
98
- header: [" <header" ," </header>" ],
99
- footer: [" <footer" , " </footer>" ],
92
+ header: [" <header" , " </header>" ],
93
+ footer: [" <footer" , " </footer>" ],
100
94
meta: [" <meta" , " </meta>" ],
101
- h1: [" <h1" , " </h1>" ],
102
- h2: [" <h2" , " </h2>" ],
103
- h3: [" <h3" , " </h3>" ],
104
- h4: [" <h4" , " </h4>" ],
105
- h5: [" <h5" , " </h5>" ],
106
- h6: [" <h6" , " </h6>" ],
95
+ h1: [" <h1" , " </h1>" ],
96
+ h2: [" <h2" , " </h2>" ],
97
+ h3: [" <h3" , " </h3>" ],
98
+ h4: [" <h4" , " </h4>" ],
99
+ h5: [" <h5" , " </h5>" ],
100
+ h6: [" <h6" , " </h6>" ],
107
101
};
108
- // test//
109
- // function writeClass(componentName) {
110
- // if (this.componentMap[componentName]?.classList?.length > 0) {
111
- // let commentStr = '<!--'
112
- // this.componentMap[componentName].classList.forEach((el) => {
113
- // commentStr += "\n"
114
- // commentStr += el;
115
- // })
116
- // commentStr += '\n-->\n\n'
117
- // return commentStr;
118
- // } else {
119
- // return ''
120
- // }
121
- // };
102
+ // test//
103
+ // function writeClass(componentName) {
104
+ // if (this.componentMap[componentName]?.classList?.length > 0) {
105
+ // let commentStr = '<!--'
106
+ // this.componentMap[componentName].classList.forEach((el) => {
107
+ // commentStr += "\n"
108
+ // commentStr += el;
109
+ // })
110
+ // commentStr += '\n-->\n\n'
111
+ // return commentStr;
112
+ // } else {
113
+ // return ''
114
+ // }
115
+ // };
122
116
// Helper function that recursively iterates through the given html element's children and their children's children.
123
117
// also adds proper indentation to code snippet
124
118
function writeNested (childrenArray , indent ) {
@@ -134,13 +128,13 @@ export default {
134
128
nestedString += ` <${ child} />\n ` ;
135
129
} else {
136
130
nestedString += htmlElementMap[child .text ][0 ];
137
- if (child .class !== " " ) {
138
- nestedString += " " + " class = " + ` "${ el .class } "` ;
139
- }
140
- if (child .text === " img" || child .text === " input" || child .text === " link" ) {
141
- nestedString += " />" ;
142
- } else {nestedString += " >" ;}
143
-
131
+ if (child .class !== " " ) {
132
+ nestedString += " " + " class = " + ` "${ el .class } "` ;
133
+ }
134
+ if (child .text === " img" || child .text === " input" || child .text === " link" ) {
135
+ nestedString += " />" ;
136
+ } else { nestedString += " >" ; }
137
+
144
138
if (child .children .length ) {
145
139
nestedString += " \n " ;
146
140
nestedString += writeNested (child .children , indented);
@@ -156,22 +150,19 @@ export default {
156
150
157
151
// Iterates through active component's HTML elements list and adds to code snippet
158
152
let htmlArr = this .componentMap [componentName].htmlList ;
159
- console .log (" ALERT" )
160
- console .log (htmlArr[0 ].class )
161
- console .log (htmlArr[0 ].children )
162
153
let outputStr = ` ` ;
163
154
// eslint-disable-next-line no-unused-vars
164
155
for (let el of htmlArr) {
165
156
if (! el .text ) {
166
157
outputStr += ` <${ el} />\n ` ;
167
158
} else {
168
159
outputStr += ` ` ;
169
- outputStr += htmlElementMap[el .text ][0 ]
170
- // if conditional to check class
171
- if (el .class !== " " ) {
172
- outputStr += " " + " class = " + ` "${ el .class } "` ;
173
- }
174
- outputStr += " >" ;
160
+ outputStr += htmlElementMap[el .text ][0 ]
161
+ // if conditional to check class
162
+ if (el .class !== " " ) {
163
+ outputStr += " " + " class = " + ` "${ el .class } "` ;
164
+ }
165
+ outputStr += " >" ;
175
166
if (el .children .length ) {
176
167
outputStr += " \n " ;
177
168
outputStr += writeNested (el .children , ` ` );
@@ -204,7 +195,7 @@ export default {
204
195
imports += ' } from "vuex";\n ' ;
205
196
}
206
197
207
- // if Typescript toggle is on, import defineComponent
198
+ // if Typescript toggle is on, import defineComponent
208
199
if (this .exportAsTypescript === " on" ) {
209
200
imports += ' import { defineComponent } from "vue";\n ' ;
210
201
}
@@ -285,19 +276,19 @@ export default {
285
276
// watches activeComponentObj for changes to make it reactive upon mutation
286
277
// // // watches componentMap for changes to make it reactive upon mutation
287
278
activeComponent: {
288
- handler () {
279
+ handler () {
289
280
this .snippetInvoke ();
290
281
},
291
282
deep: true
292
283
},
293
284
componentMap: {
294
- handler () {
285
+ handler () {
295
286
this .snippetInvoke ();
296
287
},
297
288
deep: true
298
289
},
299
290
exportAsTypescript: {
300
- handler () {
291
+ handler () {
301
292
this .snippetInvoke ();
302
293
},
303
294
}
0 commit comments