TopicElementPreview.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 PreviewTopicHead from "../elements/topic-head/TopicHead";
  20. export default {
  21. name: "topic-element-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-width",
  50. `element-item-${this.elementName}`,
  51. this.data["isLast"]
  52. ? `element-item-type-last`
  53. : "element-item-type-pre",
  54. ];
  55. },
  56. styles() {
  57. return {
  58. left: this.data.x + "px",
  59. top: this.data.y + "px",
  60. width: this.data.w + "px",
  61. height: this.data.h + "px",
  62. };
  63. },
  64. },
  65. methods: {},
  66. };
  67. </script>