ShapePool.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="shape-pool">
  3. <div class="category" v-for="item in SHAPE_LIST" :key="item.type">
  4. <div class="category-name">{{item.type}}</div>
  5. <div class="shape-list">
  6. <ShapeItemThumbnail
  7. class="shape-item"
  8. v-for="(shape, index) in item.children"
  9. :key="index"
  10. :shape="shape"
  11. @click="selectShape(shape)"
  12. />
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script lang="ts" setup>
  18. import { SHAPE_LIST, type ShapePoolItem } from '@/configs/shapes'
  19. import ShapeItemThumbnail from './ShapeItemThumbnail.vue'
  20. const emit = defineEmits<{
  21. (event: 'select', payload: ShapePoolItem): void
  22. }>()
  23. const selectShape = (shape: ShapePoolItem) => {
  24. emit('select', shape)
  25. }
  26. </script>
  27. <style lang="scss" scoped>
  28. .shape-pool {
  29. width: 340px;
  30. max-height: 520px;
  31. overflow: auto;
  32. margin-top: -8px;
  33. margin-bottom: -8px;
  34. margin-right: -10px;
  35. padding-right: 10px;
  36. padding-top: 10px;
  37. }
  38. .category-name {
  39. width: 100%;
  40. font-size: 12px;
  41. margin-bottom: 10px;
  42. border-left: 4px solid #bbb;
  43. background-color: #f1f1f1;
  44. padding: 3px 0 3px 8px;
  45. color: #555;
  46. }
  47. .shape-list {
  48. @include flex-grid-layout();
  49. margin-bottom: 10px;
  50. }
  51. .shape-item {
  52. @include flex-grid-layout-children(10, 8%);
  53. height: 0;
  54. padding-bottom: 8%;
  55. flex-shrink: 0;
  56. }
  57. </style>