feat: view raw button; paste header follows when scrolling; scroll to top button appears after scrolling far enough

chore: npm run format + lint
This commit is contained in:
2026-01-18 22:01:50 -05:00
parent ca87b1a5f2
commit 28a0ccbfab
2 changed files with 212 additions and 193 deletions
+29 -9
View File
@@ -3,6 +3,7 @@
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import type { PageData } from './$types'; import type { PageData } from './$types';
import { import {
File,
FileBox, FileBox,
Eye, Eye,
EyeClosed, EyeClosed,
@@ -19,7 +20,8 @@
Copy, Copy,
Check, Check,
CalendarCog, CalendarCog,
Flag Flag,
ArrowUp
} from '@lucide/svelte/icons/index'; } from '@lucide/svelte/icons/index';
import { import {
formatBytes, formatBytes,
@@ -52,6 +54,8 @@
let downloadedPaste = false; let downloadedPaste = false;
let copiedPaste = false; let copiedPaste = false;
let scrollY = 0;
let now = new Date(); let now = new Date();
$: isExpired = $: isExpired =
data?.paste?.expiresAt && data.paste.expiresAt !== 0 data?.paste?.expiresAt && data.paste.expiresAt !== 0
@@ -306,6 +310,8 @@
?.cf_turnstile_site_key ?? null; ?.cf_turnstile_site_key ?? null;
</script> </script>
<svelte:window bind:scrollY />
<svelte:head> <svelte:head>
<title <title
>{data.paste >{data.paste
@@ -344,9 +350,7 @@
<main <main
class="flex min-h-[calc(100vh-60px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white" class="flex min-h-[calc(100vh-60px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
> >
<div <div class=" w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-4">
class="max-h-[90vh] w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-4"
>
{#if data.paste} {#if data.paste}
<div class="mb-4 w-full text-center"> <div class="mb-4 w-full text-center">
<h1 <h1
@@ -502,10 +506,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="overflow-hidden">
<div <div
class="flex flex-col items-center justify-between gap-2 rounded-t-md border-b border-neutral-700 bg-neutral-800 px-3 py-2 md:flex-row" class="sticky top-0 z-10 flex flex-col items-center justify-between gap-2 rounded-t-md border-b border-neutral-700 bg-neutral-800 px-3 py-2 md:flex-row"
> >
<div class="flex items-center gap-2 text-sm text-neutral-300"> <div class="flex items-center gap-2 text-sm text-neutral-300">
<span class="font-medium text-neutral-100" <span class="font-medium text-neutral-100"
@@ -593,6 +595,15 @@
<span class="text-neutral-300">Download</span> <span class="text-neutral-300">Download</span>
</button> </button>
<a
href={resolve(`/raw/${data.paste.id}`)}
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
>
<File class="mr-1 h-5 w-5 text-neutral-400" />
<span class="text-neutral-300">View Raw</span>
</a>
{#if $user !== null && $user.uuid !== data.paste?.author?.uuid} {#if $user !== null && $user.uuid !== data.paste?.author?.uuid}
<button <button
type="button" type="button"
@@ -674,6 +685,17 @@
</button> </button>
{/if} {/if}
{/if} {/if}
{#if scrollY > 400 && contentRendered && !editing}
<button
transition:fade={{ duration: 200 }}
class="flex cursor-pointer items-center rounded-md bg-neutral-700 px-2 py-0.5 text-sm hover:bg-neutral-600"
on:click={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
aria-label="Scroll to top"
>
<ArrowUp class="mr-1 h-5 w-5 text-neutral-400" />
<span class="text-neutral-300">Scroll to top</span>
</button>
{/if}
</div> </div>
</div> </div>
{#if editing} {#if editing}
@@ -701,7 +723,6 @@
{@html pasteContent} {@html pasteContent}
</code> </code>
{/if} {/if}
</div>
{:else} {:else}
<h1 class="mb-4 text-center text-4xl font-bold">Paste not found</h1> <h1 class="mb-4 text-center text-4xl font-bold">Paste not found</h1>
<h2 class="mt-2 text-center text-xl">The paste you are looking for does not exist.</h2> <h2 class="mt-2 text-center text-xl">The paste you are looking for does not exist.</h2>
@@ -732,7 +753,6 @@
box-sizing: border-box; box-sizing: border-box;
min-width: 0; min-width: 0;
width: 100%; width: 100%;
max-height: 40vh;
} }
.code-row { .code-row {
display: flex; display: flex;
@@ -27,7 +27,6 @@
export let data: PageData; export let data: PageData;
let currentPage = data.pastes?.pagination?.page ?? 1; let currentPage = data.pastes?.pagination?.page ?? 1;
let pagination: Pagination = data.pastes?.pagination ?? { let pagination: Pagination = data.pastes?.pagination ?? {
page: 1, page: 1,