mirror of https://github.com/VERT-sh/VERT.git
feat: mobile detection, fix: slightly increase padding
This commit is contained in:
parent
9d7af8df70
commit
a8c90e90f1
|
|
@ -9,6 +9,7 @@
|
||||||
interface Props {
|
interface Props {
|
||||||
files: File[] | undefined;
|
files: File[] | undefined;
|
||||||
onupload?: () => void;
|
onupload?: () => void;
|
||||||
|
isMobile: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
|
|
@ -19,7 +20,7 @@
|
||||||
let fileInput = $state<HTMLInputElement>();
|
let fileInput = $state<HTMLInputElement>();
|
||||||
let dragOver = $state(false);
|
let dragOver = $state(false);
|
||||||
|
|
||||||
let { files = $bindable(), onupload }: Props = $props();
|
let { files = $bindable(), onupload, isMobile }: Props = $props();
|
||||||
|
|
||||||
function upload() {
|
function upload() {
|
||||||
if (!fileInput) return;
|
if (!fileInput) return;
|
||||||
|
|
@ -94,7 +95,7 @@
|
||||||
<Upload class="size-8" />
|
<Upload class="size-8" />
|
||||||
</div>
|
</div>
|
||||||
<h2 class="font-display text-2xl mt-6">
|
<h2 class="font-display text-2xl mt-6">
|
||||||
Drop or click to upload files
|
{isMobile ? "Tap" : "Drop or click"} to upload files
|
||||||
</h2>
|
</h2>
|
||||||
<p class="text-foreground-muted mt-4">
|
<p class="text-foreground-muted mt-4">
|
||||||
All processing is done on your device. No file or size limit.
|
All processing is done on your device. No file or size limit.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
export const load = ({ url, request }) => {
|
||||||
|
const { pathname } = url;
|
||||||
|
const ua = request.headers.get("user-agent");
|
||||||
|
const isMobile = /mobile/i.test(ua || "");
|
||||||
|
return {
|
||||||
|
pathname,
|
||||||
|
isMobile,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
<div
|
<div
|
||||||
role="main"
|
role="main"
|
||||||
class="w-full h-full flex items-center p-2 flex-col gap-16"
|
class="w-full h-full flex items-center p-4 flex-col gap-16"
|
||||||
ondragenter={maybeNavToHome}
|
ondragenter={maybeNavToHome}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
export const load = ({ url }) => {
|
|
||||||
const { pathname } = url;
|
|
||||||
return {
|
|
||||||
pathname,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
import { files } from "$lib/store/index.svelte";
|
import { files } from "$lib/store/index.svelte";
|
||||||
import { Check } from "lucide-svelte";
|
import { Check } from "lucide-svelte";
|
||||||
|
|
||||||
|
const { data } = $props();
|
||||||
|
|
||||||
let ourFiles = $state<File[]>();
|
let ourFiles = $state<File[]>();
|
||||||
|
|
||||||
const runUpload = () => {
|
const runUpload = () => {
|
||||||
|
|
@ -25,34 +27,6 @@
|
||||||
if (files.files.length > 0 && !files.beenToConverterPage)
|
if (files.files.length > 0 && !files.beenToConverterPage)
|
||||||
goto("/convert");
|
goto("/convert");
|
||||||
};
|
};
|
||||||
|
|
||||||
// const convertAllFiles = async () => {
|
|
||||||
// const promises = files.files?.map(async (file, i) => {
|
|
||||||
// let conversionType = files.conversionTypes[i];
|
|
||||||
// const converter = converters[0];
|
|
||||||
// const convertedFile = await converter.convert(
|
|
||||||
// {
|
|
||||||
// name: file.name,
|
|
||||||
// buffer: await file.arrayBuffer(),
|
|
||||||
// },
|
|
||||||
// conversionType,
|
|
||||||
// );
|
|
||||||
// files.downloadFns[i] = () => {
|
|
||||||
// const url = URL.createObjectURL(
|
|
||||||
// new Blob([convertedFile.buffer]),
|
|
||||||
// );
|
|
||||||
// const a = document.createElement("a");
|
|
||||||
// a.href = url;
|
|
||||||
// if (conversionType.startsWith("."))
|
|
||||||
// conversionType = conversionType.slice(1);
|
|
||||||
// a.download = `${file.name}.${conversionType}`;
|
|
||||||
// a.target = "_self";
|
|
||||||
// a.click();
|
|
||||||
// URL.revokeObjectURL(url);
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
// if (promises) await Promise.all(promises);
|
|
||||||
// };
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
@ -100,7 +74,11 @@
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
<div class="[@media(max-height:768px)]:block mt-10 picker-fly">
|
<div class="[@media(max-height:768px)]:block mt-10 picker-fly">
|
||||||
<Uploader bind:files={ourFiles} onupload={runUpload} />
|
<Uploader
|
||||||
|
isMobile={data.isMobile}
|
||||||
|
bind:files={ourFiles}
|
||||||
|
onupload={runUpload}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-20">
|
<div class="mt-20">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue