All files / components/Event Event.svelte

0% Statements 0/74
0% Branches 0/1
0% Functions 0/1
0% Lines 0/74

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75                                                                                                                                                     
<script lang="ts">
  import DateComponent from "$lib/components/Date";
  import Link from "$lib/components/Link";
  import {
    headingTagByLevel,
    type HeadingLevel,
  } from "$lib/components/ContentfulRichText/headings";
  import constructEventSlug from "$lib/util/constructEventSlug";

  interface EventData {
    __typename?: "EventEntry";
    slug?: string | null;
    shortTitle?: string | null;
    eventDescription?: string | null;
    eventDateAndTime?: Date | string | null;
    eventSummary?: string | null;
    sys: {
      __typename?: "Sys";
      id: string;
    };
  }

  export let event: NonNullable<EventData>;
  export let headingLevel: HeadingLevel = 2;
  export let variation: "big" | "small" = "big";

  const dateString = event?.eventDateAndTime as string;

  $: date = event?.eventDateAndTime ? new Date(dateString) : undefined;
</script>

<div class="event">
  {#if event?.eventDateAndTime}
    <DateComponent {dateString} {variation} />
  {/if}
  <div class="event-details">
    {#if event?.shortTitle}
      <Link
        class="display-block"
        href={date && event?.slug
          ? `/about/events/event/${constructEventSlug(date, event.slug)}`
          : undefined}
      >
        <svelte:element this={headingTagByLevel[headingLevel]} class="event-title">
          {event.shortTitle}
        </svelte:element>
      </Link>
    {/if}
    {#if event?.eventSummary}
      <p class="event-summary">
        {event.eventSummary}
      </p>
    {/if}
  </div>
</div>

<style>
  .event {
    display: flex;
    flex-direction: row;
    gap: 14px;
    padding-bottom: 18px;
    border-bottom: 1px solid #757473; /* replace with $grayscale-90 */
  }

  .event-title {
    font-size: 18px;
    margin: 0;
  }

  .event-summary {
    margin: 0;
  }
</style>