TopicElementPreview.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="topic-element-preview">
  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 PreviewForbidArea from "../elements/forbid-area/ElemForbidArea.vue";
  20. import PreviewTopicHead from "../elements/topic-head/TopicHead";
  21. export default {
  22. name: "topic-element-preview",
  23. components: {
  24. PreviewCardHead,
  25. PreviewTopicHead,
  26. PreviewFillQuestion,
  27. PreviewFillLine,
  28. PreviewExplain,
  29. PreviewComposition,
  30. PreviewForbidArea,
  31. },
  32. props: {
  33. data: {
  34. type: Object,
  35. },
  36. },
  37. data() {
  38. return {};
  39. },
  40. computed: {
  41. elementName() {
  42. return this.data.type.toLowerCase().replace("_", "-");
  43. },
  44. compName() {
  45. return `preview-${this.elementName}`;
  46. },
  47. classes() {
  48. return [
  49. "topic-preview",
  50. "element-item",
  51. "element-item-width",
  52. `element-item-${this.elementName}`,
  53. this.data["isLast"]
  54. ? `element-item-type-last`
  55. : "element-item-type-pre",
  56. ];
  57. },
  58. styles() {
  59. return {
  60. left: this.data.x + "px",
  61. top: this.data.y + "px",
  62. width: this.data.w + "px",
  63. height: this.data.h + "px",
  64. };
  65. },
  66. },
  67. methods: {},
  68. };
  69. </script>