Created
May 14, 2018 12:54
-
-
Save tonis2/c7b30ab08ca3241ee217f8df2ecb4022 to your computer and use it in GitHub Desktop.
Dialog component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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