Created
October 11, 2016 10:21
-
-
Save osvaldoM/0d6c94ce3382f671fbc62ba271377671 to your computer and use it in GitHub Desktop.
tabs+toolbar
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
<!-- | |
@license | |
Copyright (c) 2016 The Polymer Project Authors. All rights reserved. | |
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | |
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | |
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt | |
Code distributed by Google as part of the polymer project is also | |
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt | |
--> | |
<link rel="import" href="../bower_components/polymer/polymer.html"> | |
<link rel="import" href="../bower_components/app-layout/app-drawer/app-drawer.html"> | |
<link rel="import" href="../bower_components/app-layout/app-drawer-layout/app-drawer-layout.html"> | |
<link rel="import" href="../bower_components/app-layout/app-header/app-header.html"> | |
<link rel="import" href="../bower_components/app-layout/app-header-layout/app-header-layout.html"> | |
<link rel="import" href="../bower_components/app-layout/app-scroll-effects/app-scroll-effects.html"> | |
<link rel="import" href="../bower_components/app-layout/app-toolbar/app-toolbar.html"> | |
<link rel="import" href="../bower_components/app-route/app-location.html"> | |
<link rel="import" href="../bower_components/app-route/app-route.html"> | |
<link rel="import" href="../bower_components/iron-pages/iron-pages.html"> | |
<link rel="import" href="../bower_components/iron-selector/iron-selector.html"> | |
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html"> | |
<link rel="import" href="../bower_components/paper-toolbar/paper-toolbar.html"> | |
<link rel="import" href="../bower_components/paper-tabs/paper-tabs.html"> | |
<link rel="import" href="my-icons.html"> | |
<dom-module id="my-app"> | |
<template> | |
<style> | |
paper-toolbar { | |
--paper-toolbar-background: var(--paper-blue-900); | |
} | |
.self-end { | |
/* This mixin (from iron-flex-layout) aligns the tabs to the | |
bottom of the toolbar. */ | |
@apply(--layout-self-end); | |
} | |
</style> | |
<app-location route="{{route}}"></app-location> | |
<app-route | |
route="{{route}}" | |
pattern="/:page" | |
data="{{routeData}}" | |
tail="{{subroute}}"></app-route> | |
<paper-toolbar class="tall"> | |
<paper-icon-button icon="menu"></paper-icon-button> | |
<span class="title">Title</span> | |
<paper-icon-button icon="refresh"></paper-icon-button> | |
<paper-icon-button icon="add">+</paper-icon-button> | |
<paper-tabs selected="0" class="bottom self-end" style="width: 300px;"> | |
<paper-tab>ITEM ONE</paper-tab> | |
<paper-tab>ITEM TWO</paper-tab> | |
</paper-tabs> | |
</paper-toolbar> | |
</template> | |
<script> | |
Polymer({ | |
is: 'my-app', | |
properties: { | |
page: { | |
type: String, | |
reflectToAttribute: true, | |
observer: '_pageChanged' | |
} | |
}, | |
observers: [ | |
'_routePageChanged(routeData.page)' | |
], | |
_routePageChanged: function(page) { | |
this.page = page || 'view1'; | |
}, | |
_pageChanged: function(page) { | |
// Load page import on demand. Show 404 page if fails | |
var resolvedPageUrl = this.resolveUrl('my-' + page + '.html'); | |
this.importHref(resolvedPageUrl, null, this._showPage404, true); | |
}, | |
_showPage404: function() { | |
this.page = 'view404'; | |
} | |
}); | |
</script> | |
</dom-module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment