OLD | NEW |
1 <!-- | 1 <!-- |
2 // Copyright 2015 The Chromium Authors. All rights reserved. | 2 // Copyright 2015 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 --> | 5 --> |
| 6 <import src="/sky/framework/material-element.sky" /> |
6 <import src="/sky/framework/sky-element.sky" /> | 7 <import src="/sky/framework/sky-element.sky" /> |
7 <import src="stock-arrow.sky" /> | 8 <import src="stock-arrow.sky" /> |
8 | 9 |
9 <sky-element> | 10 <sky-element> |
10 <template> | 11 <template> |
11 <style> | 12 <style> |
12 :host { | 13 :host { |
13 // TODO(eseidel): Why does setting height here make this too big? | 14 // TODO(eseidel): Why does setting height here make this too big? |
14 // height: 48px; | 15 // height: 48px; |
15 max-height: 48px; | 16 max-height: 48px; |
(...skipping 23 matching lines...) Expand all Loading... |
39 </style> | 40 </style> |
40 <stock-arrow id="arrow" /> | 41 <stock-arrow id="arrow" /> |
41 <div id="ticker" /> | 42 <div id="ticker" /> |
42 <div id="last-sale" /> | 43 <div id="last-sale" /> |
43 <div id="change" /> | 44 <div id="change" /> |
44 </template> | 45 </template> |
45 <script> | 46 <script> |
46 import "dart:sky"; | 47 import "dart:sky"; |
47 | 48 |
48 @Tagname('stock') | 49 @Tagname('stock') |
49 class Stock extends SkyElement { | 50 class Stock extends MaterialElement { |
50 var model; // model.Stock | 51 var model; // model.Stock |
51 | 52 |
52 void shadowRootReady() { | 53 void shadowRootReady() { |
53 shadowRoot.getElementById('ticker').textContent = model.symbol; | 54 shadowRoot.getElementById('ticker').textContent = model.symbol; |
54 | 55 |
55 Element lastSale = shadowRoot.getElementById('last-sale'); | 56 Element lastSale = shadowRoot.getElementById('last-sale'); |
56 lastSale.textContent = "\$${model.lastSale.toStringAsFixed(2)}"; | 57 lastSale.textContent = "\$${model.lastSale.toStringAsFixed(2)}"; |
57 | 58 |
58 Element change = shadowRoot.getElementById('change'); | 59 Element change = shadowRoot.getElementById('change'); |
59 String changeString = "${model.percentChange.toStringAsFixed(2)}%"; | 60 String changeString = "${model.percentChange.toStringAsFixed(2)}%"; |
60 if (model.percentChange > 0) | 61 if (model.percentChange > 0) |
61 changeString = "+" + changeString; | 62 changeString = "+" + changeString; |
62 change.textContent = changeString; | 63 change.textContent = changeString; |
63 | 64 |
64 StockArrow arrow = shadowRoot.getElementById('arrow'); | 65 StockArrow arrow = shadowRoot.getElementById('arrow'); |
65 arrow.change = model.percentChange; | 66 arrow.change = model.percentChange; |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
69 _init(script) => register(script, Stock); | 70 _init(script) => register(script, Stock); |
70 </script> | 71 </script> |
71 </sky-element> | 72 </sky-element> |
OLD | NEW |