<template>
  <div class="type_group">
    <span
      v-for="item in types"
      class="type_item"
      v-text="item.name"
      :class="{ current: item.value === type }"
      :key="item.value"
      @click="$emit('change-type', item.value)"
    ></span>
  </div>
</template>

<script>
export default {
  model: {
    prop: "type",
    event: "change-type",
  },
  props: {
    type: {
      type: [Number, String],
    },
    types: {
      type: Array,
      default: () => [],
    },
  },
};
</script>

<style scoped>
.type_group {
  display: inline-flex;
  background-color: #f6f7fb;
  padding: 6px;
  border-radius: 6px;
}
.type_item {
  min-width: 100px;
  padding: 10px;
  box-sizing: border-box;
  border-radius: 5px;
  overflow: hidden;
  font-size: 14px;
  color: #58617a;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
}
.type_item:not(:first-child) {
  margin-left: 10px;
}
.type_item.current {
  background-color: #515fe7;
  color: #fff;
}
</style>
