Skip to content

Commit be678b8

Browse files
committed
fixed merge conflicts
2 parents 39b6109 + dc93c88 commit be678b8

17 files changed

+2101
-56
lines changed

package-lock.json

Lines changed: 1529 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
"fs-extra": "^8.1.0",
1616
"localforage": "^1.7.3",
1717
"mousetrap": "^1.6.3",
18+
"prismjs": "^1.16.0",
1819
"quasar": "^1.0.0",
1920
"vue-custom-context-menu": "^3.0.1",
2021
"vue-drag-resize": "^1.3.2",
2122
"vue-draggable-nested-tree": "^2.2.17",
2223
"vue-draggable-resizable": "^2.0.0-rc2",
2324
"vue-loader": "^15.7.0",
2425
"vue-multiselect": "^2.1.6",
26+
"vue-prism-editor": "^0.2.1",
2527
"vued3tree": "^3.7.1",
2628
"vuedraggable": "^2.23.0",
2729
"vuex": "^3.1.1"
@@ -38,7 +40,8 @@
3840
"eslint": "^5.10.0",
3941
"eslint-loader": "^2.1.1",
4042
"eslint-plugin-vue": "^5.0.0",
41-
"strip-ansi": "^3.0.1"
43+
"strip-ansi": "^3.0.1",
44+
"vue-cli-plugin-electron-builder": "^1.3.6"
4245
},
4346
"engines": {
4447
"node": ">= 8.9.0",

quasar.conf.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ module.exports = function (ctx) {
8686
// analyze: true,
8787
// extractCSS: false,
8888
extendWebpack (cfg) {
89-
cfg.module.rules.push({
90-
enforce: 'pre',
91-
test: /\.(js|vue)$/,
92-
loader: 'eslint-loader',
93-
exclude: /node_modules/,
94-
options: {
95-
formatter: require('eslint').CLIEngine.getFormatter('stylish')
96-
}
97-
})
89+
// cfg.module.rules.push({
90+
// enforce: 'pre',
91+
// test: /\.(js|vue)$/,
92+
// loader: 'eslint-loader',
93+
// exclude: /node_modules/,
94+
// options: {
95+
// formatter: require('eslint').CLIEngine.getFormatter('stylish')
96+
// }
97+
// })
9898
}
9999
},
100100

src/components/CodeSnippet.vue

Lines changed: 109 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,125 @@
11
<template>
2-
<div class="snip">
3-
<q-editor
4-
v-model="editor"
5-
:definitions="{
6-
bold: {label: 'Bold', icon: null, tip: 'My bold tooltip'}
7-
}"
2+
<div>
3+
<!-- <input type="checkbox" v-model="lineNumbers"> Linenumbers -->
4+
{{ `${activeComponent}.vue` }}
5+
<prism-editor
6+
v-model="code"
7+
language="js"
8+
:line-numbers="lineNumbers"
9+
class="code-editor"
10+
:style="{ height: `${height}vh` }"
811
/>
912
</div>
1013
</template>
1114

