<template>
  <div class="mapLegendView">
    <div class="legendTitle">
      图例
      <span class="legendBtn" @click="isOpen = !isOpen">
        <i class="icon iconfont" :class="isOpen ? 'icon-fold' : 'icon-unFold'"></i>
      </span>
    </div>

    <div class="legendContent" v-show="isOpen">
      <a-spin :spinning="data === 0">
        <div class="legendGroup" v-for="i in data">
          <div class="groupTitle">工程</div>
          <div class="groupContent">
            <div class="legendItem" v-for="j in 10" :key="j">
              <div class="legendIcon smallIcon"></div>
              <div class="legendIconTitle">
                大型水电站-已建
                <!-- <span
                  ><br />
                  2.、装机容量(万kW)
                </span> -->
              </div>
            </div>
          </div>
        </div>
      </a-spin>
    </div>
  </div>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
const data = ref(0);
onMounted(() => {
  setTimeout(() => {
    data.value = 10;
  }, 1000);
  console.log(data.value);
});
const isOpen = ref(true);
</script>

<style lang="scss" scoped>
.mapLegendView {
  position: absolute;
  left: 0;
  bottom: 0;
  min-width: 72px;
  margin: 24px 0 16px 16px;
  border: 1px solid #ccdae7;
  padding: 6px;
  z-index: 9;
  background-color: #ffffff;
}
.legendTitle {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  .legendBtn {
    cursor: pointer;
  }
}
.legendContent {
  white-space: nowrap;
  max-width: 450px;
  max-height: 392px;
  overflow-x: scroll;
  overflow-y: scroll;
  border-top: 1px solid #eeeeee;
  overflow-y: hidden;
  //   &::-webkit-scrollbar {
  //     width: 0;
  //   }
  .legendGroup {
    display: inline-block;
    vertical-align: top;
    padding: 0 4px;
    .groupTitle {
      text-align: left;
      font-weight: 700;
      font-size: 14px;
      cursor: pointer;
    }
    .groupContent {
      font-size: 14px;
      padding: 10px 0;
      margin-bottom: 0;
      .gray {
        filter: grayscale(100%);
        color: #00000073;
      }
      .legendItem {
        cursor: pointer;
        margin-right: 10px;
        padding: 4px 0;
        min-height: 30px;
        display: flex;
        flex-direction: row;
        .legendIcon {
          width: 22px !important;
          height: 22px !important;
          background-color: red;
        }
        .legendIconTitle {
          cursor: pointer;
          flex: 1 1;
        }
      }
    }
  }
}
</style>
