bar.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div class="svg-bar">
  3. <div class="item">
  4. <div
  5. class="rect"
  6. @mousedown="($event) => createNode($event, { type: 'rect' })"
  7. ></div>
  8. </div>
  9. <div class="item">
  10. <div
  11. class="circle"
  12. @mousedown="($event) => createNode($event, { type: 'circle' })"
  13. ></div>
  14. </div>
  15. <div class="item">
  16. <div
  17. class="rhombic"
  18. @mousedown="($event) => createNode($event, { type: 'rhombic' })"
  19. ></div>
  20. </div>
  21. </div>
  22. </template>
  23. <script setup>
  24. const emits = defineEmits(["createRect", "createNode"]);
  25. function createNode(e, config) {
  26. emits("createNode", e, config);
  27. }
  28. </script>
  29. <style lang="less" scoped>
  30. .svg-bar {
  31. width: 400px;
  32. height: 70px;
  33. position: absolute;
  34. left: 50%;
  35. top: 20px;
  36. transform: translateX(-50%);
  37. background-color: rgba(255, 255, 255, 0.8);
  38. border: 1px solid #ccc;
  39. border-radius: 10px;
  40. display: flex;
  41. align-items: center;
  42. justify-content: center;
  43. .item {
  44. width: 70px;
  45. height: 100%;
  46. display: flex;
  47. align-items: center;
  48. justify-content: center;
  49. .rect {
  50. width: 40px;
  51. height: 40px;
  52. border: 2px solid #666;
  53. border-radius: 5px;
  54. cursor: pointer;
  55. }
  56. .circle {
  57. width: 40px;
  58. height: 40px;
  59. border: 2px solid #666;
  60. border-radius: 22px;
  61. cursor: pointer;
  62. }
  63. .rhombic {
  64. width: 40px;
  65. height: 40px;
  66. border: 2px solid #666;
  67. cursor: pointer;
  68. transform: rotate(45deg) scale(0.8);
  69. }
  70. }
  71. }
  72. </style>