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

Side by Side Diff: sky/framework/sky-menu-item.sky

Issue 961873004: sky-element stocks demo: add splashes and highlights to menu items (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « sky/framework/sky-icon.sky ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-element.sky" /> 6 <import src="sky-element.sky" />
7 <import src="material-element.sky" />
7 <import src="sky-icon.sky" /> 8 <import src="sky-icon.sky" />
8 9
9 <sky-element attributes="icon:string"> 10 <sky-element attributes="icon:string">
10 <template> 11 <template>
11 <style> 12 <style>
12 :host { 13 :host {
13 display: flex; 14 display: flex;
14 align-items: center; 15 align-items: center;
15 height: 48px; 16 height: 48px;
16 -webkit-user-select: none; 17 -webkit-user-select: none;
17 } 18 }
19 #background {
20 display: flex;
21 align-items: center;
22 height: 100%;
23 flex: 1;
24 }
25 #background[highlight] {
26 background: rgba(153, 153, 153, 0.4);
27 }
18 sky-icon { 28 sky-icon {
19 padding: 0px 16px; 29 padding: 0px 16px;
20 } 30 }
21 #label { 31 #label {
22 font-family: 'Roboto Medium', 'Helvetica'; 32 font-family: 'Roboto Medium', 'Helvetica';
23 color: #212121; 33 color: #212121;
24 padding: 0px 16px; 34 padding: 0px 16px;
25 flex: 1; 35 flex: 1;
26 } 36 }
27 </style> 37 </style>
28 <sky-icon size="24" /> 38 <div id="background">
29 <div id="label"> 39 <sky-icon size="24" />
30 <content /> 40 <div id="label">
41 <content />
42 </div>
31 </div> 43 </div>
32 </template> 44 </template>
33 <script> 45 <script>
34 import "dart:sky"; 46 import "dart:sky";
35 47
36 @Tagname('sky-menu-item') 48 @Tagname('sky-menu-item')
37 class SkyMenuItem extends SkyElement { 49 class SkyMenuItem extends MaterialElement {
38 SkyIcon _icon; 50 SkyIcon _icon;
39 Element _label; 51 Element _label;
40 52
53 SkyMenuItem() {
54 addEventListener('pointerdown', _handlePointerDown);
55 addEventListener('pointerup', _handlePointerUp);
56 addEventListener('pointercancel', _handlePointerUp);
57 }
58
41 void shadowRootReady() { 59 void shadowRootReady() {
42 _icon = shadowRoot.querySelector('sky-icon'); 60 _icon = shadowRoot.querySelector('sky-icon');
43 _icon.type = "${icon}_grey600"; 61 _icon.type = "${icon}_grey600";
44 } 62 }
45 63
46 void iconChanged(String oldValue, String newValue) { 64 void iconChanged(String oldValue, String newValue) {
47 if (_icon != null) 65 if (_icon != null)
48 _icon.type = "${newValue}_grey600"; 66 _icon.type = "${newValue}_grey600";
49 } 67 }
68
69 void _handlePointerDown(Event event) {
70 shadowRoot.getElementById('background').setAttribute('highlight', '');
71 }
72
73 void _handlePointerUp(Event event) {
74 shadowRoot.getElementById('background').removeAttribute('highlight');
75 }
50 } 76 }
51 77
52 _init(script) => register(script, SkyMenuItem); 78 _init(script) => register(script, SkyMenuItem);
53 </script> 79 </script>
54 </sky-element> 80 </sky-element>
OLDNEW
« no previous file with comments | « sky/framework/sky-icon.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698