<template>
  <button class="button-input"
          @click="click"
          :class="{
            error: color === 'error',
            primary: color === 'primary',
            secondary: color === 'secondary',
            transparent: color === 'transparent',
            disabled: color === 'disabled'
          }">
    <slot/>
  </button>
</template>

<script>
export default {
  name: "button-input",
  props: ['type', 'disabled'],
  computed: {
    color: function () {
      if (this.disabled)
        return 'disabled';
      else
        return this.type;
    }
  },
  methods: {
    click: function (event) {
      if (!this.disabled) {
        this.$emit('click', event);
      }
    }
  }
}
</script>

<style scoped>
button {
  padding: 0.67rem 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.75rem;
  cursor: pointer;
}

.disabled {
  color: rgba(0, 0, 0, 0.4);
  background-color: ghostwhite;
  cursor: default;
}

.error {
  background-color: var(--error);
  color: white;
}

.primary {
  background-color: var(--primary);
  color: white;
}

.secondary {
  background-color: var(--secondary);
}

.transparent {
  background-color: transparent;
  border: none;
}
</style>