ElemGrids.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div :class="classes">
  3. <table :style="tableStyles">
  4. <template v-for="(row, rindex) in data.rowCount">
  5. <tr :key="rindex">
  6. <td
  7. v-for="(col, cindex) in data.columnCount"
  8. :key="cindex"
  9. :style="styles"
  10. >
  11. <div v-if="data.halving" style="paddingBottom: 100%;"></div>
  12. </td>
  13. </tr>
  14. <tr :key="`space-${rindex}`" v-if="data.rowSpace">
  15. <td :style="rowSpaceStyle" :colspan="data.columnCount"></td>
  16. </tr>
  17. </template>
  18. </table>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. name: "elem-grids",
  24. props: {
  25. data: {
  26. type: Object
  27. }
  28. },
  29. data() {
  30. return {};
  31. },
  32. computed: {
  33. classes() {
  34. return ["elem-grids", { "elem-grids-halving": this.data.halving }];
  35. },
  36. styles() {
  37. let data = {
  38. borderStyle: this.data.style
  39. };
  40. if (!this.data.halving) {
  41. data.width = this.data.columnSize + "px";
  42. data.height = this.data.columnSize + "px";
  43. }
  44. return data;
  45. },
  46. tableStyles() {
  47. let data = {};
  48. if (!this.data.halving) {
  49. data.width = this.data.columnSize * this.data.columnCount + "px";
  50. }
  51. return data;
  52. },
  53. rowSpaceStyle() {
  54. return {
  55. height: this.data.rowSpace + "px",
  56. borderStyle: this.data.style
  57. };
  58. }
  59. },
  60. methods: {}
  61. };
  62. </script>