metis/src/EventModal.svelte

54 lines
1.5 KiB
Svelte
Raw Normal View History

2022-03-06 00:59:36 +01:00
<script>
2022-03-06 13:47:05 +01:00
import { Modal, ModalHeader, ModalBody, ModalFooter, Icon, Badge } from 'sveltestrap';
import { Remarkable } from 'remarkable';
const md = new Remarkable({ breaks: true });
2022-03-06 00:59:36 +01:00
export let event = undefined;
export let open = undefined;
export let toggle = undefined;
2022-03-06 01:44:33 +01:00
const timeFormat = d =>
d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
const dateFormat = d =>
d.toLocaleDateString('fr-FR', { month: '2-digit', day: '2-digit' });
2022-03-06 00:59:36 +01:00
</script>
<Modal isOpen={open} {toggle} centered scrollable>
2022-03-06 13:47:05 +01:00
<ModalHeader {toggle}>
<span class="pe-3">
<Badge color="custom" style="background-color:{event.backgroundColor}"
>{event.extendedProps.calendar}</Badge
>
</span>
<b>{event.extendedProps.short_name}</b>
</ModalHeader>
2022-03-06 10:46:58 +01:00
<ModalBody>
{#if event.extendedProps.description}
{@html md.render(event.extendedProps.description)}
2022-03-06 10:46:58 +01:00
{:else}
<i>Pas de description</i>
2022-03-06 10:46:58 +01:00
{/if}
</ModalBody>
2022-03-06 01:14:43 +01:00
2022-03-06 01:44:33 +01:00
<ModalFooter class="justify-content-between">
<span>
{#if event.extendedProps.location}
<Icon name="geo" />
<span class="ms-1">{event.extendedProps.location}</span>
{/if}
</span>
<span>
{#if event.allDay}
<Icon name="calendar-range" />
<span class="ms-1">{dateFormat(event.start)} - {dateFormat(event.end)}</span>
{:else}
2022-03-06 10:46:58 +01:00
<Icon name="clock-history" />
2022-03-06 01:44:33 +01:00
<span class="ms-1">{timeFormat(event.start)} - {timeFormat(event.end)}</span>
{/if}
</span>
</ModalFooter>
2022-03-06 00:59:36 +01:00
</Modal>