import CipSvgIcon from '@cip/components/cip-svg-icon'
import { isObject } from '@cip/utils/util'
const CipMainIcon = (props) => {
  let name = props.name
  if (name) {
    if (typeof name === 'string') {
      if (name.indexOf('_') === 0) {
        name = name.substr(1)
        return <CipSvgIcon name={name}/>
      } else {
        return <i class={name} /> // h('i', { class: iconName })
      }
    } else if (isObject(name) && name.render) {
      return name.render()
    }
  } else {
    return undefined
  }
}

CipMainIcon.props = {
  name: [String, Object]
}

export default CipMainIcon
