<template>
  <a :href="href" :disabled="isDisabled" :class="style" target="_blank">
    <slot />
  </a>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
import ClickEvent from '../../core/events/ClickEvent'

type BaseButtonType = 'selected' | 'invisible' | 'primary' | 'secondary' | 'default' | 'link' | 'destructive' | 'important' | 'assertive'

@Component({
  name: 'base-button'
})
export default class BaseButton extends Vue {
  @Prop() readonly href!: string
  @Prop({ default: 'default' }) readonly type!: BaseButtonType
  @Prop({ default: false }) readonly disabled!: boolean
  @Prop({ default: false }) readonly waiting!: boolean

  get isDisabled () {
    return this.disabled !== false || this.waiting !== false
  }

  get style () {
    return {
      button: true,
      'has-text-weight-semibold': this.type === 'primary' || this.type === 'destructive' || this.type === 'important' || this.type === 'assertive',
      'is-loading': this.waiting !== false,
      'is-light': this.type === 'default',
      'is-primary': this.type === 'primary',
      'is-text': this.type === 'link',
      'is-danger': this.type === 'destructive',
      'is-info': this.type === 'important',
      'is-success': this.type === 'selected',
      'is-warning': this.type === 'assertive',
      'is-white': this.type === 'invisible'
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../../core/base/bulma.scss";
$button-padding-vertical: 0;
@import "bulma/sass/elements/button.sass";
</style>
