OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> |
| 10 |
| 11 <!doctype html> |
| 12 <html> |
| 13 <head> |
| 14 |
| 15 <title>iron-list demo</title> |
| 16 |
| 17 <meta charset="utf-8"> |
| 18 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-
scale=1, user-scalable=yes"> |
| 19 <meta name="mobile-web-app-capable" content="yes"> |
| 20 <meta name="apple-mobile-web-app-capable" content="yes"> |
| 21 |
| 22 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 23 |
| 24 <link rel="import" href="../../polymer/polymer.html"> |
| 25 <link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> |
| 26 <link rel="import" href="../iron-list.html"> |
| 27 |
| 28 <link rel="import" href="../../iron-ajax/iron-ajax.html"> |
| 29 <link rel="import" href="../../iron-icon/iron-icon.html"> |
| 30 <link rel="import" href="../../iron-icons/iron-icons.html"> |
| 31 <link rel="import" href="../../paper-toolbar/paper-toolbar.html"> |
| 32 |
| 33 <dom-module id="x-app"> |
| 34 |
| 35 <style> |
| 36 |
| 37 :host { |
| 38 @apply(--layout-fit); |
| 39 @apply(--layout-vertical); |
| 40 |
| 41 display: block; |
| 42 font-family: sans-serif; |
| 43 } |
| 44 |
| 45 .toolbar { |
| 46 background: #E91E63; |
| 47 box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26); |
| 48 color: white; |
| 49 } |
| 50 |
| 51 #list { |
| 52 @apply(--layout-flex); |
| 53 } |
| 54 |
| 55 .item { |
| 56 padding: 16px; |
| 57 @apply(--layout-horizontal); |
| 58 } |
| 59 |
| 60 .avatar { |
| 61 height: 40px; |
| 62 width: 40px; |
| 63 border-radius: 20px; |
| 64 box-sizing: border-box; |
| 65 border: 1px solid #DDD; |
| 66 background-color: #DDD; |
| 67 } |
| 68 |
| 69 .pad { |
| 70 padding: 0 16px; |
| 71 @apply(--layout-flex); |
| 72 @apply(--layout-vertical); |
| 73 } |
| 74 |
| 75 .primary { |
| 76 font-size: 16px; |
| 77 } |
| 78 |
| 79 .secondary { |
| 80 font-size: 14px; |
| 81 } |
| 82 |
| 83 .dim { |
| 84 color: gray; |
| 85 } |
| 86 |
| 87 .border { |
| 88 margin-left: 72px; |
| 89 border-bottom: 1px solid #DDD; |
| 90 } |
| 91 |
| 92 iron-icon { |
| 93 width: 24px; |
| 94 height: 24px; |
| 95 } |
| 96 |
| 97 </style> |
| 98 |
| 99 <template> |
| 100 |
| 101 <iron-ajax url="data/contacts.json" last-response="{{data}}" auto></iron-a
jax> |
| 102 |
| 103 <paper-toolbar class="toolbar"> |
| 104 <div>Inbox</div> |
| 105 </paper-toolbar> |
| 106 |
| 107 <iron-list id="list" items="[[data]]" as="item"> |
| 108 <template> |
| 109 <div> |
| 110 <div class="item"> |
| 111 <img class="avatar" src="[[item.image]]"> |
| 112 <div class="pad"> |
| 113 <div class="primary"> |
| 114 <span>[[index]]</span> |
| 115 <span>[[item.name]]</span> |
| 116 </div> |
| 117 <div class="secondary">[[item.shortText]]</div> |
| 118 <div class="secondary dim">[[item.longText]]</div> |
| 119 </div> |
| 120 <iron-icon icon$="[[iconForItem(item)]]"></iron-icon> |
| 121 </div> |
| 122 <div class="border"></div> |
| 123 </div> |
| 124 </template> |
| 125 </iron-list> |
| 126 |
| 127 </template> |
| 128 </dom-module> |
| 129 |
| 130 <script> |
| 131 |
| 132 HTMLImports.whenReady(function() { |
| 133 |
| 134 Polymer({ |
| 135 |
| 136 is: 'x-app', |
| 137 |
| 138 iconForItem: function(item) { |
| 139 return item ? (item.integer < 50 ? 'star-border' : 'star') : ''; |
| 140 } |
| 141 |
| 142 }); |
| 143 |
| 144 }); |
| 145 |
| 146 </script> |
| 147 |
| 148 </head> |
| 149 <body unresolved> |
| 150 |
| 151 <x-app></x-app> |
| 152 |
| 153 </body> |
| 154 </html> |
OLD | NEW |