Add gallery button
This commit is contained in:
parent
15f6a517e7
commit
5ce7625f6b
2 changed files with 47 additions and 21 deletions
|
|
@ -1,10 +1,25 @@
|
|||
<script setup lang="ts">
|
||||
import { RiMultiImageFill } from "@remixicon/vue";
|
||||
import { useTemplateRef } from "vue";
|
||||
|
||||
const emit = defineEmits<{
|
||||
click: [file: File];
|
||||
}>();
|
||||
|
||||
const image = useTemplateRef<HTMLInputElement>("image");
|
||||
|
||||
function onImageChange() {
|
||||
const theFile = image.value?.files?.[0];
|
||||
if (theFile === undefined) return;
|
||||
if (!theFile.type.startsWith("image/")) return;
|
||||
emit("click", theFile);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<label>
|
||||
<RiMultiImageFill size="48px" />
|
||||
<input ref="image" type="file" accept="image/*" @change="onImageChange" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
|
|
@ -27,4 +42,8 @@ label:active {
|
|||
svg {
|
||||
display: block;
|
||||
}
|
||||
|
||||
input {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue