diff --git a/navigationtab/lib/navigation-tab.ts b/navigationtab/lib/navigation-tab.ts index a940cefb0b..3099cdafa4 100644 --- a/navigationtab/lib/navigation-tab.ts +++ b/navigationtab/lib/navigation-tab.ts @@ -8,21 +8,22 @@ import '../../badge/badge.js'; import '../../focus/focus-ring.js'; import '../../ripple/ripple.js'; -import {html, PropertyValues, TemplateResult} from 'lit'; -import {property, query, state} from 'lit/decorators.js'; +import {html, LitElement, PropertyValues, TemplateResult} from 'lit'; +import {property, query, queryAsync, state} from 'lit/decorators.js'; import {ClassInfo, classMap} from 'lit/directives/class-map.js'; import {ifDefined} from 'lit/directives/if-defined.js'; +import {when} from 'lit/directives/when.js'; -import {ActionElement, BeginPressConfig, EndPressConfig} from '../../actionelement/action-element.js'; import {ariaProperty} from '../../decorators/aria-property.js'; import {pointerPress, shouldShowStrongFocus} from '../../focus/strong-focus.js'; +import {ripple} from '../../ripple/directive.js'; import {MdRipple} from '../../ripple/ripple.js'; import {NavigationTabState} from './state.js'; /** @soyCompatible */ -export class NavigationTab extends ActionElement implements NavigationTabState { - disabled = false; +export class NavigationTab extends LitElement implements NavigationTabState { + @property({type: Boolean}) disabled = false; @property({type: Boolean, reflect: true}) active = false; @property({type: Boolean}) hideInactiveLabel = false; @property() label?: string; @@ -30,6 +31,7 @@ export class NavigationTab extends ActionElement implements NavigationTabState { @property({type: Boolean}) showBadge = false; @state() protected showFocusRing = false; + @state() protected showRipple = false; // TODO(b/210730484): replace with @soyParam annotation @ariaProperty // tslint:disable-line:no-new-decorators @@ -38,7 +40,7 @@ export class NavigationTab extends ActionElement implements NavigationTabState { @query('button') buttonElement!: HTMLElement; - @query('md-ripple') ripple!: MdRipple; + @queryAsync('md-ripple') ripple!: Promise; /** @soyTemplate */ override render(): TemplateResult { @@ -52,13 +54,9 @@ export class NavigationTab extends ActionElement implements NavigationTabState { @focus="${this.handleFocus}" @blur="${this.handleBlur}" @pointerdown="${this.handlePointerDown}" - @pointerup="${this.handlePointerUp}" - @pointercancel="${this.handlePointerCancel}" - @pointerleave="${this.handlePointerLeave}" - @pointerenter="${this.handlePointerEnter}" @click="${this.handleClick}" - @contextmenu="${this.handleContextMenu}" - >${this.renderFocusRing()}${this.renderRipple()} + ${ripple(this.getRipple)}>${this.renderFocusRing()}${ + when(this.showRipple, this.renderRipple)}