moduleRight.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <Transition class="module-right">
  3. <div v-if="visible" class="module-content">
  4. <div v-if="title" class="module-content__title__expand">
  5. <span class="action-btn close-btn" @click="closeModel"></span>
  6. <span @click="clickHandler">{{ title }}</span>
  7. </div>
  8. <div class="module-slot">
  9. <slot></slot>
  10. </div>
  11. </div>
  12. </Transition>
  13. </template>
  14. <script lang="ts" setup>
  15. defineProps<{ title: string; visible: boolean }>();
  16. const emit = defineEmits(['close', 'click']);
  17. function closeModel() {
  18. emit('close');
  19. }
  20. function clickHandler() {
  21. emit('click');
  22. }
  23. </script>
  24. <style lang="less" scoped>
  25. .module-right {
  26. --bg-height: 33px;
  27. color: #fff;
  28. box-sizing: border-box;
  29. position: absolute;
  30. .module-content {
  31. width: 100%;
  32. height: 100%;
  33. }
  34. .module-content__title__expand {
  35. width: 100%;
  36. height: var(--bg-height);
  37. line-height: var(--bg-height);
  38. background: url('@/assets/images/home-container/configurable/model_right_title_bg_expand.png') no-repeat;
  39. background-size: 100% 100%;
  40. position: relative;
  41. text-align: left;
  42. padding: 0 0 0 10%;
  43. }
  44. .module-content__title {
  45. width: 50%;
  46. height: var(--bg-height);
  47. line-height: var(--bg-height);
  48. background: url('@/assets/images/home-container/configurable/model_right_title_bg.png') no-repeat;
  49. background-size: 100% 100%;
  50. position: relative;
  51. text-align: left;
  52. margin-left: 50%;
  53. padding: 0 0 0 10%;
  54. }
  55. // 固定在父容器右上角的按钮图标
  56. .action-btn {
  57. width: 18px;
  58. height: 18px;
  59. background: url('@/assets/images/home-container/configurable/expand.svg') no-repeat center;
  60. position: absolute;
  61. left: 0;
  62. top: 0;
  63. cursor: pointer;
  64. }
  65. .show-btn {
  66. transform: rotate(-90deg);
  67. }
  68. .module-slot {
  69. height: calc(100% - 33px);
  70. width: 100%;
  71. background-color: #259ccf22;
  72. }
  73. }
  74. // Transition动画相关
  75. .v-enter-active,
  76. .v-leave-active {
  77. transition: all 0.3s ease;
  78. }
  79. .v-enter-from,
  80. .v-leave-to {
  81. // opacity: 1;
  82. transform: translateX(100%);
  83. // transform: scaleY(0);
  84. // transform-origin: center top;
  85. }
  86. </style>