Last active
May 17, 2018 12:05
-
-
Save robdodson/d05a9404ac2530b5019d63e07f22e2d6 to your computer and use it in GitHub Desktop.
This file contains 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="my-icons.html"> | |
<dom-module id="my-app"> | |
<template> | |
<style> | |
:host { | |
--app-primary-color: #4285f4; | |
--app-secondary-color: black; | |
display: block; | |
} | |
app-header { | |
color: #fff; | |
background-color: var(--app-primary-color); | |
} | |
app-header paper-icon-button { | |
--paper-icon-button-ink-color: white; | |
} | |
.drawer-list { | |
margin: 0 20px; | |
} | |
.drawer-list a { | |
display: block; | |
padding: 0 16px; | |
text-decoration: none; | |
color: var(--app-secondary-color); | |
line-height: 40px; | |
} | |
.drawer-list a.iron-selected { | |
color: black; | |
font-weight: bold; | |
} | |
</style> | |
<app-location route="{{route}}"></app-location> | |
<app-route | |
route="{{route}}" | |
pattern="/:page" | |
data="{{routeData}}" | |
tail="{{subroute}}"></app-route> | |
<app-drawer-layout fullbleed> | |
<!-- Drawer content --> | |
<app-drawer> | |
<app-toolbar>Menu</app-toolbar> | |
<iron-selector selected="[[page]]" attr-for-selected="name" class="drawer-list" role="navigation"> | |
<a name="view1" href="/view1">View One</a> | |
<a name="view2" href="/view2">View Two</a> | |
<a name="view3" href="/view3">View Three</a> | |
</iron-selector> | |
</app-drawer> | |
<!-- Main content --> | |
<app-header-layout has-scrolling-region> | |
<app-header condenses reveals effects="waterfall"> | |
<app-toolbar> | |
<paper-icon-button icon="menu" drawer-toggle></paper-icon-button> | |
<div main-title>My App</div> | |
</app-toolbar> | |
</app-header> | |
<iron-pages | |
selected="[[page]]" | |
attr-for-selected="name" | |
fallback-selection="view404" | |
role="main"> | |
<my-view1 name="view1"></my-view1> | |
<my-view2 name="view2"></my-view2> | |
<my-view3 name="view3"></my-view3> | |
<my-view404 name="view404"></my-view404> | |
</iron-pages> | |
</app-header-layout> | |
</app-drawer-layout> | |
<paper-dialog id="dialog" modal> | |
<h2>Header</h2> | |
<div class="buttons"> | |
<button dialog-confirm autofocus>Accept</button> | |
</div> | |
</paper-dialog> | |
</template> | |
<script> | |
Polymer({ | |
is: 'my-app', | |
listeners: { | |
'open-dialog': 'handleOpenDialog' | |
}, | |
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'; | |
}, | |
handleOpenDialog: function() { | |
this.$.dialog.open(); | |
} | |
}); | |
</script> | |
</dom-module> |
This file contains 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/paper-dialog/paper-dialog.html"> | |
<link rel="import" href="shared-styles.html"> | |
<dom-module id="my-view1"> | |
<template> | |
<style include="shared-styles"> | |
:host { | |
display: block; | |
padding: 10px; | |
} | |
</style> | |
<div class="card"> | |
<div class="circle">1</div> | |
<h1>View One</h1> | |
<p>Ut labores minimum atomorum pro. Laudem tibique ut has. | |
<p>Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea.Lorem ipsum dolor sit amet, per | |
in nusquam nominavi periculis, sit elit oportere ea.Cu mei vide viris gloriatur, at populo eripuit sit.</p> | |
<button on-tap="open">Open dialog</button> | |
</div> | |
</template> | |
<script> | |
Polymer({ | |
is: 'my-view1', | |
open: function() { | |
this.fire('open-dialog'); | |
} | |
}); | |
</script> | |
</dom-module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment