Open History to see the last commit
1import { LitElement, html } from 'lit'
2import './todo-list-cache'
3import './todo-list-ui'
4β
5type Tab = 'ui-variables' | 'cache'
6β
7class ApproachTabs extends LitElement {
8 static properties = {
9 activeTab: { state: true },
10 }
11β
12 private activeTab: Tab = 'ui-variables'
13β
14 protected override createRenderRoot(): HTMLElement | DocumentFragment {
15 return this
16 }
17β
18 private tabStyle(tab: Tab) {
19 const isActive = this.activeTab === tab
20β
21 return `padding: 0.5rem 1rem; border: none; border-bottom: ${
22 isActive ? '2px solid #0070f3' : '2px solid transparent'
23 }; background: none; cursor: pointer; font-weight: ${
24 isActive ? 600 : 400
25 }; color: ${isActive ? '#0070f3' : '#555'}`
26 }
27β
28 render() {
29 return html`
30 <div>
31 <div
32 style="display: flex; border-bottom: 1px solid #ddd; margin-bottom: 1.5rem"
33 >
34 <button
35 type="button"
36 style=${this.tabStyle('ui-variables')}
37 @click=${() => (this.activeTab = 'ui-variables')}
38 >
39 Via UI Variables
40 </button>
41 <button
42 type="button"
43 style=${this.tabStyle('cache')}
44 @click=${() => (this.activeTab = 'cache')}
45 >
46 Via Cache Manipulation
47 </button>
48 </div>
49β
50 ${
51 this.activeTab === 'ui-variables'
52 ? html`<todo-list-ui></todo-list-ui>`
53 : html`<todo-list-cache></todo-list-cache>`
54 }
55 </div>
56 `
57 }
58}
59β
60customElements.define('approach-tabs', ApproachTabs)