Skip to content

Commit 2e0203f

Browse files
committed
Grid works, need to fix component positioning dragfinish bug
1 parent 3b162b0 commit 2e0203f

File tree

7 files changed

+59
-19
lines changed

7 files changed

+59
-19
lines changed

src/components/Canvas.vue

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
<template>
88
<!-- the background Canvas grid -->
99
<div class="component-display grid-bg" :style="mockBg" v-on:click="handleClick" v-on:click.right="handleRight">
10-
<div class="cssContainer">
10+
<div class="cssContainer" :style="{ 'background-size': `${this.gridLayout[0]}px ${this.gridLayout[1]}px, ${this.gridLayout[0]}px ${this.gridLayout[1]}px` }">
1111
<!-- This is the actual component box -->
1212
<!-- https://www.npmjs.com/package/vue-draggable-resizable -->
13-
<p class="cssContainerText">
14-
CSS Container</p>
15-
13+
<p class="cssContainerText"> CSS Container {{ this.activeComponentObj }}</p>
1614
<!--each component box in canvas will have these properties-->
15+
<!-- !For property :Grid - look into setting it as a store variable/ input variable - no dynamic :grid changing for props- need to implement -->
1716
<vue-draggable-resizable
1817
class-name="component-box"
1918
v-for="componentData in activeRouteArray"
@@ -23,8 +22,9 @@
2322
:x="componentData.x"
2423
:y="componentData.y"
2524
:z="componentData.z"
26-
:w="componentData.w"
27-
:h="componentData.h"
25+
:w="2 * this.gridLayout[0]"
26+
:h="2 * this.gridLayout[1]"
27+
:grid="this.gridLayout"
2828
:preventDeactivation="true"
2929
@activated="onActivated(componentData)"
3030
@deactivated="onDeactivated(componentData)"
@@ -69,7 +69,7 @@
6969
{'background-color': componentData.color}]"
7070
>
7171
<p class="innerHtmlText" style="font-size: 3em">{{element.note !== '' ? element.note : element.text}}</p>
72-
</div>
72+
</div>sss
7373
<div v-if="element.text === 'footer'" class="htmlFooter"></div>
7474
<div v-if="element.text === 'form'"
7575
class="htmlGeneral"
@@ -344,7 +344,7 @@
344344
import { useExportComponent } from "./composables/useExportComponent.js";
345345
import { mapState, mapActions } from "vuex";
346346
import VueDraggableResizable from "vue-draggable-resizable/src/components/vue-draggable-resizable.vue";
347-
import Vue3DraggableResizable from 'vue3-draggable-resizable'
347+
// import Vue3DraggableResizable from 'vue3-draggable-resizable'
348348
import VueMultiselect from "vue-multiselect";
349349
import "vue-draggable-resizable/src/components/vue-draggable-resizable.css";
350350
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'
@@ -357,7 +357,7 @@ const cloneDeep = require("lodash.clonedeep");
357357
export default {
358358
name: "Canvas",
359359
components: {
360-
Vue3DraggableResizable,
360+
// Vue3DraggableResizable,
361361
VueDraggableResizable,
362362
VueMultiselect,
363363
ColorPicker,
@@ -406,7 +406,8 @@ export default {
406406
'selectedElementList',
407407
'activeLayer',
408408
"colorModalOpen",
409-
"activeRouteDisplay"
409+
"activeRouteDisplay",
410+
"gridLayout",
410411
]),
411412
// used in VueDraggableResizeable component
412413
activeRouteArray() {
@@ -503,6 +504,7 @@ export default {
503504
"openNoteModal",
504505
"openColorModal",
505506
"updateColor",
507+
"updateStateComponentPosition"
506508
]),
507509
useExportComponentBound() {
508510
useExportComponent.bind(this)();
@@ -557,7 +559,6 @@ export default {
557559
payload.h !== this.initialSize.h
558560
) {
559561
this.updateComponentSize(payload);
560-
561562
}
562563
this.refresh();
563564
},
@@ -575,7 +576,7 @@ export default {
575576
payload.z--;
576577
this.updateComponentLayer(payload);
577578
},
578-
//drag and drop function
579+
//!drag and drop function
579580
finishedDrag: function (x, y) {
580581
let payload = {
581582
x: x,
@@ -588,6 +589,7 @@ export default {
588589
payload.x !== this.initialPosition.x ||
589590
payload.y !== this.initialPosition.y
590591
) {
592+
// console.log(payload);
591593
this.updateComponentPosition(payload);
592594
}
593595
this.wasDragged = true;
@@ -874,6 +876,27 @@ li:hover {
874876
border: 1px solid black;
875877
width: 1000px;
876878
height: 900px;
879+
background-color: rgba(223, 218, 218, 0.886);
880+
background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
881+
// background-position: -2px -2px, -2px -2px, -1px -1px, -1px -1px;
882+
background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0.8) 1px, transparent 1px),
883+
-webkit-linear-gradient(0, rgba(255, 255, 255, 0.8) 1px, transparent 1px),
884+
-webkit-linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
885+
-webkit-linear-gradient(0, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
886+
background-image: -moz-linear-gradient(rgba(255, 255, 255, 0.8) 1px, transparent 1px),
887+
-moz-linear-gradient(0, rgba(255, 255, 255, 0.8) 1px, transparent 1px),
888+
-moz-linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
889+
-moz-linear-gradient(0, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
890+
background-image: linear-gradient(rgba(255, 255, 255, 0.8) 1px, transparent 1px),
891+
linear-gradient(90deg, rgba(255, 255, 255, 0.8) 1px, transparent 1px),
892+
linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
893+
linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
894+
-pie-background: linear-gradient(rgba(255, 255, 255, 0.8) 1px, transparent 1px) -2px -2px / 100px,
895+
linear-gradient(90deg, rgba(255, 255, 255, 0.8) 1px, transparent 1px) -2px -2px / 100px,
896+
linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px) -1px -1px / 20px,
897+
linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px) -1px -1px / 20px,
898+
$secondary;
899+
behavior: url(/pie/PIE.htc);
877900
}
878901
879902
.cssContainerText {

src/components/composables/useCreateComponent.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ export function useCreateComponent(importObj) {
2929
// boilerplate properties for each component upon creation
3030
const component = {
3131
x: 0,
32-
y: 20,
32+
y: 0,
3333
z: 0,
34-
w: 200,
35-
h: 200,
34+
// !Chris: disabling this temporarily to see if we can have create component dynamically fit into grid- less snapping bugs
35+
// w: 200,
36+
// h: 200,
3637
htmlList: this.selectedElementList,
3738
noteList: [],
3839
children: [],
@@ -47,7 +48,7 @@ export function useCreateComponent(importObj) {
4748
htmlAttributes: {
4849
class: "",
4950
id: ""
50-
}
51+
},
5152
};
5253

5354
if (imported === true) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Description:
88
<template>
99
<div class="create-component-div drawer-menu">
1010
<q-expansion-item group="accordion" label="Import Component">
11+
<!-- !THIS IS THE IMPORT COMPONENT TAB WE NEED TO WORK ON -->
1112
<ImportComponent v-if="activeComponent === ''" @imported="createComponent" title="Import Component (coming soon)" class="sidebar-btn" :disable = "true"/>
1213
</q-expansion-item>
1314
<q-expansion-item group="accordion" label="Create Component">

src/store/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const actions = {
133133
[types.updateComponentPosition]: ({ commit }, payload) => {
134134
commit(types.UPDATE_COMPONENT_POSITION, payload);
135135
},
136+
136137
[types.addBindingText]: ({ commit }, payload) => {
137138
commit(types.addBindingText, payload);
138139
},

src/store/mutations.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ const mutations = {
522522
}
523523
state.activeHTML = "";
524524
},
525-
//Drag-andDrop
525+
//!Drag-andDrop
526526
//store id of dragged html element in activeComponent
527527
[types.SET_ID_DRAG]: (state, payload) => {
528528
const componentName = state.activeComponent;
@@ -765,11 +765,22 @@ const mutations = {
765765
updatedComponent.y = payload.y;
766766
},
767767

768-
[types.UPDATE_COMPONENT_SIZE]: (state, payload) => {
768+
// updates state to code snippet component position
769+
[types.UPDATE_COMPONENT_POSITION]: (state, payload) => {
770+
//! this thing is returning undefined for some reason
769771
const updatedComponent = state.routes[state.activeRoute].filter(
770772
(element) => element.componentName === payload.activeComponent
771773
)[0];
774+
console.log(updatedComponent, 'this is payload', payload);
775+
updatedComponent.x = payload.x;
776+
updatedComponent.y = payload.y;
777+
},
772778

779+
[types.UPDATE_COMPONENT_SIZE]: (state, payload) => {
780+
const updatedComponent = state.routes[state.activeRoute].filter(
781+
(element) => element.componentName === payload.activeComponent
782+
)[0];
783+
console.log(updatedComponent, 'this is payload', payload);
773784
updatedComponent.h = payload.h;
774785
updatedComponent.w = payload.w;
775786
updatedComponent.x = payload.x;

src/store/state/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ const newState = {
6868
showTutorial: true,
6969
tutorialFirstOpen: true,
7070
pasteTimer: 0,
71+
gridLayout: [70, 70],
72+
x: 0,
73+
y: 0,
7174
}
7275

7376
// closured method to ensure we only ever write the default state ONCE

src/store/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const CLEAR_ACTIVE_HTML = 'CLEAR_ACTIVE_HTML'
8585
//
8686
export const REMOVE_ALL_STATE_PROPS_ACTIONS = 'REMOVE_ALL_STATE_PROPS_ACTIONS'
8787
export const UPDATE_PASTE_TIMER = 'UPDATE_PASTE_TIMER'
88-
//Drag and Drop
88+
//!Drag and Drop
8989
export const SET_ID_DRAG = 'SET_ID_DRAG'
9090
export const SET_ID_DROP = 'SET_ID_DROP'
9191
export const SET_SELECTED_ID_DRAG = 'SET_SELECTED_ID_DRAG'

0 commit comments

Comments
 (0)