<template>
  <div class="chart-box">
    <div class="chart-title">
      <div class="name">
        <img src="@/assets/images/common/chart-icon.png" alt="" />
        <span>{{name}}</span>
      </div>
      <div class="slot">
        <slot name="title-right"></slot>
      </div>
    </div>
    <div class="chart-content">
        <div v-show="arrow" :class="['arrow',arrow]" @click="handleShrink">
            <el-icon class="icon" color="#141414"><DArrowLeft /></el-icon>
        </div>
        <slot></slot>
    </div>
  </div>
</template>

<script setup>
import {ref} from 'vue'
const props = defineProps({
    name:{
        type:String,
        defalut:''
    },
    arrow:{
        type:String,
        defalut:''
    }
})

const isShrink = ref(true)
const handleShrink = () =>{

}
</script>

<style lang="scss" scoped>
.chart-box {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 4px;
  background: #232323;
  border: 0.6px solid rgb(255, 255, 255,0.4);
  .chart-title {
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    border-bottom: 0.6px solid rgb(255, 255, 255, 0.4);
    .name {
      display: flex;
      align-items: center;
      padding: 0 12px;
      span{
        font-size: 18px;
        margin-left: 6px;
        font-family: 'SOURCEHANTIFINE';
      }
    }
  }
  .chart-content{
    position: relative;
    width: 100%;
    height: calc(100% - 38px);
    .arrow{
        position: absolute;
        right: -16px;
        top:calc(50% - 40px);
        background: #fff;
        width: 16px;
        height: 80px;
        line-height: 80px;
        border-radius: 0 5px 5px 0;
        text-align: center;
        cursor: pointer;
    }
    .arrow-left{
        left: -16px;
        border-radius: 5px 0 0 5px;
        .icon{
            transform: rotate(180deg);
        }
    }
  }
}

.shrink-animation {  
  width: 100%; /* 初始宽度，与关键帧中的初始状态一致 */  
  overflow: hidden; /* 防止内容溢出 */  
  animation: shrink-horizontal 2s forwards; /* 应用动画，持续时间为2秒，动画结束后保持最终状态 */  
}

/* 定义动画关键帧 */  
@keyframes shrink-horizontal {  
  0% {  
    width: 100%; /* 初始宽度，可以是具体的像素值或百分比 */  
    transform: scaleX(1); /* 初始缩放比例 */  
  }  
  100% {  
    width: 0%; /* 最终宽度，这里设置为0表示完全收缩 */  
    transform: scaleX(0); /* 最终缩放比例，这里设置为0表示在X轴上完全收缩 */  
  }  
}
</style>