2025-08-19 21:03:04 +00:00
|
|
|
<script lang="ts">
|
2026-09-21 20:25:01 +00:00
|
|
|
import cx from "classnames"
|
2025-08-19 21:03:04 +00:00
|
|
|
import {stopPropagation} from "svelte/legacy"
|
2026-09-28 18:45:09 +00:00
|
|
|
import type {Publishable} from "@welshman/app"
|
2025-08-19 21:03:04 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
type Props = {
|
2026-09-28 18:45:09 +00:00
|
|
|
publication: Publishable
|
2026-09-24 18:23:21 +00:00
|
|
|
// A standalone usage fills its own row, and forcing that inside a flex row costs that row a line.
|
2026-09-21 20:25:01 +00:00
|
|
|
inline?: boolean
|
2025-08-19 21:03:04 +00:00
|
|
|
class?: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-28 18:45:09 +00:00
|
|
|
const {publication, inline = false, ...restProps}: Props = $props()
|
2025-08-19 21:03:04 +00:00
|
|
|
|
2026-09-28 18:45:09 +00:00
|
|
|
const abort = () => publication.abort()
|
2025-08-19 21:03:04 +00:00
|
|
|
|
2026-09-28 18:45:09 +00:00
|
|
|
const canAbort = $derived($publication.canAbort())
|
2025-08-19 21:03:04 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-09-21 20:25:01 +00:00
|
|
|
<div class={cx("flex px-1 text-xs", {"w-full justify-end": !inline}, restProps.class)}>
|
2025-08-19 21:03:04 +00:00
|
|
|
<span class="flex items-center gap-1">
|
2026-08-31 17:03:01 +00:00
|
|
|
<span class="spinner spinner-xs mx-1 translate-y-px"></span>
|
2025-08-19 21:03:04 +00:00
|
|
|
<span class="opacity-50">Sending...</span>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
2026-09-26 08:12:13 +00:00
|
|
|
class={cx("underline transition-all", {
|
2026-09-28 18:45:09 +00:00
|
|
|
link: canAbort,
|
|
|
|
|
"pointer-events-none opacity-25": !canAbort,
|
2026-09-26 08:12:13 +00:00
|
|
|
})}
|
2025-08-19 21:03:04 +00:00
|
|
|
onclick={stopPropagation(abort)}>
|
|
|
|
|
Cancel
|
|
|
|
|
</button>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|