-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make confirm dialog & toast messages
added components from melt-ui, with `stores/once.ts` to get confirmation value removed "delete post cache" button, because it serves little purpose (it was intended to remove cached post metadata, which can be worked on later.)
- Loading branch information
1 parent
fd8356d
commit 46187ed
Showing
7 changed files
with
144 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!-- https://www.melt-ui.com/docs/builders/toast --> | ||
<script lang="ts" context="module"> | ||
export type ToastData = { | ||
title: string; | ||
description?: string; | ||
}; | ||
const { | ||
elements: { content, title, description, close }, | ||
helpers, | ||
states: { toasts }, | ||
actions: { portal } | ||
} = createToaster<ToastData>(); | ||
export const addToast = helpers.addToast; | ||
</script> | ||
|
||
<script lang="ts"> | ||
import { createToaster, melt } from "@melt-ui/svelte"; | ||
import { fly } from "svelte/transition"; | ||
</script> | ||
|
||
<div | ||
class="fixed bottom-0 left-1/2 z-top flex -translate-x-1/2 flex-col items-end gap-4" | ||
use:portal | ||
> | ||
{#each $toasts as { id, data } (id)} | ||
<div | ||
use:melt={$content(id)} | ||
in:fly={{ duration: 150, y: "100%" }} | ||
out:fly={{ duration: 150, y: "100%" }} | ||
class="m-4 rounded bg-accent/80 px-4 py-2 text-background shadow-glow shadow-accent/60" | ||
> | ||
<h2 use:melt={$title(id)}> | ||
{data.title} | ||
</h2> | ||
{#if data.description} | ||
<div use:melt={$description(id)}> | ||
{data.description} | ||
</div> | ||
{/if} | ||
</div> | ||
{/each} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { writable } from "svelte/store"; | ||
|
||
export function once<T>(value?: T) { | ||
const { set, update, subscribe } = writable<T>(value); | ||
|
||
return { | ||
set, | ||
update, | ||
subscribe, | ||
once: () => | ||
new Promise<T>((resolve) => { | ||
let initCall = true; | ||
const unsub = subscribe((value) => { | ||
if (initCall) { | ||
initCall = false; | ||
return; | ||
} | ||
|
||
unsub(); | ||
resolve(value); | ||
}); | ||
}) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters