import React from 'react'
import * as icons from '../../icons'

const Icon = ({ type, white, className = '', width = 36, style, onClick, ...props }) => {
  const DemioIcon = white ? icons[type + 'White'] : icons[type]
  if (!DemioIcon) {
    console.error(`DemioIcon "${type}" does not exist`)
    return null
  }
  return (
    <DemioIcon
      className={`demio-icon ${className}`}
      style={{
        fontSize: width,
        ...style
      }}
      onClick={onClick}
      {...props}
    />
  )
}

export default Icon