1215
<script>
16+
import { mapState } from 'vuex'
17+
import PrismEditor from 'vue-prism-editor'
18+
import 'prismjs'
19+
import 'prismjs/themes/prism-okaidia.css'
20+
import 'vue-prism-editor/dist/VuePrismEditor.css'
21+
1322
export default {
1423
data () {
1524
return {
16-
editor: 'Here we are overriding the <b>bold</b> command to include a label instead of an icon and also changing its tooltip.'
25+
code: `Select a component`,
26+
lineNumbers: true,
27+
height: null
28+
}
29+
},
30+
components: {
31+
PrismEditor
32+
},
33+
computed: {
34+
// needs access to current component aka activeComponent
35+
...mapState(['componentMap', 'activeComponent'])
36+
},
37+
methods: {
38+
getWindowHeight (e) {
39+
let minHeight =
40+
window.outerHeight < 900 ? 22 : window.outerHeight < 1035 ? 24 : 27.5
41+
this.height = minHeight
42+
},
43+
// calls createTemplate and createBoiler to generate snippet
44+
createCodeSnippet (componentName, children) {
45+
let result = `${this.createTemplate(componentName, children)}${this.createBoiler(componentName, children)}`
46+
console.log(`createCodeSnippet result: ${result}`)
47+
return result
48+
},
49+
createTemplate (componentName, children) {
50+
let output = ``
51+
// let htmlArr = this.componentMap[compName].htmlList;
52+
output += ` <div>\n`
53+
children.forEach(name => {
54+
output += ` <${name}>\n </${name}>\n`
55+
})
56+
let templateTagStr = this.writeTemplateTag(componentName)
57+
return `<template>\n ${output}${templateTagStr} </div>\n</template>`
58+
},
59+
writeTemplateTag (componentName) {
60+
console.log('writeTemplateTag invoked!')
61+
// create reference object
62+
const htmlElementMap = {
63+
div: ['<div>', '</div>'],
64+
button: ['<button>', '</button>'],
65+
form: ['<form>', '</form>'],
66+
img: ['<img>', ''],
67+
link: ['<a href="#"/>', ''],
68+
list: ['<li>', '</li>'],
69+
paragraph: ['<p>', '</p>'],
70+
'list-ol': ['<ol>', '</ol>'],
71+
'list-ul': ['<ul>', '</ul>'],
72+
input: ['<input />', ''],
73+
navbar: ['<nav>', '</nav>']
74+
}
75+
// loop to iterate through compName arr
76+
let htmlArr = this.componentMap[componentName].htmlList
77+
let outputStr = ``
78+
for (let el of htmlArr) {
79+
outputStr += ` `
80+
outputStr += htmlElementMap[el.text][0]
81+
outputStr += htmlElementMap[el.text][1]
82+
outputStr += ` \n`
83+
}
84+
console.log(`outputStr from writeTemplateTag: ${outputStr}`)
85+
return outputStr
86+
},
87+
createBoiler (componentName, children) {
88+
let str = ''
89+
children.forEach(name => {
90+
str += `import ${name} from '@/components/${name}.vue';\n`
91+
})
92+
let childrenComponentNames = ''
93+
children.forEach(name => {
94+
childrenComponentNames += ` ${name},\n`
95+
})
96+
return `\n\n<script>\n${str}\nexport default {\n name: '${componentName}',\n components: {\n${childrenComponentNames} }\n};\n<\/script>\n\n<style scoped>\n</style>`
1797
}
98+
},
99+
mounted () {
100+
// https://vuejs.org/v2/api/#Vue-nextTick
101+
// kinda like a promise, used for the window resize
102+
this.$nextTick(() => {
103+
window.addEventListener('resize', this.getWindowHeight)
104+
105+
this.getWindowHeight()
106+
})
107+
// set code to this new string literal mofo
108+
// this.code = `${this.createCodeSnippet(this.activeComponent, this.componentMap[this.activeComponent].children)}`
109+
},
110+
// updates code snippet, but broken cause children undefined, shows `function () { [native code] }`
111+
updated () {
112+
console.log(`code: ${this.createCodeSnippet(this.activeComponent, this.componentMap[this.activeComponent].children)}`)
113+
this.code = `${this.createCodeSnippet(this.activeComponent, this.componentMap[this.activeComponent].children)}`
114+
},
115+
beforeDestroy () {
116+
window.removeEventListener('resize', this.getWindowHeight)
18117
}
19118
}
20119
</script>
21120

22-
<style>
23-
.snip{
24-
height: 150px;
121+
<style lang="stylus" scoped>
122+
// resize handled by vue lifecycle methods
123+
.code-editor {
25124
}
26125
</style>

src/components/ComponentDisplay.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
use-chips
4242
stack-label
4343
label="Select children"
44-
style="width: 250px"
44+
style="width: 250px; background-color: #fd5f00"
4545
/>
4646
</q-dialog>
4747
</div>

src/components/CreateComponent.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
2-
<div class="home-sidebar">
2+
<div class="home-sidebar drawer-menu">
33
<!-- <p class="panel-heading">Create a component</p> -->
44
<br />
55
<form v-on:submit.prevent="handleClick" v-on:click="resetActiveComponent">
66
<q-input
7-
standout="bg-teal text-white"
7+
standout="bg-secondary text-white"
88
bottom-slots
99
v-model="componentNameInputValue"
1010
label="Component Name"

0 commit comments

Comments
 (0)