Skip to content

Commit 5a13975

Browse files
committed
added code for z-index
1 parent eb2bd13 commit 5a13975

File tree

7 files changed

+88
-3
lines changed

7 files changed

+88
-3
lines changed

src/components/Canvas.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
element.y !== 0 ? {'left': element.y} : {'left': '10%'},
7171
element.w !== 0 ? {'width': element.w} : {'width': '80%'},
7272
element.h !== 0 ? {'height' : element.h} : {'height' : '40%'},
73+
element.z !== 0 ? {'z-index' : element.z} : {'z-index' : '0'},
7374
{'background-color': componentData.color}]"
7475
>
7576
<p class="innerHtmlText" style="font-size: 3em">{{element.text}}</p>

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

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@
8888
@click="submitLeft(leftText, this.activeHTML)">
8989
</i>
9090
</q-input>
91+
92+
<q-item id="layer-item" filled dark autofocus true hide-bottom-space color="secondary">
93+
<q-item-section v-model="z" class="layer">Component Layer = {{z}}</q-item-section>
94+
<q-btn
95+
class="minorAction"
96+
color="transparent"
97+
text-color="primary"
98+
label="&ndash;"
99+
@click="(e) => handleLayer(e)"
100+
/>
101+
<p id="counter">{{ z }}</p>
102+
<q-btn
103+
class="minorAction"
104+
color="transparent"
105+
text-color="primary"
106+
label="+"
107+
@click="(e) => handleLayer(e)"
108+
/>
109+
</q-item>
110+
111+
112+
91113
<q-btn label="Close" @click="this.openAttributeModal" />
92114
</q-form>
93115
</div>
@@ -105,6 +127,7 @@ export default {
105127
widthText: '0',
106128
topText: '0',
107129
leftText: '0',
130+
z: '0',
108131
}
109132
},
110133
computed: {
@@ -115,7 +138,11 @@ export default {
115138
'activeComponent',
116139
'activeHTML',
117140
'activeLayer',
118-
'attributeModalOpen'
141+
'attributeModalOpen',
142+
'activeRoute',
143+
'routes',
144+
'activeComponentData',
145+
'activeComponentObj',
119146
])
120147
},
121148
components: {
@@ -130,6 +157,7 @@ export default {
130157
'addActiveComponentWidth',
131158
'addActiveComponentTop',
132159
'addActiveComponentLeft',
160+
'updateHTMLLayer',
133161
]),
134162
submitClass(element, idNum) {
135163
if (element === '') {
@@ -187,13 +215,43 @@ export default {
187215
this.leftText = '';
188216
},
189217
218+
handleLayer(e) {
219+
e.preventDefault();
220+
221+
let htmlZ;
222+
223+
this.activeComponentObj.htmlList.forEach( element => {
224+
if (element.id === this.activeHTML) {
225+
htmlZ = element.z;
226+
}
227+
})
228+
229+
const payload = {
230+
activeHTML: this.activeHTML,
231+
z: htmlZ,
232+
};
233+
234+
if (e.target.innerText === "+") {
235+
payload.z++;
236+
this.z++;
237+
}
238+
if (e.target.innerText === "" && payload.z > 0) {
239+
payload.z--;
240+
this.z--;
241+
}
242+
this.updateHTMLLayer(payload);
243+
console.log('here')
244+
console.log(this.activeHTML)
190245
},
246+
191247
watch: {
192248
attributeModalOpen() {
193249
this.attributeModal = this.attributeModalOpen;
194250
},
195251
}
196252
}
253+
254+
}
197255
</script>
198256

199257
<style lang="scss">
@@ -212,4 +270,14 @@ export default {
212270
.title {
213271
font-size: 1.3em
214272
}
273+
274+
.minorAction {
275+
margin-right:5px;
276+
margin-left: 5px;
277+
width:2em;
278+
height: 1.5em;
279+
}
280+
#counter {
281+
padding-top:5px;
282+
}
215283
</style>

