OLD | NEW |
(Empty) | |
| 1 <!-- |
| 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 |
| 4 // found in the LICENSE file. |
| 5 --> |
| 6 <import src="sky-element.sky" /> |
| 7 |
| 8 <sky-element attributes="type:string, size:number"> |
| 9 <template> |
| 10 <img /> |
| 11 </template> |
| 12 <script> |
| 13 import "dart:sky"; |
| 14 |
| 15 const String kAssetBase = '/sky/assets/material-design-icons'; |
| 16 |
| 17 @Tagname('sky-icon') |
| 18 class SkyIcon extends SkyElement { |
| 19 void shadowRootReady() { |
| 20 Element img = shadowRoot.firstElementChild; |
| 21 int intSize = size.floor(); |
| 22 img.style['height'] = '${intSize}px'; |
| 23 img.style['width'] = '${intSize}px'; |
| 24 List<String> parts = type.split('/'); |
| 25 String category = parts[0]; |
| 26 String subtype = parts[1]; |
| 27 img.src = '${kAssetBase}/${category}/2x_web/ic_${subtype}_${intSize}dp.png'; |
| 28 } |
| 29 } |
| 30 |
| 31 _init(script) => register(script, SkyIcon); |
| 32 </script> |
| 33 </sky-element> |
OLD | NEW |