diff --git a/package.json b/package.json index ee5e2f39..dacec74c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@dicebear/initials": "^6.0.4", "lemmy-js-client": "^0.18.0-rc.2", "markdown-it": "^13.0.1", - "mono-svelte": "^0.2.2" + "mono-svelte": "^0.2.8" }, "type": "module" } diff --git a/src/lib/PwaReload.svelte b/src/lib/PwaReload.svelte index 4a35ce98..ce16eb61 100644 --- a/src/lib/PwaReload.svelte +++ b/src/lib/PwaReload.svelte @@ -1,5 +1,5 @@ - -
- {#if toast.loading} -
- -
- {:else} - - {/if} -
- {#if toast.title} -

{toast.title}

- {/if} -

{toast.content}

-
-
- {#if toast.action} - - {/if} - -
-
diff --git a/src/lib/components/ui/toasts/ToastContainer.svelte b/src/lib/components/ui/toasts/ToastContainer.svelte deleted file mode 100644 index 4a0017e0..00000000 --- a/src/lib/components/ui/toasts/ToastContainer.svelte +++ /dev/null @@ -1,21 +0,0 @@ - - -
- {#each $toasts as toast, index (toast.id)} -
- -
- {/each} -
diff --git a/src/lib/components/ui/toasts/toasts.ts b/src/lib/components/ui/toasts/toasts.ts deleted file mode 100644 index e3c01e33..00000000 --- a/src/lib/components/ui/toasts/toasts.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { writable } from 'svelte/store' - -type ToastType = keyof typeof toastColors - -export const toastColors = { - error: 'bg-red-600 text-white border border-red-700', - warning: 'bg-yellow-400 text-black border border-yellow-500', - success: 'bg-green-400 text-black border border-green-500', - info: 'dark:bg-zinc-900 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg', -} - -export interface Toast { - id: number - title?: string - content: string - type: ToastType - loading?: boolean - action?: () => any -} - -export const toasts = writable([]) - -export function toast({ - title, - content, - type = 'info', - duration = 5000, - loading = false, - action, -}: { - title?: string - content: string - type?: ToastType - duration?: number - loading?: boolean - action?: () => any -}) { - let id = 0 - - toasts.update((toasts) => { - id = Math.floor(Math.random() * 10000) - - return [ - ...toasts, - { - id: id, - content: content, - title: title, - type: type, - loading: loading, - action: action, - }, - ] - }) - - setTimeout(() => { - toasts.update((toasts) => toasts.filter((toast) => toast.id != id)) - }, duration) - - return id -} - -export const removeToast = (id: number) => - toasts.update((toasts) => toasts.filter((toast) => toast.id != id)) diff --git a/src/lib/util.ts b/src/lib/util.ts index 7ebed6ca..e663528f 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -1,5 +1,5 @@ import { goto } from '$app/navigation' -import { toast } from '$lib/components/ui/toasts/toasts.js' +import { toast } from 'mono-svelte' import { userSettings } from '$lib/settings.js' import { get } from 'svelte/store' diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 291db05b..18da9799 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -4,15 +4,13 @@ import { navigating } from '$app/stores' import nProgress from 'nprogress' import 'nprogress/nprogress.css' - import ToastContainer from '$lib/components/ui/toasts/ToastContainer.svelte' import Moderation from '$lib/components/lemmy/moderation/Moderation.svelte' import Sidebar from '$lib/components/ui/sidebar/Sidebar.svelte' - import { onMount } from 'svelte' // @ts-ignore import { pwaInfo } from 'virtual:pwa-info' - import PwaReload from '$lib/PwaReload.svelte' import { inDarkTheme } from '$lib/ui/colors.js' import { userSettings } from '$lib/settings.js' + import { ToastContainer } from 'mono-svelte' nProgress.configure({ minimum: 0.4, diff --git a/src/routes/accounts/+page.svelte b/src/routes/accounts/+page.svelte index 9465037c..c153b32a 100644 --- a/src/routes/accounts/+page.svelte +++ b/src/routes/accounts/+page.svelte @@ -11,7 +11,7 @@ import EditableList from '$lib/components/ui/list/EditableList.svelte' import Menu from '$lib/components/ui/menu/Menu.svelte' import MenuButton from '$lib/components/ui/menu/MenuButton.svelte' - import { toast } from '$lib/components/ui/toasts/toasts.js' + import { toast } from 'mono-svelte' import DebugObject from '$lib/components/util/debug/DebugObject.svelte' import { DEFAULT_INSTANCE_URL, @@ -173,7 +173,12 @@
- moveProfile(profile.id, true)}> @@ -246,12 +251,15 @@ label="Guest instance" bind:value={newInstance} disabled={LINKED_INSTANCE_URL != undefined} - /> + size="sm" + > + https:// + diff --git a/src/routes/admin/applications/Application.svelte b/src/routes/admin/applications/Application.svelte index 35d18948..9d0c1f5b 100644 --- a/src/routes/admin/applications/Application.svelte +++ b/src/routes/admin/applications/Application.svelte @@ -4,7 +4,7 @@ import Card from '$lib/components/ui/Card.svelte' import SectionTitle from '$lib/components/ui/SectionTitle.svelte' - import { toast } from '$lib/components/ui/toasts/toasts.js' + import { toast } from 'mono-svelte' import { getClient } from '$lib/lemmy.js' import type { RegistrationApplicationView } from 'lemmy-js-client' import { Button } from 'mono-svelte' diff --git a/src/routes/admin/config/+page.svelte b/src/routes/admin/config/+page.svelte index a491f35d..347defc7 100644 --- a/src/routes/admin/config/+page.svelte +++ b/src/routes/admin/config/+page.svelte @@ -1,7 +1,7 @@ @@ -50,7 +52,7 @@ Type - + @@ -70,6 +72,16 @@
+
+ + searchParam($page.url, 'community', c.detail?.id || undefined, 'page')} + /> +
{#if !data.results} import { goto } from '$app/navigation' - import { toast } from '$lib/components/ui/toasts/toasts.js' + import { toast } from 'mono-svelte' import { DEFAULT_INSTANCE_URL } from '$lib/instance.js' import { validateInstance } from '$lib/lemmy.js' import { Button, TextInput } from 'mono-svelte' diff --git a/src/routes/signup/[instance]/+page.svelte b/src/routes/signup/[instance]/+page.svelte index f5533123..7cfcace1 100644 --- a/src/routes/signup/[instance]/+page.svelte +++ b/src/routes/signup/[instance]/+page.svelte @@ -8,7 +8,7 @@ import Card from '$lib/components/ui/Card.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte' import Spinner from '$lib/components/ui/loader/Spinner.svelte' - import { toast } from '$lib/components/ui/toasts/toasts.js' + import { toast } from 'mono-svelte' import { getClient } from '$lib/lemmy.js' import type { GetCaptchaResponse } from 'lemmy-js-client' import { Button, TextArea, TextInput } from 'mono-svelte' diff --git a/src/routes/u/[name]/+page.svelte b/src/routes/u/[name]/+page.svelte index 50c31774..ad62667f 100644 --- a/src/routes/u/[name]/+page.svelte +++ b/src/routes/u/[name]/+page.svelte @@ -24,7 +24,7 @@ import { isCommentView } from '$lib/lemmy/item.js' import { getClient } from '$lib/lemmy.js' import { isBlocked } from '$lib/lemmy/user.js' - import { toast } from '$lib/components/ui/toasts/toasts.js' + import { toast } from 'mono-svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import { profile } from '$lib/auth.js' import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation.js' diff --git a/yarn.lock b/yarn.lock index 36436eda..56c73452 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2977,10 +2977,10 @@ mlly@^1.2.0, mlly@^1.4.0: pkg-types "^1.0.3" ufo "^1.1.2" -mono-svelte@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.2.2.tgz#a7414fa09c7cae03539397e6b3a75b3db16e9fe2" - integrity sha512-SNUAFT4WvexJyqKz31tumsA+/uedzElewC/fvqfPEN03GvRk6Vz7IB8MIkBFQ2Zs2tJ1kkVicW+TAlL2VeYO2A== +mono-svelte@^0.2.8: + version "0.2.8" + resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.2.8.tgz#30f6e83089a1f2517dfede8bba2cf36a6f26161c" + integrity sha512-M9KveQgHjBIp0xBPYJTPiDlNAFPIOeEQcq0H7ZokKfiyeDS+ZYCvNyyWC15ziJYWOtErKQd2e0cG7OVdE1ppPA== mri@^1.1.0: version "1.2.0"