<template>
  <div class="title" :class="{error: type === 'error', warning: type === 'warning'}">
    <div>
      <span v-for="(item, index) in data" :key="index">
        <span>{{item.name}}</span>
        <b>{{item.num}}</b>
      </span>
    </div>
    <slot/>
  </div>
</template>
<script>
export default {
  props: {
    type: {
      type: String,
      default: 'warning'
    },
    data: {
      type: Array,
      default: []
    }
  }
}
</script>
<style lang="less" scoped>
.title{
  height: 48px;
  line-height: 48px;
  background-color: rgba(0, 0, 0, .02);
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  padding-right: 10px;
  font-weight: bold;
  transition: all .3s;
  width: 100%;
  b{
    font-size: 18px;
  }
  &:hover{
    background-color: rgba(0, 0, 0, .06);
  }
  &.error {
    b{
      color: #ED6F62;
    }
    &:before{
      background-color: #ED6F62;
    }
  }
  &.warning {
    b{
      color: #F2A24A;
    }
    &:before{
      background-color: #F2A24A;
    }
  }
  &:before{
      content: '';
      display: block;
      position: absolute;
      width: 7px;
      height: 48px;
      left: 0;
    }
  >div{
    position: relative;
    padding-left: 20px;
    font-size: 14px;
    >span{
      margin-right: 10px;
      display: inline-block;
    }
  }
}
</style>
