<template>
  <div class="brief-container">
    <div v-for="item in list" :key="item.name">
      <img v-if="item.icon" :src="`@/assets/images/${item.icon}`" />
      <div v-if="Array.isArray(item.value)">
        <div class="count-group">
          <m-count class="count yellow" :value="item.value[0]" />
          /
          <m-count class="count" :value="item.value[1]" />
        </div>
        <p>{{ item.name }}</p>
      </div>
      <div v-else :class="{ center: !item.icon }">
        <m-count class="count yellow" :value="item.value" />
        <p>{{ item.name }}</p>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue'

export interface BriefProp {
  name: string
  value: number | number[]
  icon?: string
}
export default defineComponent({
  name: 'Brief',
  props: {
    list: {
      type: Array as PropType<BriefProp[]>,
      required: true,
    },
  },
})
</script>

<style lang="stylus" scoped>
@import '../../components/MyComponent/main.styl'
.brief-container
  display flex
  justify-content space-around
  align-items center
  .count
    font-size .12rem
    &.yellow
      font-size .14rem
      color $yellow
  >div
    display flex
    align-items center
    >img
      width .22rem
      height @width
      margin-right .05rem
    >div
      font-weight bold
      p
        color #ccc
      &.center
        text-align center
</style>
