chartBox.vue 2.5 KB

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