<template>
  <div class="go-wisdom-metrics">
    <div class="metrics-container">
      <div class="header">
        <div class="title" :style="{ color: option.titleColor, fontSize: option.titleSize + 'px' }">{{ option.title }}</div>
        <div class="subtitle" :style="{ color: option.subtitleColor, fontSize: option.subtitleSize + 'px' }">{{ option.subtitle }}</div>
      </div>
      <div class="content">
        <div v-for="(item, index) in option.dataset" :key="index" class="metric-item">
          <svg-icon :icon-class="item.icon" class="item-icon" :style="{ color: option.valueColor }"></svg-icon>
          <div class="item-label" :style="{ color: option.labelColor, fontSize: option.labelSize + 'px' }">{{ item.label }}</div>
          <div class="item-value">
            <span :style="{ color: option.valueColor, fontSize: option.valueSize + 'px' }">{{ item.value }}</span>
            <span :style="{ color: option.unitColor, fontSize: option.unitSize + 'px' }">{{ item.unit }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { PropType, computed } from 'vue'
import { option as configOption } from './config'

const props = defineProps({
  chartConfig: {
    type: Object as PropType<{ option: typeof configOption }>,
    required: true
  }
})

const option = computed(() => props.chartConfig.option)
</script>

<style lang="scss" scoped>
.go-wisdom-metrics {
  width: 100%;
  height: 100%;
  background-color: #0F1C3D;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;

  .metrics-container {
    width: 100%;
    height: 100%;
    border: 2px solid;
    border-image: linear-gradient(to right, v-bind('option.borderColor1'), v-bind('option.borderColor2')) 1;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }

  .header {
    text-align: center;
    margin-bottom: 20px;
    .title {
      font-weight: bold;
    }
  }

  .content {
    flex: 1;
    display: flex;
    justify-content: space-around;
    align-items: center;
  }

  .metric-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    .item-icon {
      font-size: 32px;
      margin-bottom: 10px;
    }
    .item-label {
      margin-bottom: 5px;
    }
    .item-value {
      span:first-child {
        font-weight: bold;
        margin-right: 5px;
      }
    }
  }
}
</style>
