All files / vue-storybook/src/components/generic ButtonItem.vue

71.43% Statements 5/7
50% Branches 2/4
100% Functions 1/1
71.43% Lines 5/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                4x                         2x     2x   2x   2x                
<template>
    <button type="button" class="btn font-weight-bold" :class="button_class" @click="$emit('click')">
        <icon :type="icon_type" :name="icon" v-if="icon"></icon>
        <span v-if="text">{{ text }}</span>
    </button>
</template>
 
<script>
import Icon from './Icon.vue';
 
export default {
  components: {
    Icon
  },
  props: {
    type: { type: String, required: false, default: 'primary' },
    text: { type: String, required: false },
    icon_type: { type: String, required: false, default: 'regular' },
    icon: { type: String, required: false }
  },
  computed: {
    button_class () {
      const {type} = this;
 
I      if (type.toLowerCase() === 'text') {
        return 'bg-transparent text-info p-0';
E      }
      else if (!type.startsWith('btn-')) {
        return `btn-${type}`;
      }
 
      return type;
    }
  }
}
</script>