<template>
  <i class="zui-icon" :class="classRender" :style="styleRender" @click.stop="onClick">
    <div v-if="info || dot" class="zui-info" :class="{ dot: dot }">{{ info }}</div>
  </i>
</template>

<script>
export default {
  name: 'Icon',
  props: {
    name: {
      type: String,
      default: '',
    },
    fontFamily: {
      type: String,
      default: 'iconfont',
    },
    classPrefix: {
      type: String,
      default: 'icon-',
    },
    size: String,
    color: String,
    info: [Number, String],
    dot: Boolean,
  },
  computed: {
    classRender: function () {
      var fontFamily = this.fontFamily || '';
      var iconClass = this.classPrefix + this.name;
      return [fontFamily, iconClass];
    },
    styleRender: function () {
      return {
        fontSize: this.size,
        color: this.color,
      };
    },
  },
  methods: {
    onClick: function () {
      if (this.$listeners['click']) {
        this.$emit('click');
      }
    },
  },
};
</script>

<style>
@import './index.css';
</style>
