ElemCompositionElement.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div class="elem-composition-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-composition-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 [
  41. "composition-element-body",
  42. `composition-element-${this.elementName}`
  43. ];
  44. },
  45. styles() {
  46. return {
  47. left: this.data.x + "px",
  48. top: this.data.y + "px",
  49. width: this.data.w + "px",
  50. height: this.data.h + "px"
  51. };
  52. }
  53. }
  54. };
  55. </script>