<template>
  <button
    type="button"
    :class="$style.btn"
    :disabled="disabled"
    :style="{
      'background-color': bg,
      'border-color': bg,
      color: color,
      padding: padding,
      'font-size': fontSize + 'px',
      'font-weight': fontWeight,
      'border-radius': borderRadius + 'px',
    }"
    @click="$emit('click')"
  >
    <div :class="$style.groups">
      <div
        :class="$style.iconLeft"
        :style="{ 'background-color': `rgba(0,0,0, ${opacityIcon})` }"
        v-if="positionIcon === 'left'"
      >
        <IconBase :color="colorIcon" :name="nameIcon" :size="sizeIcon" />
      </div>
      <div
        v-html="textButton"
        :style="
          positionIcon === 'left'
            ? { 'padding-left': paddingText + 'px' }
            : { 'padding-right': paddingText + 'px' }
        "
      ></div>
      <div
        :class="$style.iconRight"
        :style="{ 'background-color': `rgba(0,0,0, ${opacityIcon})` }"
        v-if="positionIcon === 'right'"
      >
        <IconBase :color="colorIcon" :name="nameIcon" :size="sizeIcon" />
      </div>
    </div>
  </button>
</template>

<script>
import IconBase from "../Icons/IconBase.vue";

export default {
  name: "ButtonSimple",
  props: {
    textButton: {
      type: String,
      default: "Default button",
    },
    bg: {
      type: String,
      default: "#399333"
    },
    color: {
      type: String,
      default: "#ffffff"
    },
    padding: {
      type: String,
      default: "7px 12px",
    },
    fontWeight: {
      type: String,
      default: "normal",
    },
    fontSize: {
      type: Number,
      default: 13,
    },
    borderRadius: {
      type: Number,
      default: 3,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    colorIcon: {
      type: String,
      default: "#ffffff"
    },
    opacityIcon: {
      type: Number,
      default: 0.2,
    },
    nameIcon: {
      type: String,
    },
    sizeIcon: {
      type: Number,
    },
    positionIcon: {
      type: String,
      default: "right",
    },
    paddingText: {
      type: Number,
      default: 30,
    },
  },
  components: {
    IconBase,
  },
};
</script>

<style lang="scss" module>
.btn {
  display: inline-block;
  margin-bottom: 0;
  text-align: center;
  vertical-align: middle;
  touch-action: manipulation;
  cursor: pointer;
  background-image: none;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5384616;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  outline: none;
  -webkit-transition: all ease-in-out 0.15s;
  -o-transition: all ease-in-out 0.15s;
  transition: all ease-in-out 0.15s;
  &:hover {
    opacity: 0.9;
  }
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
}
.groups {
  display: flex;
  align-items: center;
  flex-direction: row;
  justify-content: space-between;
  position: relative;

  .iconLeft {
    padding: 10px;
    left: -13px;
    top: -8px;
    bottom: -8px;
    position: absolute;
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
  }

  .iconRight {
    padding: 10px;
    right: -13px;
    top: -8px;
    bottom: -8px;
    position: absolute;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
  }
}
</style>