ye
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 52s

This commit is contained in:
2026-04-29 01:32:09 +02:00
parent 76bb9fbb30
commit e6d66529e3
16 changed files with 767 additions and 83 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, onMounted } from 'vue';
import { onMounted, onUnmounted, ref } from 'vue';
import Note from './Note.vue';
import { emitter } from '~/services/Emitter';
@@ -9,6 +9,10 @@ const noteContainer = ref(null);
function calculateContainerWidth(){
let dom = noteContainer.value;
if (!dom) {
return;
}
dom.style.width = noteData.value.length * 701 + "px";
setTimeout(() => {
@@ -22,19 +26,33 @@ function calculateContainerWidth(){
}
function pushNote(note){
noteData.value = noteData.value.filter((currentNote) => {
return currentNote.key !== note.key;
});
noteData.value.push(note);
calculateContainerWidth();
}
emitter.on("push-note", (note) => {
function handlePushNote(note) {
pushNote(note);
})
}
emitter.on("delete-note", (key) => {
function handleDeleteNote(key) {
noteData.value = noteData.value.filter((note) => {
return note.key !== key;
});
calculateContainerWidth();
}
// Moure aixo
onMounted(() => {
emitter.on("push-note", handlePushNote);
emitter.on("delete-note", handleDeleteNote);
});
onUnmounted(() => {
emitter.off("push-note", handlePushNote);
emitter.off("delete-note", handleDeleteNote);
});
</script>
@@ -59,10 +77,9 @@ emitter.on("delete-note", (key) => {
display: flex;
height: 100%;
margin: 0;
height: 100%;
background-color: var(--color-background);
}
</style>
<style>
</style>
</style>