Replace vue-dnd-code with vue-draggable-next
This commit is contained in:
@ -1,42 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { useDraggable } from '@vue-dnd-kit/core';
|
||||
import { computed } from 'vue';
|
||||
|
||||
const { index, source } = defineProps<{
|
||||
index: number;
|
||||
source: any[];
|
||||
}>();
|
||||
|
||||
const { elementRef, handleDragStart, isOvered, isDragging } = useDraggable({
|
||||
data: computed(() => ({
|
||||
index,
|
||||
source,
|
||||
})),
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="elementRef" @pointerdown="handleDragStart" :class="{
|
||||
'is-over': isOvered,
|
||||
'is-dragging': isDragging,
|
||||
}" class="draggable">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.draggable {
|
||||
cursor: move;
|
||||
user-select: none;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.is-dragging {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.is-over {
|
||||
padding-top: 0.5rem;
|
||||
border-top: 2px solid var(--border);
|
||||
}
|
||||
</style>
|
||||
@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<Frame margin="none" class="px-2 py-3 flex h-fit gap-2 hover:bg-muted" :class="selected && 'bg-muted'">
|
||||
<Frame margin="none" class="px-2 py-3 flex h-fit gap-2 hover:bg-muted">
|
||||
<div class="text-[2rem] h-full">
|
||||
<Draggable />
|
||||
</div>
|
||||
<Separator orientation="vertical" />
|
||||
<div class="w-fit flex-1 flex flex-col justify-between">
|
||||
<div class="w-fit flex-1 flex flex-col justify-between cursor-pointer" data-no-drag @click="onPlayClick">
|
||||
<div class="w-full">
|
||||
<div class="flex items-start justify-between w-full">
|
||||
<h4 class="scroll-m-20 text-xl font-semibold tracking-tight truncate max-w-[32ch]">
|
||||
@ -26,8 +26,8 @@
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<Separator orientation="vertical" />
|
||||
<div class="max-w-20 max-h-20 w-20 h-20" v-if="imageUrl">
|
||||
<Separator orientation="vertical" class="cursor-pointer" data-no-drag @click="onPlayClick" />
|
||||
<div class="max-w-20 max-h-20 w-20 h-20 cursor-pointer" data-no-drag v-if="imageUrl" @click="onPlayClick">
|
||||
<NuxtImg class="object-cover w-full h-full rounded-md" :src="imageUrl" :alt="title" />
|
||||
</div>
|
||||
</Frame>
|
||||
@ -42,14 +42,22 @@ import Frame from '@/components/ui/frame/Frame.vue'
|
||||
interface Props {
|
||||
title: string
|
||||
author: string
|
||||
selected?: boolean
|
||||
badges?: string[]
|
||||
imageUrl?: string
|
||||
date?: string
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
onPlay: []
|
||||
}>();
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
authorLabel: 'Author',
|
||||
badges: () => []
|
||||
})
|
||||
|
||||
function onPlayClick(e: MouseEvent) {
|
||||
emit("onPlay")
|
||||
e.stopPropagation();
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user