Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Unified Diff: sky/examples/stocks/stock.sky

Issue 953593002: Show the last sale price in the stocks app (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: same Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/stocks/stock.sky
diff --git a/sky/examples/stocks/stock.sky b/sky/examples/stocks/stock.sky
index fcfc9fa02b641f688ef09d01935738f1ab1d3435..e147718e7b7dec7d37df7dccae02f4f613cdf1b2 100644
--- a/sky/examples/stocks/stock.sky
+++ b/sky/examples/stocks/stock.sky
@@ -5,7 +5,7 @@
-->
<import src="/sky/framework/sky-element.sky" />
-<sky-element attributes="ticker:string">
+<sky-element>
<template>
<style>
:host {
@@ -18,10 +18,13 @@
padding: 10px;
flex-grow: 1;
}
+ #last-sale {
+ padding: 10px;
+ }
#change {
padding: 10px;
border-radius: 5px;
- min-width: 60px;
+ min-width: 70px;
text-align: right;
}
.positive {
@@ -32,6 +35,7 @@
}
</style>
<div id="ticker" />
+ <div id="last-sale" />
<div id="change" />
</template>
<script>
@@ -42,11 +46,16 @@ class Stock extends SkyElement {
var model; // model.Stock
void shadowRootReady() {
- Element ticker = shadowRoot.getElementById('ticker');
- ticker.textContent = model.symbol;
+ shadowRoot.getElementById('ticker').textContent = model.symbol;
+
+ Element lastSale = shadowRoot.getElementById('last-sale');
+ lastSale.textContent = "\$${model.lastSale.toStringAsFixed(2)}";
Element change = shadowRoot.getElementById('change');
- change.textContent = "${model.percentChange.toStringAsFixed(2)}%";
+ String changeString = "${model.percentChange.toStringAsFixed(2)}%";
+ if (model.percentChange > 0)
+ changeString = "+" + changeString;
+ change.textContent = changeString;
change.classList.add((model.percentChange < 0) ? 'negative' : 'positive');
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698