<template>
  <button
    class="top-button"
    @click="handleClick"
    :disabled="buttonDisabled"
    :class="[
      type ? 'top-button--' + type : '',
      buttonSize ? 'top-button--' + buttonSize : '',
      {
        'is-disabled': buttonDisabled,
        'is-plain': plain
      }
    ]"
  >
    <span><slot></slot></span>
  </button>
</template>

<script>
export default {
  name: 'TopButton',
  props: {
    type: {
      type: String,
      default: 'default'
    },
    size: {
      type: String,
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    },
    plain: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    buttonSize() {
      return this.size
    },
    buttonDisabled() {
      return this.disabled
    }
  },
  methods: {
    handleClick(evt) {
      this.$emit('click', evt)
    }
  }
}
</script>

<style lang="scss" scoped>
.top-button {
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #fff;
  border: 1px solid #dcdfe6;
  color: #606266;
  -webkit-appearance: none;
  text-align: center;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  outline: 0;
  margin: 0;
  -webkit-transition: .1s;
  transition: .1s;
  font-weight: 500;
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 4px;
}

.top-button:focus, .top-button:hover {
  color: #409eff;
  border-color: #c6e2ff;
  background-color: #ecf5ff;
}

.top-button--mini, .top-button--mini.is-round {
  padding: 7px 15px;
}

.top-button--mini, .top-button--small {
  font-size: 12px;
  border-radius: 3px;
}
</style>
