Skip to content

Commit 5139fd4

Browse files
committed
updated with color option in grid
1 parent a20bf92 commit 5139fd4

File tree

7 files changed

+175
-64
lines changed

7 files changed

+175
-64
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@
4848
"vue-multiselect": "^3.0.0-alpha.2",
4949
"vue-prism-editor": "^2.0.0-alpha.2",
5050
"vue-router": "4.0.13",
51+
"vue3-draggable-resizable": "^1.6.4",
5152
"vue3-tree": "^0.11.0",
5253
"vued3tree": "^5.1.0",
54+
"vuedraggable": "^4.1.0",
5355
"vuex": "^4.0.2"
5456
},
5557
"devDependencies": {

src/components/Canvas.vue

Lines changed: 121 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -12,69 +12,6 @@
1212
v-on:click="handleClick"
1313
v-on:click.right="handleRight"
1414
>
15-
<!--color selector-->
16-
<ColorPicker
17-
class="colorPicker"
18-
default-format="hex"
19-
id="color-picker-1"
20-
:visible-formats="['hex']"
21-
:color="{
22-
h: 1,
23-
s: 1,
24-
l: 0.5,
25-
a: 1
26-
}"
27-
@color-change="updateColor"
28-
>
29-
<template #hue-range-input-label>
30-
<span class="sr-only">Hue</span>
31-
</template>
32-
33-
<template #alpha-range-input-label>
34-
<span class="sr-only">Alpha</span>
35-
</template>
36-
37-
<template #copy-button>
38-
<span class="sr-only">Copy color</span>
39-
40-
<svg
41-
aria-hidden="true"
42-
xmlns="http://www.w3.org/2000/svg"
43-
width="15"
44-
height="15"
45-
viewBox="0 0 15 15"
46-
>
47-
<path
48-
d="M5 0v2H1v13h12v-3h-1v2H2V5h10v3h1V2H9V0zm1 1h2v2h3v1H3V3h3z"
49-
fill="currentColor"
50-
/>
51-
52-
<path
53-
d="M10 7v2h5v2h-5v2l-3-3zM3 6h5v1H3zm0 2h3v1H3zm0 2h3v1H3zm0 2h5v1H3z"
54-
fill="currentColor"
55-
/>
56-
</svg>
57-
</template>
58-
59-
<template #format-switch-button>
60-
<span class="sr-only">Switch format</span>
61-
62-
<svg
63-
aria-hidden="true"
64-
xmlns="http://www.w3.org/2000/svg"
65-
width="16"
66-
height="15"
67-
viewBox="0 0 16 15"
68-
>
69-
<path
70-
d="M8 15l5-5-1-1-4 2-4-2-1 1zm4-9l1-1-5-5-5 5 1 1 4-2z"
71-
fill="currentColor"
72-
/>
73-
</svg>
74-
</template>
75-
</ColorPicker>
76-
77-
7815
<!-- This is the actual component box -->
7916
<!-- https://www.npmjs.com/package/vue-draggable-resizable -->
8017
<vue-draggable-resizable
@@ -112,6 +49,12 @@
11249
name="edit_note"
11350
class="compNoteLogoEmpty"
11451
@click="handleAddNotes" />
52+
<q-icon
53+
size="30px"
54+
z-layer="0"
55+
name="palette"
56+
class="colorLogo"
57+
@click="handleEditColor" />
11558

11659
<!-- start of right click function-->
11760
<q-menu context-menu>
@@ -152,7 +95,7 @@
15295
<q-icon color="primary" name="upload" />
15396
</q-item-section>
15497
</q-item>
155-
<q-item clickable v-ripple v-close-popup @click="handleAddChild">
98+
<q-item clickable v-ripple v-close-popup @click="handleEditColor">
15699
<q-item-section>Edit Color</q-item-section>
157100
<q-item-section avatar>
158101
<q-icon color="primary" name="edit" />
@@ -224,17 +167,86 @@
224167
</div>
225168
</div>
226169
</q-dialog>
170+
171+
172+
<!--color selector-->
173+
<q-dialog v-model="colorModal" @update:model-value="handleEditColor">
174+
<ColorPicker
175+
class="colorPicker"
176+
default-format="hex"
177+
id="color-picker-1"
178+
:visible-formats="['hex']"
179+
:color="{
180+
h: 1,
181+
s: 1,
182+
l: 0.5,
183+
a: 1
184+
}"
185+
@color-change="updateColor"
186+
>
187+
<template #hue-range-input-label>
188+
<span class="sr-only">Hue</span>
189+
</template>
190+
191+
<template #alpha-range-input-label>
192+
<span class="sr-only">Alpha</span>
193+
</template>
194+
195+
<template #copy-button>
196+
<span class="sr-only">Copy color</span>
197+
198+
<svg
199+
aria-hidden="true"
200+
xmlns="http://www.w3.org/2000/svg"
201+
width="15"
202+
height="15"
203+
viewBox="0 0 15 15"
204+
>
205+
<path
206+
d="M5 0v2H1v13h12v-3h-1v2H2V5h10v3h1V2H9V0zm1 1h2v2h3v1H3V3h3z"
207+
fill="currentColor"
208+
/>
209+
210+
<path
211+
d="M10 7v2h5v2h-5v2l-3-3zM3 6h5v1H3zm0 2h3v1H3zm0 2h3v1H3zm0 2h5v1H3z"
212+
fill="currentColor"
213+
/>
214+
</svg>
215+
</template>
216+
217+
<template #format-switch-button>
218+
<span class="sr-only">Switch format</span>
219+
220+
<svg
221+
aria-hidden="true"
222+
xmlns="http://www.w3.org/2000/svg"
223+
width="16"
224+
height="15"
225+
viewBox="0 0 16 15"
226+
>
227+
<path
228+
d="M8 15l5-5-1-1-4 2-4-2-1 1zm4-9l1-1-5-5-5 5 1 1 4-2z"
229+
fill="currentColor"
230+
/>
231+
</svg>
232+
</template>
233+
</ColorPicker>
234+
</q-dialog>
235+
227236
</div>
228237
</div>
229238
</template>
230239

