|
1 | 1 | <script lang="ts"> |
| 2 | + import { goto } from '$app/navigation'; |
| 3 | + import { saveFile } from './utils/save-file'; |
| 4 | + import Dropzone from './components/dropzone.svelte'; |
2 | 5 | import RecordingList from './components/recording-list.svelte'; |
3 | 6 | import FloatingRecordingBar from './components/floating-recording-bar.svelte'; |
| 7 | +
|
| 8 | + let isDroppingNewRecording = false; |
| 9 | +
|
| 10 | + async function handleDrop({ detail: { files } }: CustomEvent<{ files: FileList | undefined }>) { |
| 11 | + const file = files?.[0]; |
| 12 | +
|
| 13 | + if (!file) return; |
| 14 | + if (!file.type.includes('video')) return; |
| 15 | +
|
| 16 | + const filename = file.name; |
| 17 | + const folderName = file.name.split('.').slice(0, -1).join('.'); |
| 18 | +
|
| 19 | + await saveFile(file, `${folderName}/${filename}`); |
| 20 | + await goto(folderName); |
| 21 | + } |
4 | 22 | </script> |
5 | 23 |
|
6 | | -<main |
7 | | - class="w-full h-full p-8 pb-44 grid grid-cols-[repeat(auto-fill,minmax(360px,1fr))] auto-rows-min gap-8 md:p-16 md:pb-44 lg:px-32 lg:gap-y-16" |
8 | | -> |
9 | | - <RecordingList /> |
10 | | - <FloatingRecordingBar /> |
| 24 | +<main> |
| 25 | + <Dropzone |
| 26 | + class="w-full min-h-dvh p-8 pb-44 grid grid-cols-[repeat(auto-fill,minmax(360px,1fr))] auto-rows-min gap-8 cursor-auto outline-none md:p-16 md:pb-44 lg:px-32 lg:gap-y-16 {isDroppingNewRecording |
| 27 | + ? '*:pointer-events-none' |
| 28 | + : ''}" |
| 29 | + openPickerOnClick={false} |
| 30 | + on:dragenter={() => (isDroppingNewRecording = true)} |
| 31 | + on:dragover={() => (isDroppingNewRecording = true)} |
| 32 | + on:dragleave={() => (isDroppingNewRecording = false)} |
| 33 | + on:drop={(e) => { |
| 34 | + isDroppingNewRecording = false; |
| 35 | + handleDrop(e); |
| 36 | + }} |
| 37 | + > |
| 38 | + <article |
| 39 | + class="w-full h-full bg-white/10 flex justify-center items-center flex-col gap-2 fixed inset-0 z-10 backdrop-blur {isDroppingNewRecording |
| 40 | + ? 'block' |
| 41 | + : 'hidden'}" |
| 42 | + > |
| 43 | + <h2 class="text-2xl font-bold">Drop it!</h2> |
| 44 | + <p>Drop here any video to upload it and star editing!</p> |
| 45 | + </article> |
| 46 | + <RecordingList /> |
| 47 | + <FloatingRecordingBar /> |
| 48 | + </Dropzone> |
11 | 49 | </main> |
0 commit comments