Skip to content

Commit fb2e6ae

Browse files
committed
UX: handle case lots of files at once. Before you were unable to press
the download on mobile
1 parent bb92fea commit fb2e6ae

2 files changed

Lines changed: 40 additions & 23 deletions

File tree

frontend/src/components/FileReceiver.svelte

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import {formatFileSize} from "../util/filesize.ts";
33
import {
4-
CircleXIcon, DownloadIcon,
4+
ChevronDownIcon, ChevronUpIcon, CircleXIcon, DownloadIcon,
55
FileAudioIcon,
66
FileIcon,
77
FileVideoIcon, FrownIcon, HeartIcon,
@@ -20,6 +20,8 @@
2020
import {truncateFileName} from "../util/truncate.ts";
2121
2222
let manager: WebsocketManager;
23+
let showAllFiles = $state(false);
24+
const previewFileLimit = 8;
2325
2426
interface Props {
2527
RoomId: undefined | string;
@@ -47,8 +49,8 @@
4749
4850
</script>
4951

50-
<div class="card h-full min-h-svh sm:min-h-0 bg-base-100 w-screen sm:w-full sm:h-auto max-w-lg gap-3 space-y-6">
51-
<div class="card-body flex-col justify-between h-full md:h-auto gap-16">
52+
<div class="card relative h-[100dvh] bg-base-100 w-screen sm:w-full sm:max-h-[calc(100dvh-2rem)] max-w-lg {$currentFileOffer?.files.length > previewFileLimit ? 'sm:h-[min(100dvh-2rem,40rem)]' : 'sm:h-auto'}">
53+
<div class="card-body flex h-full min-h-0 flex-col gap-6">
5254
<div class="flex items-center space-x-4">
5355
<div class="bg-gray-100 p-2 rounded-full">
5456
<ShareIcon class="h-6 w-6"/>
@@ -57,31 +59,32 @@
5759
<p class="text-2xl sm:text-3xl font-bold modal-title">File transfer</p>
5860
</div>
5961
</div>
60-
{#if $downloadFinished}
61-
<div>
62+
<div class="min-h-0 flex-1 overflow-y-auto pb-28 pr-1">
63+
{#if $downloadFinished}
64+
<div>
6265
<p class="text-xl">Download finished!</p>
6366
<p class="text-gray-500">Please consider donating! It helps the platform running ❤️</p>
6467

6568
</div>
66-
{:else if $downloadCancelled}
67-
<div>
69+
{:else if $downloadCancelled}
70+
<div>
6871
<CircleXIcon class="w-32 h-32 mx-auto"/>
6972
<p class="text-xl">Download cancelled</p>
7073
<p class="text-gray-500">The download has been cancelled by the sender. <a class="link link-primary"
7174
href="/">Return to
7275
homepage</a></p>
7376
</div>
74-
{:else if $isConnected === false || $checkedRoomCode === false}
75-
<div>
77+
{:else if $isConnected === false || $checkedRoomCode === false}
78+
<div>
7679
<div class="flex flex-row gap-3">
7780
<Loader2Icon class="animate-spin"/>
7881
<p class="text-base-content/70 text-lg">Setting up the connection</p>
7982
</div>
8083
</div>
81-
{:else if $currentFileOffer}
82-
<div>
83-
<ul class="space-y-2">
84-
{#each $currentFileOffer.files as file}
84+
{:else if $currentFileOffer}
85+
<div>
86+
<ul id="offered-files" class="space-y-2">
87+
{#each $currentFileOffer.files.slice(0, showAllFiles ? undefined : previewFileLimit) as file}
8588
<li class="flex flex-col py-2">
8689
<div class="flex items-center justify-between">
8790
<div class="flex items-center space-x-3">
@@ -104,26 +107,41 @@
104107
</li>
105108
{/each}
106109
</ul>
107-
<div class="mt-4">
108-
<span class="text-gray-500">Total size: {formatFileSize($currentFileOffer.files.reduce((acc, file) => acc + file.size, 0))}</span>
109-
</div>
110110
</div>
111-
{:else if ($roomExists === false && $checkedRoomCode && $isConnected) || $room?.user_count === 1}
112-
<div>
111+
{:else if ($roomExists === false && $checkedRoomCode && $isConnected) || $room?.user_count === 1}
112+
<div>
113113
<FrownIcon class="w-32 h-32 mx-auto"/>
114114
<p class="text-xl">Invalid link</p>
115115
<p class="text-gray-500">The link you received is incorrect. Please try again. <a
116116
class="link link-primary" href="/">Return to homepage</a></p>
117117
</div>
118-
{:else}
119-
<div>
118+
{:else}
119+
<div>
120120
<div class="flex flex-row gap-3">
121121
<Loader2Icon class="animate-spin"/>
122122
<p class="text-base-content/70 text-lg">Waiting for file(s)...</p>
123123
</div>
124124
</div>
125+
{/if}
126+
</div>
127+
{#if $currentFileOffer && $currentFileOffer.files.length > previewFileLimit}
128+
<button class="btn btn-neutral btn-sm absolute bottom-40 left-1/2 z-10 -translate-x-1/2 shadow-lg" aria-controls="offered-files" aria-expanded={showAllFiles} onclick={() => showAllFiles = !showAllFiles}>
129+
{#if showAllFiles}
130+
<ChevronUpIcon class="h-4 w-4"/>
131+
Show less
132+
{:else}
133+
<ChevronDownIcon class="h-4 w-4"/>
134+
Show {$currentFileOffer.files.length - previewFileLimit} more file{$currentFileOffer.files.length - previewFileLimit === 1 ? "" : "s"}
135+
{/if}
136+
</button>
137+
{/if}
138+
{#if $currentFileOffer}
139+
<div class="flex shrink-0 items-center justify-between rounded-box bg-base-200 px-4 py-3 text-sm text-base-content/70">
140+
<span>Total files: {$currentFileOffer.files.length}</span>
141+
<span>Total size: {formatFileSize($currentFileOffer.files.reduce((total, file) => total + file.size, 0))}</span>
142+
</div>
125143
{/if}
126-
<div class="flex flex-col gap-3">
144+
<div class="flex shrink-0 flex-col gap-3">
127145
{#if $downloadFinished}
128146
<a href="/donate" class="btn btn-primary w-full">
129147
<HeartIcon class="h-5 w-5"/>

frontend/src/pages/index.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
import "../styles/globals.css"
32
import Layout from '../layouts/Layout.astro';
43
import {
54
Users,
@@ -23,7 +22,7 @@ const tweet = "I just used sendfa.st to send files between my devices. It's fast
2322
---
2423
<Layout title="SendFast • quick and easy file transfers">
2524
<Navbar/>
26-
<section class="md:min-h-[100vh] bg-base-100 relative overflow-hidden">
25+
<section class="md:min-h-screen bg-base-100 relative overflow-hidden">
2726
<GradientBackdrop/>
2827
<div class="relative z-10 max-w-6xl mx-auto flex flex-col items-center justify-center gap-16 lg:gap-20 px-8 py-12 lg:py-32">
2928
<div class="relative z-10 mx-auto flex flex-col items-center justify-center gap-16 lg:gap-20 px-8 py-12 lg:py-32">

0 commit comments

Comments
 (0)