Skip to content

Commit 5584bb3

Browse files
committed
fized error
2 parents 17a78ee + d7d4d4d commit 5584bb3

File tree

4 files changed

+78
-12
lines changed

4 files changed

+78
-12
lines changed

src/components/Canvas.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ export default {
451451
activeComponentData: this.activeComponentData,
452452
}
453453
this.updateColor(payload)
454-
},
454+
this.refresh();
455+
},
455456
456457
// records component's initial size/position in case of resize
457458
recordInitialSize: function (e) {
@@ -478,8 +479,25 @@ export default {
478479
payload.h !== this.initialSize.h
479480
) {
480481
this.updateComponentSize(payload);
482+
481483
}
484+
this.refresh();
482485
},
486+
487+
//refresh function - super ghetto refresh function
488+
refresh() {
489+
const payload = {
490+
activeComponent: this.activeComponent,
491+
routeArray: this.routes[this.activeRoute],
492+
activeComponentData: this.activeComponentData,
493+
z: this.activeComponentData.z,
494+
};
495+
payload.z++;
496+
this.updateComponentLayer(payload);
497+
payload.z--;
498+
this.updateComponentLayer(payload);
499+
},
500+
483501
finishedDrag: function (x, y) {
484502
let payload = {
485503
x: x,
@@ -496,6 +514,7 @@ export default {
496514
}
497515
this.wasDragged = true;
498516
setTimeout(()=>this.wasDragged = false, 100)
517+
this.refresh();
499518
},
500519
onActivated(componentData) {
501520
if (!componentData){
@@ -571,6 +590,7 @@ export default {
571590
activeComponentData: this.activeComponentData,
572591
z: this.activeComponentData.z,
573592
};
593+
574594
if (e.target.innerText === "+") payload.z++;
575595
if (e.target.innerText === "" && payload.z > 0) payload.z--;
576596
this.updateComponentLayer(payload);

src/components/left-sidebar/ComponentTab/AttributesSubMenu.vue

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
</q-list>
1818
</q-btn-dropdown>
1919

20-
2120
<q-input
2221
@keyup.enter="createAttribute(attributeText)"
2322
color="white"
@@ -35,6 +34,9 @@
3534
</template>
3635
</q-input>
3736

37+
<button v-if = "this.activeComponentObj.htmlAttributes.class !== ''" class = "deleteButton" @click="deleteAttribute('class')" color="primary">Remove class</button>
38+
39+
<button v-if = "this.activeComponentObj.htmlAttributes.id !== ''" class = "deleteButton" @click="deleteAttribute('id')" color="primary">Remove id</button>
3840

3941
<!-- <div>
4042
<q-btn
@@ -62,6 +64,7 @@ export default {
6264
return {
6365
attributeText: "",
6466
attributeSelection: "ID",
67+
deleteText:"",
6568
};
6669
},
6770
computed: {
@@ -94,8 +97,19 @@ export default {
9497
activeComponentData: this.activeComponentData,
9598
})
9699
},
100+
97101
changeAttribute(attribute) {
98102
this.attributeSelection = attribute;
103+
},
104+
105+
deleteAttribute(attribute) {
106+
this.editAttribute({
107+
attribute: attribute,
108+
value: "",
109+
activeComponent: this.activeComponent,
110+
routeArray: this.routes[this.activeRoute],
111+
activeComponentData: this.activeComponentData,
112+
})
99113
}
100114
},
101115
};
@@ -110,9 +124,23 @@ export default {
110124
}
111125
112126
.input-add {
113-
position:absolute;
114-
margin-left: 7em;
115-
bottom:-60%;
116-
// padding:20px;
127+
// position:absolute;
128+
// margin-left: 7em;
129+
// bottom:-100%;
130+
margin-top:1em;
131+
margin-bottom: -1em;
117132
}
133+
.deleteButton{
134+
width:100px;
135+
height:30px;
136+
background-color:rgba(204, 190, 190, 0.164);
137+
color: $menutext;
138+
margin-right:2em;
139+
}
140+
141+
.deleteButton:hover{
142+
cursor: pointer;
143+
}
144+
145+
118146
</style>

src/components/right-sidebar/CodeSnippet.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ Description:
1111
<div class="top-p" v-if="this.activeComponent === ''">
1212
Select a component
1313
</div>
14-
<div v-else>{{ `${this.activeComponent}.vue` }}</div> <button class="refreshCode">
15-
<q-icon size="25px" z-layer="0" name="refresh" @click="this.snippetInvoke" />
16-
</button>
14+
<div v-else>{{ `${this.activeComponent}.vue` }}</div>
1715
<prism-editor v-model="code" :highlight="highlighter" line-numbers class="my-editor" readonly />
1816
</div>
1917
</template>
@@ -76,9 +74,15 @@ export default {
7674
// Creates beginner boilerplate
7775
createTemplate(componentName) {
7876
let templateTagStr = this.writeTemplateTag(componentName);
79-
if (this.activeComponentObj.htmlAttributes.class !== "") return `<template>\n <div class = "${this.activeComponentObj.htmlAttributes.class}">\n${templateTagStr} </div>\n</template>`;
80-
else return `<template>\n <div>\n${templateTagStr} </div>\n</template>`;
8177
78+
//if/else statement to determine if there are class and id attributes present in the html element
79+
if (this.activeComponentObj.htmlAttributes.class !== "" && this.activeComponentObj.htmlAttributes.id !== "") {
80+
return `<template>\n <div id = "${this.activeComponentObj.htmlAttributes.id}" class = "${this.activeComponentObj.htmlAttributes.class}">\n${templateTagStr} </div>\n</template>`;
81+
} else if (this.activeComponentObj.htmlAttributes.class !== "" && this.activeComponentObj.htmlAttributes.id === "") {
82+
return `<template>\n <div class = "${this.activeComponentObj.htmlAttributes.class}">\n${templateTagStr} </div>\n</template>`;
83+
} else if (this.activeComponentObj.htmlAttributes.class === "" && this.activeComponentObj.htmlAttributes.id !== "")
84+
return `<template>\n <div id = "${this.activeComponentObj.htmlAttributes.id}">\n${templateTagStr} </div>\n</template>`;
85+
else return `<template>\n <div>\n${templateTagStr} </div>\n</template>`;
8286
},
8387
// Creates <template> boilerplate
8488
writeTemplateTag(componentName) {
@@ -251,7 +255,6 @@ z-index: ${this.activeComponentObj.z}px;
251255
for (const html of htmlArray) {
252256
if (html.class === ' ') styleString = "";
253257
if (html.class) {
254-
console.log(this.activeComponentObj)
255258
styleString += `.${html.class} {\n
256259
}\n`
257260
}

src/store/mutations.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,21 @@ const mutations = {
628628
updatedComponent.x = payload.x;
629629
updatedComponent.y = payload.y;
630630
},
631+
//color updater
632+
[types.UPDATE_COLOR]: (state, payload) => {
633+
const updatedComponent = state.routes[state.activeRoute].filter(
634+
(element) => element.componentName === payload.activeComponent
635+
)[0];
636+
637+
updatedComponent.color = payload.color
638+
},
639+
640+
[types.EDIT_ATTRIBUTE]: (state, payload) => {
641+
const updatedComponent = state.routes[state.activeRoute].filter(
642+
(element) => element.componentName === payload.activeComponent
643+
)[0];
644+
updatedComponent.htmlAttributes[payload.attribute] = payload.value
645+
},
631646

632647
[types.UPDATE_COMPONENT_LAYER]: (state, payload) => {
633648
const updatedComponent = state.routes[state.activeRoute].filter(

0 commit comments

Comments
 (0)