fix adding / removing content

pull/3094/head
yann300 6 years ago
parent 13e7544ee0
commit e80e58927b
  1. 6
      src/app/components/swap-panel-component.js
  2. 8
      src/app/components/vertical-icons-component.js

@ -27,13 +27,13 @@ class SwapPanelComponent {
} }
add (moduleName, content) { add (moduleName, content) {
this.contents[moduleName] = yo`<div id='${moduleName}Content' class=${css.plugItIn} >${content}</div>` this.contents[moduleName] = yo`<div class=${css.plugItIn} >${content}</div>`
this.view.appendChild(this.contents[moduleName]) this.view.appendChild(this.contents[moduleName])
} }
remove (moduleName) { remove (moduleName) {
var el = this.view.querySelector(`div#${moduleName}Content`) let el = this.contents[moduleName]
el.parentElement.removeChild(el) if (el) el.parentElement.removeChild(el)
} }
render () { render () {

@ -12,16 +12,18 @@ class VerticalIconComponent {
constructor () { constructor () {
this.event = new EventEmmitter() this.event = new EventEmmitter()
this.icons = {}
} }
addIcon (mod) { addIcon (mod) {
let self = this let self = this
this.view.appendChild(yo`<div id="${mod.name}Icon" class="${css.icon}" onclick=${(e) => { self._iconClick(mod.name) }} title=${mod.name}><img src="${mod.icon}" alt="${mod.name}" /></div>`) this.icons[mod.name] = yo`<div class="${css.icon}" onclick=${(e) => { self._iconClick(mod.name) }} title=${mod.name}><img src="${mod.icon}" alt="${mod.name}" /></div>`
this.view.appendChild(this.icons[mod.name])
} }
removeIcon (mod) { removeIcon (mod) {
var el = this.view.querySelector(`#${mod.name}Icon`) let el = this.icons[mod.name]
el.parentElement.removeChild(el) if (el) el.parentElement.removeChild(el)
} }
select (name) { select (name) {

Loading…
Cancel
Save