<script>
import { defineComponent, h } from 'vue'
import { isString, isFunction } from '../utils/assist'
import VIcon from '../VIcon/index.vue'

export default defineComponent({
  name: 'VMenuIcon',
  props: {
    icon: [String, Function],
    color: String,
    size: [String, Number]
  },
  components: {},
  setup(props) {
    if (!props.icon) return () => ''
    
    if (isString(props.icon)) {
      return () => h(VIcon, { name: props.icon, size: props.size, color: props.color })
    }
    if (isFunction(props.icon)) {
      return () => h('i', { class: 'el-icon v-menu-icon' }, isFunction(props.icon) ? props.icon() : '')
    }
    return () => ''
  }
})
</script>

<style scoped></style>
