ElemExplainElement.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div class="elem-explain-element">
  3. <div :class="classes" :style="styles" :id="data.id">
  4. <component :is="compName" :data="data"></component>
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import ElemText from "../text/ElemText";
  10. import ElemImage from "../image/ElemImage";
  11. import ElemLine from "../line/ElemLine";
  12. import ElemLines from "../lines/ElemLines";
  13. import ElemGrids from "../grids/ElemGrids";
  14. export default {
  15. name: "elem-explain-element",
  16. components: {
  17. ElemText,
  18. ElemImage,
  19. ElemLine,
  20. ElemLines,
  21. ElemGrids,
  22. },
  23. props: {
  24. data: {
  25. type: Object,
  26. },
  27. },
  28. data() {
  29. return {};
  30. },
  31. computed: {
  32. compName() {
  33. if (this.data.type.includes("LINE_")) return "elem-line";
  34. return `elem-${this.data.type.toLowerCase()}`;
  35. },
  36. elementName() {
  37. return this.data.type.toLowerCase().replace("_", "-");
  38. },
  39. classes() {
  40. return ["explain-element-body", `explain-element-${this.elementName}`];
  41. },
  42. styles() {
  43. return {
  44. left: this.data.x + "px",
  45. top: this.data.y + "px",
  46. width: this.data.w + "px",
  47. height: this.data.h + "px",
  48. };
  49. },
  50. },
  51. methods: {},
  52. };
  53. </script>