<template>
  <view class="zui-button" hover-class="active" :class="classRender" :style="style" @click="onClick">
    <slot></slot>
  </view>
</template>

<script>
export default {
  name: 'zui-button',
  props: {
    type: {
      type: String,
      default: 'default'
    },
    size: {
      type: String,
      default: 'md'
    },
    block: {
      type: Boolean,
      default: false
    },
    round: Boolean,
    square: Boolean,
    disabled: Boolean,
  },
  computed: {
    style: function() {
      return `display: ${this.block ? '' : 'inline-block'};` ;
    },
    classRender: function() {
      return [this.size, this.disabled ? 'disabled' : '', this.block ? 'block' : '', this.type, this.round ? 'round' : '', this.square ? 'square' : ''];
    }
  },
  methods: {
    onClick: function() {
      if (!this.disabled) {
        this.$emit('click');
      }
    }
  }
}
</script>

<style lang="scss">
@import "./index.scss";
</style>