<template>
  <button
    :class="['button', 'button-with-icon-and-text', { 'button-with-icon-and-text--large': large }]"
    :disabled="disabled"
    @click="$emit('click')"
  >
    <component class="button-with-icon-and-text__icon" :is="icon" />
    <span class="button-with-icon-and-text__text">{{ text }}</span>
  </button>
</template>

<script>
import formElementIcons from '@/components/ui/form-element-icons';

export default {
  props: {
    icon: {
      type: String,
      default: '',
    },
    text: {
      type: String,
      default: '',
    },
    large: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },

  components: {
    ...formElementIcons,
  },
};
</script>

<style scoped lang="scss">
@import '~styles/helpers';

.button-with-icon-and-text {
  display: flex;
  align-items: center;
  cursor: pointer;
  border: 0;
  width: 100%;

  &:disabled {
    background-color: transparent;
    opacity: 0.5;
  }

  &__icon {
    width: 24px;
    height: 24px;
    margin-right: $small-spacing;
  }

  &__text {
    @include small-text;
  }

  $p: &;

  &--large {
    #{$p}__text {
      @include large-link;
    }
  }
}
</style>
