<template>
  <section>
    <div class="content">
      <ul>
        <li>Linksklick + Ziehen: Neues Türchen erstellen</li>
        <li>Rechtsklick + Ziehen: Türchen verschieben</li>
        <li>Doppel- oder Mittelklick: Türchen löschen</li>
      </ul>
    </div>
    <figure class="image">
      <img src="@/assets/adventskalender.jpg" />
      <RectangleCanvas v-model="rectangles" />
    </figure>
  </section>
</template>

<script lang="ts">
import { Vue, Options } from "vue-class-component";
import { Door } from "./calendar";
import RectangleCanvas from "./RectangleCanvas.vue";

@Options({
  components: {
    RectangleCanvas,
  },
  props: {
    doors: Array,
  },
  emits: ["update:doors"],
})
export default class extends Vue {
  private doors!: Door[];

  private get rectangles() {
    return this.doors.filter((door) => door.position);
  }

  public beforeUnmount() {
    this.$emit("update:doors", this.doors);
  }
}
</script>

<style lang="scss" scoped>
section > figure {
  user-select: none;
}
</style>