Skip to content

Instantly share code, notes, and snippets.

@tonis2
Created May 14, 2018 12:54
Show Gist options
  • Select an option

  • Save tonis2/c7b30ab08ca3241ee217f8df2ecb4022 to your computer and use it in GitHub Desktop.

Select an option

Save tonis2/c7b30ab08ca3241ee217f8df2ecb4022 to your computer and use it in GitHub Desktop.
Dialog component
import { HTML } from "/modules/light-html/index.js";
class Component extends HTMLElement {
constructor() {
super();
this.hide = this.hide.bind(this);
}
hide() {
this.style.display = "none";
while (this.firstChild) {
this.removeChild(this.firstChild);
}
}
show(component) {
if (this.hasChildNodes()) {
this.hide();
}
this.style.display = "flex";
this.appendChild(component);
const close = HTML`<img onclick="${
this.hide
}" id="close-dialog" src="images/close.svg" title="close" />`;
close.render(this);
}
}
export default Component;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment