<template>
  <div v-show="visible" :class="[
     type ? 'qf-tip-' + type : ''
  ]">
    <div class="qf-tip-title" :class="[description || $slots.description ? 'is-bold' : '']">
      <qf-font-icon :name="'ic-ic_' + type"></qf-font-icon>
      <div class="qf-tip-msg">
        <span v-html="msg" v-if="msg"></span>
        <slot></slot>
      </div>
      <qf-font-icon name="ic-ic_close" class="qf-tip-close" @click="close" v-if="closable"></qf-font-icon>
    </div>
    <div v-if="description || $slots.description" class="qf-tip-description">
      <slot name="description">{{description}}</slot>
    </div>
  </div>
</template>

<script>
import QfFontIcon from '../../font-icon';

export default {
  components: {
    QfFontIcon
  },
  name: 'QfTip',
  props: {
    type: {
      type: String,
      default: 'info'
    },
    closable: {
      type: Boolean,
      default: false
    },
    description: String,
    msg: String
  },
  data() {
    return {
      visible: true
    };
  },
  methods: {
    close() {
      this.visible = false;
      this.$emit('close');
    }
  }
};
</script>
