license import { LitElement , html , css , property } from 'lit-element' ; import { connect , installRouter } from 'pwa-helpers' ; import { updateLocation } from '../actions/app.js' ; import { store , RootState } from '../store.js' ; import { sharedStyles } from './shared-styles.js' ; export class HnAppElement extends connect ( store ) ( LitElement ) { static get styles ( ) { return [ sharedStyles , css `
      [view] > * {
        display: none;
        padding: 0 16px;
      }
      [view=list] hn-list,
      [view=item] hn-item,
      [view=user] hn-user,
      [view=invalid-page] hn-invalid-page {
        display: block;
      }` ] ; } render ( ) { return html `
    <div view="${ this . _view }">
      <hn-list></hn-list>
      <hn-item></hn-item>
      <hn-user></hn-user>
      <hn-invalid-page></hn-invalid-page>
    </div>` ; } @ property ( ) private _view ? : string ; firstUpdated ( ) { installRouter ( ( location , event ) => { if ( event && event . type === 'click' ) { window . scrollTo ( 0 , 0 ) ; } store . dispatch ( updateLocation ( location ) ) ; } ) ; } stateChanged ( state ) { this . _view = state . app . view ; } } customElements . define ( 'hn-app' , HnAppElement ) ;