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

Unified Diff: sky/framework/sky-icon.sky

Issue 951823002: Update Sky widgets to have more material design (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 | « sky/framework/sky-checkbox.sky ('k') | sky/framework/sky-input.sky » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/sky-icon.sky
diff --git a/sky/framework/sky-icon.sky b/sky/framework/sky-icon.sky
index 5be01fea1526b0cb2bbd3af5829922d3249e7961..e526c8ca1df66b85318d3ecec94b1ee488b5988a 100644
--- a/sky/framework/sky-icon.sky
+++ b/sky/framework/sky-icon.sky
@@ -16,15 +16,37 @@ const String kAssetBase = '/sky/assets/material-design-icons';
@Tagname('sky-icon')
class SkyIcon extends SkyElement {
- void shadowRootReady() {
- Element img = shadowRoot.firstElementChild;
- int intSize = size.floor();
- img.style['height'] = '${intSize}px';
- img.style['width'] = '${intSize}px';
+ Element _img;
+
+ void _setSize(int size) {
+ _img.style['height'] = '${size}px';
+ _img.style['width'] = '${size}px';
+ }
+
+ void _setSrc(String type, int size) {
List<String> parts = type.split('/');
+ if (parts.length < 2)
+ return;
String category = parts[0];
String subtype = parts[1];
- img.src = '${kAssetBase}/${category}/2x_web/ic_${subtype}_${intSize}dp.png';
+ _img.src = '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png';
+ }
+
+ void shadowRootReady() {
+ _img = shadowRoot.firstElementChild;
+ int size = this.size.floor();
+ _setSize(size);
+ _setSrc(type, size);
+ }
+
+ void typeChanged(String oldValue, String newValue) {
+ if (_img != null)
+ _setSrc(newValue, size.floor());
+ }
+
+ void sizeChanged(double oldValue, double newValue) {
+ if (_img != null)
+ _setSize(newValue.floor());
}
}
« no previous file with comments | « sky/framework/sky-checkbox.sky ('k') | sky/framework/sky-input.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698