<template>
  <button class="ie-button"
    :class="['ie-button', `ie-button-${type}`, `ie-button-${size}`, customClass, { 'is-disabled': disabled, 'has-shadow': hasShadow }]"
    :disabled="disabled" hover-class="button-hover" :style="getStyle" @click="handleClick">
    <slot></slot>
  </button>
</template>
<script lang="ts" setup>

type Props = {
  disabled: boolean;
  type: 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error';
  size: 'large' | 'normal' | 'small' | 'mini';
  customClass: string;
  round: number;
  shadow: boolean;
}
const props = withDefaults(defineProps<Props>(), {
  disabled: false,
  type: 'primary',
  size: 'large',
  customClass: '',
  round: 999,
  shadow: true
});
const hasShadow = computed(() => {
  return props.shadow && props.type === 'primary';
});
const getStyle = computed(() => {
  return {
    borderRadius: props.round + 'px'
  }
});
const emit = defineEmits(['click']);
const handleClick = () => {
  emit('click');
}
</script>
<style lang="scss" scoped>
.ie-button {
  height: fit-content !important;
  line-height: 1;
  font-weight: 800;
  @apply relative text-center;
}

.has-shadow {
  box-shadow: 0 5px 8px 0px rgba(49, 160, 252, 0.6);
}

.ie-button-primary {
  background: linear-gradient(to right, #31A0FC, #0088FE);
  @apply text-white
}

.ie-button-info {
  @apply bg-back text-fore-title;
}

.ie-button-success {
  @apply bg-success text-white;
}

.ie-button-warning {
  @apply bg-warning text-white;
}

.ie-button-large {
  @apply py-36 text-30;
}

.ie-button-normal {
  @apply py-32 text-28;
}

.ie-button-small {
  @apply py-26 text-26;
}

.ie-button-mini {
  @apply py-22 text-24;
}

.ie-button::after {
  border: none;
}

.is-disabled {
  background: #f7f7f7;
  color: rgba(0, 0, 0, 0.3);
  box-shadow: none;
}

.button-hover {
  // background: linear-gradient(to right, #2a8dde, #007ae5);
  @apply opacity-80;
}

.is-disabled:hover {
  background: #f7f7f7;
  color: rgba(0, 0, 0, 0.3);
  box-shadow: none;
}
</style>