Skip to content

Commit 0ea67da

Browse files
committed
Added colors to each component
1 parent 5139fd4 commit 0ea67da

File tree

5 files changed

+33
-13
lines changed

5 files changed

+33
-13
lines changed

src/components/Canvas.vue

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
@resizestop="finishedResize"
3333
:onDragStart="recordInitialPosition"
3434
:onResizeStart="recordInitialSize"
35+
:style="{'background-color': componentData.color}"
3536
>
37+
3638

3739
<div class="component-title">
3840
<p>{{ componentData.componentName }}</p>
@@ -171,18 +173,14 @@
171173

172174
<!--color selector-->
173175
<q-dialog v-model="colorModal" @update:model-value="handleEditColor">
176+
<!--may need to change starting to be current state?-->
174177
<ColorPicker
175178
class="colorPicker"
176179
default-format="hex"
177180
id="color-picker-1"
178181
:visible-formats="['hex']"
179-
:color="{
180-
h: 1,
181-
s: 1,
182-
l: 0.5,
183-
a: 1
184-
}"
185-
@color-change="updateColor"
182+
:color="this.activeComponentData.color"
183+
@color-change="updateColors"
186184
>
187185
<template #hue-range-input-label>
188186
<span class="sr-only">Hue</span>
@@ -415,6 +413,7 @@ export default {
415413
"deleteActiveComponentNote",
416414
"openNoteModal",
417415
"openColorModal",
416+
"updateColor",
418417
]),
419418
useExportComponentBound(){
420419
useExportComponent.bind(this)();
@@ -432,8 +431,15 @@ export default {
432431
this.initialPosition.y = this.activeComponentData.y;
433432
},
434433
//color change function
435-
updateColor (data) {
436-
console.log(data)
434+
updateColors (data) {
435+
let payload = {
436+
color: data.cssColor,
437+
activeComponent: this.activeComponent,
438+
routeArray: this.routes[this.activeRoute],
439+
activeComponentData: this.activeComponentData,
440+
}
441+
this.updateColor(payload)
442+
437443
},
438444
439445
// records component's initial size/position in case of resize
@@ -796,15 +802,15 @@ li:hover{
796802
.component-box {
797803
color: $menutext;
798804
border: 1.2px dashed $darktext;
799-
background-color: rgba($darktext, .42);
805+
// background-color: rgba($darktext, .42);
800806
-webkit-transition: background-color 200ms linear;
801807
-ms-transition: background-color 200ms linear;
802808
transition: background-color 200ms linear;
803809
position: absolute;
804810
}
805811
.active {
806-
background-color: rgba($secondary, .42);
807-
border: 1px dashed $accent;
812+
// background-color: rgba($secondary, .42);
813+
border: 3px solid $primary;
808814
}
809815
.minorAction {
810816
font-weight: bolder !important;

src/components/composables/useCreateComponent.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export function useCreateComponent(importObj) {
4141
state: [],
4242
parent: {},
4343
isActive: false,
44+
color: "#ffffff00"
4445
};
4546

4647
if (imported === true){

src/store/actions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ const actions = {
113113
[types.updateComponentSize]: ({ commit }, payload) => {
114114
commit(types.UPDATE_COMPONENT_SIZE, payload);
115115
},
116-
116+
//color updater
117+
[types.updateColor]: ({ commit }, payload) => {
118+
commit(types.UPDATE_COLOR, payload);
119+
},
117120
// copy the active component
118121
[types.copyActiveComponent]: ({ commit }, payload) => {
119122
commit(types.COPY_ACTIVE_COMPONENT);

src/store/mutations.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,14 @@ const mutations = {
626626
updatedComponent.x = payload.x;
627627
updatedComponent.y = payload.y;
628628
},
629+
//color updater
630+
[types.UPDATE_COLOR]: (state, payload) => {
631+
const updatedComponent = state.routes[state.activeRoute].filter(
632+
(element) => element.componentName === payload.activeComponent
633+
)[0];
634+
635+
updatedComponent.color = payload.color
636+
},
629637

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

src/store/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const UPDATE_COMPONENT_CHILDREN_MULTISELECT_VALUE = 'UPDATE_COMPONENT_CHI
5757
export const UPDATE_COMPONENT_NAME_INPUT_VALUE = 'UPDATE_COMPONENT_NAME_INPUT_VALUE'
5858
export const UPDATE_COMPONENT_CHILDREN_VALUE = 'UPDATE_COMPONENT_CHILDREN_VALUE'
5959
export const UPDATE_COMPONENT_POSITION = 'UPDATE_COMPONENT_POSITION'
60+
export const UPDATE_COLOR = 'UPDATE_COLOR'
6061
export const UPDATE_COMPONENT_LAYER = 'UPDATE_COMPONENT_LAYER'
6162
export const UPDATE_COMPONENT_SIZE = 'UPDATE_COMPONENT_SIZE'
6263
export const UPDATE_OPEN_MODAL = 'UPDATE_OPEN_MODAL'
@@ -140,6 +141,7 @@ export const updateComponentLayer = 'updateComponentLayer'
140141
export const updateComponentNameInputValue = 'updateComponentNameInputValue'
141142
export const updateComponentPosition = 'updateComponentPosition'
142143
export const updateComponentSize = 'updateComponentSize'
144+
export const updateColor = 'updateColor'
143145
export const updateOpenModal = 'updateOpenModal'
144146
export const updateStartingPosition = 'updateStartingPosition'
145147
export const updateStartingSize = 'updateStartingSize'

0 commit comments

Comments
 (0)