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 type { PageData } from './$types';
import {
File,
FileBox,
Eye,
EyeClosed,
@@ -19,7 +20,8 @@
Copy,
Check,
CalendarCog,
Flag
Flag,
ArrowUp
} from '@lucide/svelte/icons/index';
import {
formatBytes,
@@ -52,6 +54,8 @@
let downloadedPaste = false;
let copiedPaste = false;
let scrollY = 0;
let now = new Date();
$: isExpired =
data?.paste?.expiresAt && data.paste.expiresAt !== 0
@@ -306,6 +310,8 @@
?.cf_turnstile_site_key ?? null;
</script>
<svelte:window bind:scrollY />
<svelte:head>
<title
>{data.paste
@@ -344,9 +350,7 @@
<main
class="flex min-h-[calc(100vh-60px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
>
<div
class="max-h-[90vh] w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-4"
>
<div class=" w-[95%] max-w-7xl rounded border-2 border-neutral-800 bg-neutral-900 p-4">
{#if data.paste}
<div class="mb-4 w-full text-center">
<h1
@@ -502,10 +506,8 @@
</div>
</div>
</div>
<div class="overflow-hidden">
<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">
<span class="font-medium text-neutral-100"
@@ -593,6 +595,15 @@
<span class="text-neutral-300">Download</span>
</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}
<button
type="button"
@@ -674,6 +685,17 @@
</button>
{/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>
{#if editing}
@@ -701,7 +723,6 @@
{@html pasteContent}
</code>
{/if}
</div>
{:else}
<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>
@@ -732,7 +753,6 @@
box-sizing: border-box;
min-width: 0;
width: 100%;
max-height: 40vh;
}
.code-row {
display: flex;
@@ -27,7 +27,6 @@
export let data: PageData;
let currentPage = data.pastes?.pagination?.page ?? 1;
let pagination: Pagination = data.pastes?.pagination ?? {
page: 1,