<template>
  <div>
    <ul class="sidebar">
      <li @click="handleItem(item)" :class="{active:item.id==activeId}" v-for="(item,i) in list" :key="i">{{item.title}}</li>
    </ul>
    <slot name="bottom"></slot>
  </div>
</template>

<script>
export default {
  props:{
    list:{
      type:Array,
      default:()=>{
        return []
      }
    },
    activeId:{
      type:String,
      default:''
    }
  },
  methods:{
    handleItem(item){
      this.$emit('handleItem',item)
    }
  }
}
</script>

<style lang="less" scoped>
.sidebar{
  border: 1px solid #9E9E9E;
  max-width: 250px;
  min-width: 220px;
  li{
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
    line-height: 50px;
    height: 50px;
    padding: 0 10px 0 24px;
    position: relative;
    cursor: pointer;
    color: #9e9e9e;
    text-align: left;
    &::before{
      display: inline-block;
      content: '';
      width: 4px;
      height: 4px;
      position: absolute;
      transform: translate(-50%,-50%);
      left: 18px;
      top: 50%;
      border-radius: 50%;
      background-color: #9e9e9e;
    }
    &:hover{
      &::before{
        background-color: #fff;
      }
    }
  }
  .active{
    font-weight: bold;
    &::before{
      background-color: #fff;
    }
  }
}
</style>