<template>
  <span
    class="trifle-label"
    :style="style"
    @click="onClick"
  >
    <slot />
  </span>
</template>

<script>
const colorList = [
  'red', 'orange', 'yellow', 'olive', 'green',
  'teal', 'blue', 'violet', 'purple', 'pink',
  'brown', 'grey', 'black'
]

export default {
  name: 'Label',
  props: {
    onClick: {
      type: Function,
      default: function() {}
    },
    color: {
      type: String,
      default: 'red',
      required: true,
      validator(val) {
        return colorList.includes(val)
      },
    }
  },
  computed: {
    style() {
      return {
        '--color': this.color
      }
    },
  },
}
</script>

<style lang="scss" scoped>
@import '../const/variable.scss';

.trifle-label {
  --color: red;
  background: var(--color);

  display: inline-block;
  color: palette(white, base);
  margin: 5px;
  padding: 5px 10px;
  font-weight: bold;
  border-radius: 4px;
  font-size: 10px;
}
</style>