231240

241+
232242
<script>
233243
import { useExportComponent } from "./composables/useExportComponent.js";
234244
import { mapState, mapActions } from "vuex";
235245
import VueDraggableResizable from "vue-draggable-resizable/src/components/vue-draggable-resizable.vue";
246+
import Vue3DraggableResizable from 'vue3-draggable-resizable'
236247
import VueMultiselect from "vue-multiselect";
237248
import "vue-draggable-resizable/src/components/vue-draggable-resizable.css";
249+
import 'vue3-draggable-resizable/dist/Vue3DraggableResizable.css'
238250
import { ColorPicker } from 'vue-accessible-color-picker'
239251
240252
const { fs, ipcRenderer } = window;
@@ -244,6 +256,7 @@ const cloneDeep = require("lodash.clonedeep");
244256
export default {
245257
name: "Canvas",
246258
components: {
259+
Vue3DraggableResizable,
247260
VueDraggableResizable,
248261
VueMultiselect,
249262
ColorPicker,
@@ -255,6 +268,7 @@ export default {
255268
wasDragged: false,
256269
testModel: [],
257270
noteModal: false,
271+
colorModal: false,
258272
mockImg: false,
259273
initialPosition: { x: 0, y: 0 },
260274
initialSize: { w: 0, h: 0 },
@@ -302,10 +316,12 @@ export default {
302316
"activeComponentObj",
303317
"exportAsTypescript",
304318
"noteModalOpen",
319+
"colorModalOpen",
305320
"activeRouteDisplay"
306321
]),
307322
// used in VueDraggableResizeable component
308323
activeRouteArray() {
324+
console.log(this.routes[this.activeRoute])
309325
return this.routes[this.activeRoute];
310326
},
311327
// used to delete active component
@@ -398,6 +414,7 @@ export default {
398414
"addActiveComponentNote",
399415
"deleteActiveComponentNote",
400416
"openNoteModal",
417+
"openColorModal",
401418
]),
402419
useExportComponentBound(){
403420
useExportComponent.bind(this)();
@@ -503,6 +520,13 @@ export default {
503520
this.openNoteModal();
504521
}
505522
},
523+
524+
handleEditColor(){
525+
if (this.wasDragged === false && this.activeComponent !== ''){
526+
this.openColorModal();
527+
}
528+
},
529+
506530
handleAddChild() {
507531
this.modalOpen = true;
508532
},
@@ -550,6 +574,9 @@ export default {
550574
noteModalOpen (){
551575
this.noteModal = this.noteModalOpen;
552576
},
577+
colorModalOpen (){
578+
this.colorModal = this.colorModalOpen;
579+
},
553580
activeComponent: {
554581
handler(){
555582
if (this.activeComponent !== '' &&
@@ -603,6 +630,16 @@ li:hover{
603630
height: 65vh;
604631
max-height: 80vh;
605632
}
633+
.colorBox{
634+
background-color: $subsecondary;
635+
color: $menutext;
636+
width: 65%;
637+
padding: 15px;
638+
height: 65vh;
639+
max-height: 80vh;
640+
}
641+
642+
606643
.noteNum{
607644
width: 10%;
608645
}
@@ -723,6 +760,20 @@ li:hover{
723760
left: 4px;
724761
}
725762
763+
.colorLogo {
764+
background: rgba($subprimary, .9);
765+
color: $secondary;
766+
border-radius: 4px;
767+
position: absolute;
768+
top: 4px;
769+
left: 40px;
770+
}
771+
772+
.colorLogo:hover{
773+
background: rgba($subprimary, .6);
774+
color: rgba($secondary, .8);
775+
}
776+
726777
.compNoteLogoEmpty{
727778
background: rgba($subprimary, .9);
728779
color: rgba($primary, 1);
@@ -736,6 +787,7 @@ li:hover{
736787
color: rgba($secondary, .8);
737788
}
738789
790+
739791
.compNoteLogoEmpty:hover{
740792
background: rgba($subprimary, .6);
741793
color: rgba($menutext, .4);
@@ -816,4 +868,9 @@ li:hover{
816868
background: rgba(177, 171, 171, 0.562);
817869
}
818870
871+
.colorContainer {
872+
position:relative;
873+
background: black
874+
}
875+
819876
</style>

0 commit comments

Comments
 (0)