<template>
  <button
    class="lzxx-button"
    :class="{[`lzxx-icon--${iconPosition}`]: true}"
    @click="$emit('click')"
  >
    <i
      v-if="loading"
      class="lzxx-button__spinning lzxx-icon i-loading"
    ></i>
    <i
      v-else-if="icon"
      :class="['lzxx-icon', 'i-' + icon]"
    >
    </i>
    <div class="lzxx-button__content">
      <slot />
    </div>
  </button>
</template>

<script>
export default {
  name: 'LButton',
  props: {
    icon: String,
    iconPosition: {
      type: String,
      default: 'left',
      validator (value) {
        return value === 'left' || value === 'right'
      }
    },
    loading: {
      type: Boolean,
      default: false
    }
  }
}
</script>