src/components/right-sidebar/CodeSnippet.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ z-index: ${this.activeComponentObj.z};
256256
}\n`
257257
}
258258
259-
console.log(htmlArray)
260259
for (const html of htmlArray) {
261260
if (html.class === ' ') styleString = "";
262261
if (html.class) {

src/components/right-sidebar/HTMLQueue.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export default {
115115
if (this.activeComponent === '') return this.selectedElementList.map((el, index) => [el.text, index, el.id])
116116
// change activeComponent's htmlList into an array of arrays ([element/component name, index in state])
117117
if (this.activeComponent !== '' && this.activeLayer.id === '') {
118-
let sortedHTML = this.componentMap[this.activeComponent].htmlList.map((el, index) => [el.text, index, el.id]).filter(el => {
118+
let sortedHTML = this.componentMap[this.activeComponent].htmlList.map((el, index) => [el.text, index, el.id, el.z]).filter(el => {
119119
return el[0] !== undefined
120120
})
121121
return sortedHTML

src/store/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ const actions = {
122122
commit(types.UPDATE_COMPONENT_LAYER, payload);
123123
},
124124

125+
[types.updateHTMLLayer]: ({ commit }, payload) => {
126+
commit(types.UPDATE_HTML_LAYER, payload);
127+
},
128+
125129
[types.updateComponentPosition]: ({ commit }, payload) => {
126130
commit(types.UPDATE_COMPONENT_POSITION, payload);
127131
},

src/store/mutations.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ const mutations = {
473473
if (payload[0] === "") {
474474
state.activeHTML = "";
475475
} else {
476+
console.log(payload)
476477
state.activeHTML = payload[2];
477478
}
478479
},
@@ -780,6 +781,16 @@ const mutations = {
780781
state.componentMap[payload.activeComponent].z = payload.z;
781782
},
782783

784+
[types.UPDATE_HTML_LAYER]: (state, payload) => {
785+
786+
state.componentMap[state.activeComponent].htmlList.forEach((el) => {
787+
if (payload.id === el.id) {
788+
el.z = payload.z
789+
}
790+
})
791+
792+
},
793+
783794
[types.UPDATE_ACTIVE_COMPONENT_CHILDREN_VALUE]: (state, payload) => {
784795
//temp is the activeComponent's children array
785796
if (state.activeComponent === payload) { return }

src/store/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const UPDATE_COMPONENT_CHILDREN_VALUE = 'UPDATE_COMPONENT_CHILDREN_VALUE'
6060
export const UPDATE_COMPONENT_POSITION = 'UPDATE_COMPONENT_POSITION'
6161
export const UPDATE_COLOR = 'UPDATE_COLOR'
6262
export const UPDATE_COMPONENT_LAYER = 'UPDATE_COMPONENT_LAYER'
63+
export const UPDATE_HTML_LAYER = 'UPDATE_HTML_LAYER'
6364
export const UPDATE_COMPONENT_SIZE = 'UPDATE_COMPONENT_SIZE'
6465
export const UPDATE_OPEN_MODAL = 'UPDATE_OPEN_MODAL'
6566
export const DELETE_USER_ACTIONS = 'DELETE_USER_ACTIONS'
@@ -158,6 +159,7 @@ export const updateActiveComponentChildrenValue = 'updateActiveComponentChildren
158159
export const updateComponentChildrenMultiselectValue = 'updateComponentChildrenMultiselectValue'
159160
export const updateComponentChildrenValue = 'updateComponentChildrenValue'
160161
export const updateComponentLayer = 'updateComponentLayer'
162+
export const updateHTMLLayer = 'updateHTMLLayer'
161163
export const updateComponentNameInputValue = 'updateComponentNameInputValue'
162164
export const updateComponentPosition = 'updateComponentPosition'
163165
export const updateComponentSize = 'updateComponentSize'

0 commit comments

Comments
 (0)