chartBox.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div class="chart-box" :class="color">
  3. <div class="chart-title" v-if="name">
  4. <div class="name">
  5. <img :src="`/src/assets/images/common/chart-${color || 'icon'}.png`" alt="" />
  6. <span>{{name}}</span>
  7. <slot name="title-left"></slot>
  8. </div>
  9. <div class="slot">
  10. <slot name="title-right"></slot>
  11. </div>
  12. </div>
  13. <slot v-else name="title-name"></slot>
  14. <div class="chart-content">
  15. <div v-show="arrow" :class="['arrow',arrow]" @click="handleShrink">
  16. <el-icon class="icon" color="#141414"><DArrowLeft /></el-icon>
  17. </div>
  18. <slot></slot>
  19. </div>
  20. </div>
  21. </template>
  22. <script setup>
  23. import {ref} from 'vue'
  24. const props = defineProps({
  25. name:{
  26. type:String,
  27. defalut:''
  28. },
  29. arrow:{
  30. type:String,
  31. defalut:''
  32. },
  33. color:{
  34. type:String,
  35. defalut:'icon'
  36. }
  37. })
  38. const isShrink = ref(true)
  39. const handleShrink = () =>{
  40. }
  41. </script>
  42. <style lang="scss" scoped>
  43. .chart-box {
  44. width: 100%;
  45. height: 100%;
  46. box-sizing: border-box;
  47. border-radius: 4px;
  48. background: #232323;
  49. border: 0.6px solid rgb(255, 255, 255,0.4);
  50. .chart-title {
  51. width: 100%;
  52. height: 38px;
  53. display: flex;
  54. align-items: center;
  55. justify-content: space-between;
  56. background: rgba(255, 255, 255, 0.05);
  57. padding-right: 12px;
  58. box-sizing: border-box;
  59. flex: none;
  60. .name {
  61. display: flex;
  62. align-items: center;
  63. padding: 0 12px;
  64. span{
  65. font-size: 18px;
  66. margin-left: 6px;
  67. font-family: 'SOURCEHANTIFINE';
  68. margin-right: 8px;
  69. }
  70. }
  71. }
  72. .chart-content{
  73. position: relative;
  74. width: 100%;
  75. height: calc(100% - 38px);
  76. padding: 4px 8px;
  77. box-sizing: border-box;
  78. .arrow{
  79. position: absolute;
  80. right: -16px;
  81. top:calc(50% - 40px);
  82. background: #fff;
  83. width: 16px;
  84. height: 80px;
  85. line-height: 80px;
  86. border-radius: 0 5px 5px 0;
  87. text-align: center;
  88. cursor: pointer;
  89. }
  90. .arrow-left{
  91. left: -16px;
  92. border-radius: 5px 0 0 5px;
  93. .icon{
  94. transform: rotate(180deg);
  95. }
  96. }
  97. }
  98. &.yellow{
  99. border: 0.6px solid #444444;
  100. border-radius: 8px;
  101. background: #191919;
  102. .chart-title{
  103. height: 59px;
  104. .name{
  105. color: #FFD489;
  106. span{
  107. font-size: 22px;
  108. }
  109. }
  110. }
  111. .chart-content{
  112. padding: 0;
  113. height: calc(100% - 59px);
  114. }
  115. }
  116. }
  117. .shrink-animation {
  118. width: 100%; /* 初始宽度,与关键帧中的初始状态一致 */
  119. overflow: hidden; /* 防止内容溢出 */
  120. animation: shrink-horizontal 2s forwards; /* 应用动画,持续时间为2秒,动画结束后保持最终状态 */
  121. }
  122. /* 定义动画关键帧 */
  123. @keyframes shrink-horizontal {
  124. 0% {
  125. width: 100%; /* 初始宽度,可以是具体的像素值或百分比 */
  126. transform: scaleX(1); /* 初始缩放比例 */
  127. }
  128. 100% {
  129. width: 0%; /* 最终宽度,这里设置为0表示完全收缩 */
  130. transform: scaleX(0); /* 最终缩放比例,这里设置为0表示在X轴上完全收缩 */
  131. }
  132. }
  133. </style>