<template>
  <div class="topic-element-preview">
    <div
      :id="`preview-${data.id}`"
      :class="classes"
      :data-type="data.type"
      :style="styles"
    >
      <component :is="compName" :data="data"></component>
    </div>
  </div>
</template>

<script>
import PreviewPaneBox from "../elements/pane-box/ElemPaneBox.vue";
import PreviewPaperStruct from "../elements/paper-struct/ElemPaperStruct";

export default {
  name: "TopicElementPreview",
  components: {
    PreviewPaneBox,
    PreviewPaperStruct,
  },
  props: {
    data: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {};
  },
  computed: {
    elementName() {
      return this.data.type.toLowerCase().replace("_", "-");
    },
    compName() {
      return `preview-${this.elementName}`;
    },
    classes() {
      return [
        "topic-preview",
        "element-item",
        "element-item-width",
        `element-item-${this.elementName}`,
      ];
    },
    styles() {
      return {
        left: this.data.x + "px",
        top: this.data.y + "px",
        width: this.data.w + "px",
        height: this.data.h + "px",
      };
    },
  },
  methods: {},
};
</script>
