2025-02-06 17:29:30 +00:00
|
|
|
<script lang="ts">
|
2025-02-06 18:14:29 +00:00
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
2025-02-06 17:29:30 +00:00
|
|
|
import {preventDefault} from "@lib/html"
|
2025-09-10 22:26:39 +00:00
|
|
|
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
|
|
|
|
import AltArrowRight from "@assets/icons/alt-arrow-right.svg?dataurl"
|
2026-09-18 18:22:51 +00:00
|
|
|
import Copy from "@assets/icons/copy.svg?dataurl"
|
|
|
|
|
import LinkRound from "@assets/icons/link-round.svg?dataurl"
|
2025-02-06 17:29:30 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
2026-09-18 18:55:04 +00:00
|
|
|
import Divider from "@lib/components/Divider.svelte"
|
2025-02-06 17:29:30 +00:00
|
|
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
2026-02-02 18:09:14 +00:00
|
|
|
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
|
|
|
|
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
2025-02-06 17:29:30 +00:00
|
|
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
2026-01-30 22:14:12 +00:00
|
|
|
import Modal from "@lib/components/Modal.svelte"
|
|
|
|
|
import ModalBody from "@lib/components/ModalBody.svelte"
|
2026-07-02 18:36:05 +00:00
|
|
|
import RoomNameWithImage from "@app/components/RoomNameWithImage.svelte"
|
2026-09-18 18:22:51 +00:00
|
|
|
import {makeEventPermalink, makeRoomPath} from "@app/routes"
|
2026-08-11 21:54:05 +00:00
|
|
|
import {shareTo} from "@app/share"
|
2026-09-18 18:22:51 +00:00
|
|
|
import {clip} from "@app/toast"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {rooms} from "@app/core"
|
2025-02-06 17:29:30 +00:00
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
type Props = {
|
|
|
|
|
url: string
|
|
|
|
|
noun: string
|
|
|
|
|
event: TrustedEvent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {url, noun, event}: Props = $props()
|
|
|
|
|
|
|
|
|
|
const spaceRooms = $rooms.forUrl(url).$
|
2025-02-06 17:29:30 +00:00
|
|
|
|
|
|
|
|
const back = () => history.back()
|
|
|
|
|
|
|
|
|
|
const onSubmit = () => {
|
2026-09-08 17:23:22 +00:00
|
|
|
shareTo(makeRoomPath(url, selection), {type: "event", value: event})
|
2025-02-06 17:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
2025-10-30 22:33:34 +00:00
|
|
|
const toggleRoom = (h: string) => {
|
|
|
|
|
selection = h === selection ? "" : h
|
2025-02-06 17:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
2026-09-18 18:22:51 +00:00
|
|
|
const permalink = makeEventPermalink(event, url)
|
|
|
|
|
|
|
|
|
|
const copyPermalink = () => clip(permalink)
|
|
|
|
|
|
2025-02-06 17:29:30 +00:00
|
|
|
let selection = $state("")
|
|
|
|
|
</script>
|
|
|
|
|
|
2026-01-30 22:14:12 +00:00
|
|
|
<Modal tag="form" onsubmit={preventDefault(onSubmit)}>
|
|
|
|
|
<ModalBody>
|
|
|
|
|
<ModalHeader>
|
2026-02-02 18:09:14 +00:00
|
|
|
<ModalTitle>Share {noun}</ModalTitle>
|
|
|
|
|
<ModalSubtitle>Which room would you like to share this event to?</ModalSubtitle>
|
2026-01-30 22:14:12 +00:00
|
|
|
</ModalHeader>
|
2026-07-02 18:36:05 +00:00
|
|
|
<div class="grid grid-cols-2 gap-2">
|
2026-07-28 16:16:26 +00:00
|
|
|
{#each $spaceRooms as room (room.h)}
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button
|
2026-01-30 22:14:12 +00:00
|
|
|
type="button"
|
2026-07-02 18:36:05 +00:00
|
|
|
class="flex justify-center button {selection === room.h
|
|
|
|
|
? 'button-primary'
|
|
|
|
|
: 'button-neutral'}"
|
2026-01-30 22:14:12 +00:00
|
|
|
onclick={() => toggleRoom(room.h)}>
|
2026-07-28 16:16:26 +00:00
|
|
|
<RoomNameWithImage {url} h={room.h} />
|
2026-06-24 20:56:53 +00:00
|
|
|
</Button>
|
2026-01-30 22:14:12 +00:00
|
|
|
{/each}
|
|
|
|
|
</div>
|
2026-09-18 18:55:04 +00:00
|
|
|
<Divider>Or copy a link</Divider>
|
|
|
|
|
<label class="input flex min-w-0 items-center gap-2">
|
|
|
|
|
<Icon icon={LinkRound} class="shrink-0" />
|
|
|
|
|
<input value={permalink} class="min-w-0 flex-1 truncate" type="text" readonly />
|
|
|
|
|
<Button class="shrink-0" aria-label="Copy link" onclick={copyPermalink}>
|
|
|
|
|
<Icon icon={Copy} />
|
|
|
|
|
</Button>
|
|
|
|
|
</label>
|
2026-01-30 22:14:12 +00:00
|
|
|
</ModalBody>
|
2025-02-06 17:29:30 +00:00
|
|
|
<ModalFooter>
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button class="button button-link" onclick={back}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={AltArrowLeft} />
|
2025-02-06 17:29:30 +00:00
|
|
|
Go back
|
|
|
|
|
</Button>
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button type="submit" class="button button-primary" disabled={!selection}>
|
2025-02-06 18:14:29 +00:00
|
|
|
Share {noun}
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={AltArrowRight} />
|
2025-02-06 17:29:30 +00:00
|
|
|
</Button>
|
|
|
|
|
</ModalFooter>
|
2026-01-30 22:14:12 +00:00
|
|
|
</Modal>
|