<template>
  <div class="modal is-active" v-if="modelValue" @click="hide">
    <div class="modal-background" />

    <div class="modal-content">
      <div class="image is-square">
        <img :src="imageUrl" alt="Kalender-Bild" />
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Options, Vue } from "vue-class-component";

@Options({
  props: {
    modelValue: Boolean,
    imageUrl: String,
  },
})
export default class ImageModal extends Vue {
  modelValue!: boolean;
  imageUrl!: string;

  public created(): void {
    window.addEventListener("keydown", (e) => {
      if (e.key == "Escape") this.hide();
    });
  }

  private hide(): void {
    this.$emit("update:modelValue", false);
  }
}
</script>
