Add gallery button

This commit is contained in:
Joscha 2025-03-26 23:52:26 +01:00
parent 15f6a517e7
commit 5ce7625f6b
2 changed files with 47 additions and 21 deletions

View file

@ -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>