Reworked modals

This commit is contained in:
2021-11-05 23:15:04 +03:00
parent eed9223b77
commit 92f73084e8
8 changed files with 91 additions and 42 deletions

View File

@@ -0,0 +1,66 @@
<template>
<Modal ref="modal">
<div class="title">Assign Category</div>
<div
v-for="category in categories"
:key="category"
class="category"
:style="{ background: stringToColor(category) }"
@click="assignCategory(category)"
>
{{ category }}
</div>
</Modal>
</template>
<script>
import { ref, computed } from 'vue';
import { useStore } from 'vuex';
import Modal from '@/components/Modal.vue';
import toColor from '@/stringToColor';
export default {
components: { Modal },
props: {
name: {
type: String,
required: true,
},
},
setup(props) {
const store = useStore();
const modal = ref(null);
const open = () => {
modal.value.open();
};
const close = () => {
modal.value.close();
};
const stringToColor = (str) => toColor(str);
const assignCategory = (category) => {
store.commit('assignCategory', { name: props.name, category });
modal.value.close();
};
return {
modal,
open,
close,
assignCategory,
stringToColor,
categories: computed(() => store.state.categories),
};
},
};
</script>
<style lang="scss" scoped>
.category {
margin-top: 12px;
border-radius: 24px !important;
padding: 12px 24px !important;
}
</style>