2025-02-06 17:29:30 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {goto} from "$app/navigation"
|
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"
|
2025-10-06 18:23:19 +00:00
|
|
|
import {setKey} from "@lib/implicit"
|
2025-02-06 17:29:30 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
|
|
|
|
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-06-08 21:14:40 +00:00
|
|
|
import {makeRoomPath} from "@app/routes"
|
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 = () => {
|
2025-02-06 19:33:01 +00:00
|
|
|
setKey("share", event)
|
2025-02-06 17:29:30 +00:00
|
|
|
goto(makeRoomPath(url, selection), {replaceState: true})
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-30 22:33:34 +00:00
|
|
|
const toggleRoom = (h: string) => {
|
|
|
|
|
selection = h === selection ? "" : h
|
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>
|
|
|
|
|
</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>
|