Skip to content

Commit

Permalink
feat: adds quick action to add module to recently focused group
Browse files Browse the repository at this point in the history
Provides the user a quick way to add modules to groups. A new indicator in the top right of the
group shows which group is focused, ready to accept gallery modules when double clicked

fixes #496
  • Loading branch information
2xAA committed Jun 23, 2021
1 parent 0d177c3 commit 58c513a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/components/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ export default {
},
async doubleClick() {
if (this.$store.state.focus.type !== "group") {
return;
}
const groupId = this.$store.state.focus.id;
const groupId = this.$store.state["ui-groups"].lastFocused;
if (!groupId) {
return;
}
Expand Down
26 changes: 26 additions & 0 deletions src/components/Group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
@keypress.enter="endTitleEditable"
/>
</div>
<figure
class="group__focusIndicator"
v-show="lastFocusedGroup"
title="Focused Group"
></figure>
<Container
drag-handle-selector=".handle"
orientation="horizontal"
Expand Down Expand Up @@ -365,6 +370,10 @@ export default {
);
},
lastFocusedGroup() {
return this.$store.state["ui-groups"].lastFocused === this.groupId;
},
enabled: {
get() {
return this.group.enabled;
Expand Down Expand Up @@ -494,6 +503,8 @@ export default {
type: "group"
});
}
this.$store.commit("ui-groups/SET_LAST_FOCUSED", this.groupId);
},
removeModule(moduleId) {
Expand All @@ -507,6 +518,10 @@ export default {
this.$modV.store.dispatch("modules/removeActiveModule", {
moduleId
});
if (this.focused) {
this.$store.commit("ui-groups/CLEAR_LAST_FOCUSED");
}
},
toggleTitleEditable() {
Expand Down Expand Up @@ -594,6 +609,7 @@ export default {
overflow: hidden;
display: flex;
flex-direction: column;
position: relative;
}
.group__enabledCheckbox {
Expand Down Expand Up @@ -671,6 +687,16 @@ export default {
max-width: 120px;
}
.group__focusIndicator {
position: absolute;
top: 6px;
right: 6px;
width: 16px;
height: 16px;
border-radius: 50%;
background: #ffffff;
}
.group__controls {
background: #363636;
color: white;
Expand Down
11 changes: 10 additions & 1 deletion src/ui-store/modules/ui-groups.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const state = {
pinned: []
pinned: [],
lastFocused: null
};

const mutations = {
Expand All @@ -17,6 +18,14 @@ const mutations = {
if (index > -1) {
state.splice(index, 1);
}
},

SET_LAST_FOCUSED(state, id) {
state.lastFocused = id;
},

CLEAR_LAST_FOCUSED(state) {
state.lastFocused = null;
}
};

Expand Down

0 comments on commit 58c513a

Please sign in to comment.