enh: toast

This commit is contained in:
Timothy Jaeryang Baek 2025-01-17 22:34:54 -08:00
parent ab0736728a
commit c36ab799ef
5 changed files with 38 additions and 6 deletions

11
package-lock.json generated
View File

@ -39,6 +39,7 @@
"prettier-plugin-svelte": "^3.3.2",
"svelte": "^5.17.1",
"svelte-check": "^4.1.3",
"svelte-sonner": "^0.3.28",
"tailwindcss": "^4.0.0-beta.8",
"tippy.js": "^6.3.7",
"ts-node": "^10.9.2",
@ -10843,6 +10844,16 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/svelte-sonner": {
"version": "0.3.28",
"resolved": "https://registry.npmjs.org/svelte-sonner/-/svelte-sonner-0.3.28.tgz",
"integrity": "sha512-K3AmlySeFifF/cKgsYNv5uXqMVNln0NBAacOYgmkQStLa/UoU0LhfAACU6Gr+YYC8bOCHdVmFNoKuDbMEsppJg==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"svelte": "^3.0.0 || ^4.0.0 || ^5.0.0-next.1"
}
},
"node_modules/tailwindcss": {
"version": "4.0.0-beta.8",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.0.0-beta.8.tgz",

View File

@ -39,6 +39,7 @@
"prettier-plugin-svelte": "^3.3.2",
"svelte": "^5.17.1",
"svelte-check": "^4.1.3",
"svelte-sonner": "^0.3.28",
"tailwindcss": "^4.0.0-beta.8",
"tippy.js": "^6.3.7",
"ts-node": "^10.9.2",

View File

@ -1,4 +1,6 @@
<script lang="ts">
import { Toaster, toast } from 'svelte-sonner';
import { onMount } from 'svelte';
import { installStatus, serverStatus, serverStartedAt, serverLogs } from './lib/stores';
@ -61,3 +63,9 @@
<main class="w-screen h-screen bg-gray-900">
<Main />
</main>
<Toaster
theme={window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'}
richColors
position="top-center"
/>

View File

@ -89,7 +89,7 @@
<div class="flex-1 w-full flex justify-center relative">
{#if $installStatus === false}
<div class="m-auto flex flex-col justify-center text-center">
<div class="m-auto flex flex-col justify-center text-center max-w-2xl w-full">
{#if mounted}
<div
class=" font-medium text-5xl xl:text-7xl text-center mb-4 xl:mb-5 font-secondary"
@ -168,7 +168,7 @@
</div>
{:else if $installStatus === true}
<div class="flex-1 w-full flex justify-center relative">
<div class="m-auto">
<div class="m-auto max-w-2xl w-full">
<div class="flex flex-col gap-3 text-center">
<Spinner className="size-5" />

View File

@ -1,16 +1,26 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import Tooltip from '../common/Tooltip.svelte';
import { copyToClipboard } from '../../utils';
export let show;
export let logs = [];
</script>
{#if show}
<div class="relative max-w-full px-3">
<div class="relative max-w-full w-full px-3">
{#if logs.length > 0}
<div class="absolute top-0 right-0 p-1 bg-transparent text-xs font-mono">
<Tooltip content="Copy">
<button class="text-xs cursor-pointer" on:click={() => (logs = [])}>
<button
class="text-xs cursor-pointer"
type="button"
on:click={async () => {
await copyToClipboard(logs.join('\n'));
toast.success('Logs copied to clipboard');
}}
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
@ -31,10 +41,12 @@
{/if}
<div
class="text-xs font-mono text-left max-h-40 overflow-y-auto max-w-2xl w-full flex flex-col-reverse scrollbar-hidden no-drag-region"
class="text-xs font-mono text-left max-h-40 overflow-auto max-w-full w-full flex flex-col-reverse scrollbar-hidden no-drag-region"
>
{#each logs.reverse() as log, idx}
<div class="text-xs font-mono">{log}</div>
<div class="text-xs font-mono whitespace-pre-wrap text-wrap max-w-full w-full">
{log}
</div>
{/each}
</div>
</div>