TopicElementPreview.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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"] ? `element-item-type-last` : "element-item-type-pre"
  52. ];
  53. },
  54. styles() {
  55. return {
  56. left: this.data.x + "px",
  57. top: this.data.y + "px",
  58. width: this.data.w + "px",
  59. height: this.data.h + "px"
  60. };
  61. }
  62. },
  63. methods: {}
  64. };
  65. </script>