all files / ui/ FontAwesomeIconProvider.js

52.94% Statements 9/17
25% Branches 2/8
60% Functions 3/5
52.94% Lines 9/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41            205× 205× 205× 1640× 1640× 1640×   1640× 1640×                                 1640×                  
import { forEach } from '../util'
import FontAwesomeIcon from './FontAwesomeIcon'
 
class FontAwesomeIconProvider {
 
  constructor(icons) {
    this.faMap = {}
    this.textMap = {}
    forEach(icons, function(config, name) {
      let faClass = config['fontawesome']
      Eif (faClass) {
        this.addFAIcon(name, faClass)
      }
      let text = config['text']
      Iif (text) {
        this.addTextIcon(name, text)
      }
    }.bind(this))
  }
 
  renderIcon($$, name) {
    let faClass = this.faMap[name]
    let text = this.textMap[name]
    if (faClass) {
      return $$(FontAwesomeIcon, { icon: faClass })
    } else if (text) {
      return text
    }
  }
 
  addFAIcon(name, faClass) {
    this.faMap[name] = faClass
  }
 
  addTextIcon(name, text) {
    this.textMap[name] = text
  }
}
 
export default FontAwesomeIconProvider