Using lit element 2,
I notice when I toggle in the tabs with mwc-tab-bar, the class="hide"
on <transactions-element class="hide"></transactions-element>
does persist.
Why is this?
render() {
return html`
<mwc-tab-bar @MDCTabBar:activated="${this._setCurrentTabView}">
<mwc-tab
data-el="transactions-element"
label="transactions"></mwc-tab>
<mwc-tab
data-el="foo-element"
label="foo"></mwc-tab>
</mwc-tab-bar>
<div class="main">
<main>${this._renderCurrentView()}</main>
</div>
`
}
_setCurrentTabView(e) {
const {index} = e.detail;
const tabs = this.renderRoot.querySelectorAll('mwc-tab');
const { el } = tabs[index].dataset;
this._fadeOutPage(this.currentView);
}
_renderCurrentView() {
switch (this.currentView) {
case 'transactions-element':
import('./transactions-element.js');
return html`<transactions-element></transactions-element>`;
case 'foo-element':
import('./foo-element.js');
return html`<foo-element></foo-element>`;
default:
import('./not-found-view.js');
return html`<not-found-view></not-found-view>`;
}
}
_fadeOutPage(el) {
const fromEl = this.renderRoot.querySelector(el);
fromEl.classList.add('hide');
}
}