<template>
  <div class="box">
    <ul class="box-content">
      <li :class="{'box-item': true, 'selected': item.tag === value}"
          v-for="item in params" :key="item.tag" v-if="item.tag"
          @click="onClick(item)">
        <p>{{item.name}}</p>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'ControlSelector',
  props: {
    value: {
      type: String,
      default: ''
    },
    params: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  methods: {
    onClick (item) {
      if (item.tag !== this.value) this.$emit('input', item.tag)
    }
  }
}
</script>

<style scoped>
  .box {
    width: 100%;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
  }

  .box-content {
    width: calc(100% + 15px);
    height: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
    box-sizing: border-box;
    list-style: none;
  }

  .box-item {
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
    border-bottom: 1px solid #ECEDEF;
    list-style: none;
  }

  .box-item:last-child {
    border-bottom: none
  }

  .box-item:hover {
    border-bottom-color: #3db389;
    color: #3db389;
  }

  .box-item.selected {
    color: #fff;
    border-bottom-color: #3db389;
    background-color: #3db389;
  }

  .box-item * {
    user-select: none;
    pointer-events: none;
  }
</style>
