Created
December 15, 2021 06:34
-
-
Save tjmonsi/f5f455e816af59c787cc876a701bc913 to your computer and use it in GitHub Desktop.
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 { LitElement, html } from 'lit'; | |
| export class Component extends LitElement { | |
| static properties = { | |
| isLoggedIn: { | |
| type: Boolean | |
| } | |
| } | |
| constructor () { | |
| super(); | |
| this._boundSetLoggedIn = this.setLoggedIn.bind(this) // this === Component | |
| } | |
| setLoggedIn (value) { | |
| // "this" is equal to Component Class because we have bounded it | |
| this.isLoggedIn = !!value; | |
| } | |
| createRenderRoot () { | |
| return this; | |
| } | |
| render () { | |
| return html` | |
| <header class="header"> | |
| <h1> | |
| <a href="/">My Blog</a> | |
| </h1> | |
| <nav> | |
| ${this.isLoggedIn | |
| ? html`<a href="/logout">Logout</a>` | |
| : html`<a href="/login">Login</a>`} | |
| </nav> | |
| </header> | |
| ` | |
| } | |
| } | |
| window.customElements.define('web-header', Component); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment