@@ -32,7 +32,7 @@ import 'vue-prism-editor/dist/VuePrismEditor.css'
3232export default {
3333 data () {
3434 return {
35- code: ` Your component boilerplate will be displayed here.` ,
35+ // code: `Your component boilerplate will be displayed here.`,
3636 lineNumbers: true ,
3737 height: null
3838 }
@@ -42,7 +42,17 @@ export default {
4242 },
4343 computed: {
4444 // needs access to current component aka activeComponent
45- ... mapState ([' componentMap' , ' activeComponent' , ' activeComponentObj' ])
45+ ... mapState ([' componentMap' , ' activeComponent' , ' activeComponentObj' ]),
46+ code : function () {
47+ let computedCode = ' Your component boilerplate will be displayed here.'
48+ if (this .activeComponent ) {
49+ computedCode = this .createCodeSnippet (
50+ this .activeComponentObj .componentName ,
51+ this .activeComponentObj .children
52+ )
53+ }
54+ return computedCode
55+ }
4656 },
4757 methods: {
4858 getWindowHeight (e ) {
@@ -227,24 +237,24 @@ export default {
227237 },
228238 watch: {
229239 // watches activeComponentObj for changes to make it reactive upon mutation
230- activeComponentObj: {
231- handler () {
232- // console.log(this.activeComponentObj.children)
233- this .code = this .createCodeSnippet (
234- this .activeComponentObj .componentName ,
235- this .activeComponentObj .children
236- )
237- }
238- },
240+ // activeComponentObj: {
241+ // handler () {
242+ // // console.log(this.activeComponentObj.children)
243+ // this.code = this.createCodeSnippet(
244+ // this.activeComponentObj.componentName,
245+ // this.activeComponentObj.children
246+ // )
247+ // }
248+ // },
239249 // watches componentMap for changes to make it reactive upon mutation
240- componentMap: {
241- handler () {
242- this .code = this .createCodeSnippet (
243- this .activeComponentObj .componentName ,
244- this .activeComponentObj .children
245- )
246- }
247- }
250+ // componentMap: {
251+ // handler () {
252+ // this.code = this.createCodeSnippet(
253+ // this.activeComponentObj.componentName,
254+ // this.activeComponentObj.children
255+ // )
256+ // }
257+ // }
248258 },
249259 mounted () {
250260 // https://vuejs.org/v2/api/#Vue-nextTick
@@ -256,17 +266,17 @@ export default {
256266 })
257267 },
258268 // Updates code snippet when adding children
259- updated () {
260- if (this .componentMap [this .activeComponent ]) {
261- this .code = ` ${ this .createCodeSnippet (
262- this .activeComponent ,
263- this .componentMap [this .activeComponent ].children
264- )} `
265- // else if there is not existing component/no active component
266- } else {
267- this .code = ` Your component boilerplate will be displayed here.`
268- }
269- },
269+ // updated () {
270+ // if (this.componentMap[this.activeComponent]) {
271+ // this.code = `${this.createCodeSnippet(
272+ // this.activeComponent,
273+ // this.componentMap[this.activeComponent].children
274+ // )}`
275+ // // else if there is not existing component/no active component
276+ // } else {
277+ // this.code = `Your component boilerplate will be displayed here.`
278+ // }
279+ // },
270280 beforeDestroy () {
271281 window .removeEventListener (' resize' , this .getWindowHeight )
272282 }
0 commit comments