mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 08:10:28 +00:00
implement generic drop zone
This commit is contained in:
parent
257457a2d8
commit
781ed9d1ba
1 changed files with 31 additions and 0 deletions
31
frontend/components/global/DropZone.vue
Normal file
31
frontend/components/global/DropZone.vue
Normal file
|
@ -0,0 +1,31 @@
|
|||
<template>
|
||||
<div
|
||||
ref="el"
|
||||
class="h-24 w-full border-2 border-primary border-dashed grid place-content-center"
|
||||
:class="isOverDropZone ? 'bg-primary bg-opacity-10' : ''"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineProps({
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "drop"]);
|
||||
|
||||
const el = ref<HTMLDivElement>(null);
|
||||
const { isOverDropZone } = useDropZone(el, files => {
|
||||
emit("drop", files);
|
||||
});
|
||||
|
||||
watch(isOverDropZone, () => {
|
||||
emit("update:modelValue", isOverDropZone.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
Loading…
Add table
Add a link
Reference in a new issue