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

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

Issue 947383002: Add <sky-icon> to access material design widgets (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/examples/stocks/stocks.sky ('k') | no next file » | 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
new file mode 100644
index 0000000000000000000000000000000000000000..5be01fea1526b0cb2bbd3af5829922d3249e7961
--- /dev/null
+++ b/sky/framework/sky-icon.sky
@@ -0,0 +1,33 @@
+<!--
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+-->
+<import src="sky-element.sky" />
+
+<sky-element attributes="type:string, size:number">
+<template>
+ <img />
+</template>
+<script>
+import "dart:sky";
+
+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';
+ List<String> parts = type.split('/');
+ String category = parts[0];
+ String subtype = parts[1];
+ img.src = '${kAssetBase}/${category}/2x_web/ic_${subtype}_${intSize}dp.png';
+ }
+}
+
+_init(script) => register(script, SkyIcon);
+</script>
+</sky-element>
« no previous file with comments | « sky/examples/stocks/stocks.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698