From 133558c4ab45b9c5bc7e602e4570f9327b825ffd Mon Sep 17 00:00:00 2001 From: bivashy Date: Fri, 21 Nov 2025 01:40:53 +0500 Subject: [PATCH] Drag and Drop operation on MusicCard --- app/components/action/Draggable.vue | 42 ++++++++++++++++ .../{ui => internal}/musiccard/MusicCard.vue | 0 app/pages/edit.vue | 48 +++++++++++++++++-- app/plugins/vue-dnd-kit.client.ts | 6 +++ bun.lock | 3 ++ package.json | 1 + 6 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 app/components/action/Draggable.vue rename app/components/{ui => internal}/musiccard/MusicCard.vue (100%) create mode 100644 app/plugins/vue-dnd-kit.client.ts diff --git a/app/components/action/Draggable.vue b/app/components/action/Draggable.vue new file mode 100644 index 0000000..83726e9 --- /dev/null +++ b/app/components/action/Draggable.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/app/components/ui/musiccard/MusicCard.vue b/app/components/internal/musiccard/MusicCard.vue similarity index 100% rename from app/components/ui/musiccard/MusicCard.vue rename to app/components/internal/musiccard/MusicCard.vue diff --git a/app/pages/edit.vue b/app/pages/edit.vue index e606e06..ad78dd5 100644 --- a/app/pages/edit.vue +++ b/app/pages/edit.vue @@ -2,9 +2,11 @@ import { Search } from 'lucide-vue-next' import { Button } from '@/components/ui/button' import { InputWithIcon } from '@/components/ui/input' -import MusicCard from '@/components/ui/musiccard/MusicCard.vue' import { Outline } from '@/components/ui/outline' import { SidebarTrigger } from '@/components/ui/sidebar' +import MusicCard from '~/components/internal/musiccard/MusicCard.vue' +import { DnDOperations, useDroppable } from '@vue-dnd-kit/core' +import Draggable from '~/components/action/Draggable.vue' const searchValue = ref('') @@ -66,6 +68,15 @@ const selectTrack = (trackId: number) => { track.selected = track.id === trackId }) } + +const { elementRef: tracksRef } = useDroppable({ + data: { + source: tracks.value, + }, + events: { + onDrop: DnDOperations.applyTransfer, + }, +});