TopicElementPreview.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="topic-element">
  3. <div
  4. :class="classes"
  5. :id="`preview-${data.id}`"
  6. :data-type="data.type"
  7. :style="styles"
  8. >
  9. <component :is="compName" :data="data" preview></component>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import PreviewCardHead from "../elements/card-head/CardHead";
  15. import PreviewExplain from "../elements/explain/ElemExplain";
  16. import PreviewComposition from "../elements/composition/ElemComposition";
  17. import PreviewFillQuestion from "../elements/fill-question/ElemFillQuestion";
  18. import PreviewFillLine from "../elements/fill-line/ElemFillLine";
  19. import PreviewTopicHead from "../elements/topic-head/TopicHead";
  20. export default {
  21. name: "topic-preview",
  22. components: {
  23. PreviewCardHead,
  24. PreviewTopicHead,
  25. PreviewFillQuestion,
  26. PreviewFillLine,
  27. PreviewExplain,
  28. PreviewComposition
  29. },
  30. props: {
  31. data: {
  32. type: Object
  33. }
  34. },
  35. data() {
  36. return {};
  37. },
  38. computed: {
  39. elementName() {
  40. return this.data.type.toLowerCase().replace("_", "-");
  41. },
  42. compName() {
  43. return `preview-${this.elementName}`;
  44. },
  45. classes() {
  46. return [
  47. "topic-preview",
  48. "element-item",
  49. `element-item-${this.elementName}`,
  50. this.data["isLast"] ? `element-item-type-last` : "element-item-type-pre"
  51. ];
  52. },
  53. styles() {
  54. return {
  55. left: this.data.x + "px",
  56. top: this.data.y + "px",
  57. width: this.data.w + "px",
  58. height: this.data.h + "px"
  59. };
  60. }
  61. },
  62. methods: {}
  63. };
  64. </script>