New category input improvements

This commit is contained in:
2021-11-06 00:24:59 +03:00
parent 85ed1e05e5
commit 6cd4a91ec7
2 changed files with 10 additions and 3 deletions

View File

@@ -5,7 +5,8 @@
v-model="newCategory" v-model="newCategory"
placeholder="New category" placeholder="New category"
@keypress.enter="addCategory" @keypress.enter="addCategory"
@mouseenter="newCategory = ''" @click="hoverInput"
@mouseenter="hoverInput"
@mouseleave="blurInput" @mouseleave="blurInput"
/> />
<div class="categories"> <div class="categories">
@@ -44,11 +45,16 @@ export default {
removeCategory(category) { removeCategory(category) {
this.$store.commit('removeCategory', category); this.$store.commit('removeCategory', category);
if (category === this.selectedCategory) { if (category === this.selectedCategory) {
this.selectedCategory(); this.selectCategory();
} }
}, },
hoverInput(event) {
this.newCategory = '';
event.target.classList.add('hover');
},
blurInput(event) { blurInput(event) {
this.newCategory = '+'; this.newCategory = '+';
event.target.classList.remove('hover');
event.target.blur(); event.target.blur();
}, },
stringToColor(str) { stringToColor(str) {
@@ -93,7 +99,7 @@ export default {
box-sizing: border-box; box-sizing: border-box;
transition: width 0.6s; transition: width 0.6s;
&:hover { &.hover {
width: 220px; width: 220px;
} }
} }

View File

@@ -10,6 +10,7 @@ export default createStore({
categories: [], categories: [],
tasks: [], tasks: [],
midnightReset: false, midnightReset: false,
lastReset: undefined,
darkTheme: true, darkTheme: true,
}, },
mutations: { mutations: {