OLD | NEW |
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="shadow.sky" as="shadow" /> |
7 | 8 |
8 <sky-element attributes="highlight:boolean"> | 9 <sky-element attributes="primary:boolean, level:number"> |
9 <template> | 10 <template> |
10 <style> | 11 <style> |
11 :host { | 12 :host { |
12 display: inline-flex; | 13 display: inline-flex; |
13 border-radius: 4px; | 14 -webkit-user-select: none; |
14 justify-content: center; | 15 justify-content: center; |
15 align-items: center; | 16 align-items: center; |
16 border: 1px solid blue; | 17 height: 36px; |
17 -webkit-user-select: none; | 18 min-width: 64px; |
18 margin: 5px; | 19 padding: 0 8px; |
| 20 margin: 4px; |
| 21 border-radius: 2px; |
19 } | 22 } |
20 :host([highlight=true]) { | 23 :host([primary]) { |
21 background-color: orange; | 24 color: white; |
| 25 background-color: #0098f4; |
22 } | 26 } |
23 </style> | 27 </style> |
24 <content /> | 28 <content /> |
25 </template> | 29 </template> |
26 <script> | 30 <script> |
27 import "dart:sky"; | 31 import "dart:sky"; |
28 | 32 |
29 @Tagname('sky-button') | 33 @Tagname('sky-button') |
30 class SkyButton extends SkyElement { | 34 class SkyButton extends SkyElement { |
31 SkyButton() { | 35 SkyButton() { |
32 addEventListener('pointerdown', _handlePointerDown); | |
33 addEventListener('pointerup', _handlePointerUp); | |
34 addEventListener('pointercancel', _handlePointerCancel); | |
35 | |
36 tabIndex = 0; // Make focusable. | 36 tabIndex = 0; // Make focusable. |
37 } | 37 } |
38 | 38 |
39 void _handlePointerDown(_) { | 39 void shadowRootReady() { |
40 highlight = true; | 40 shadow.applyTo(shadowRoot); |
41 } | |
42 | |
43 void _handlePointerUp(_) { | |
44 highlight = false; | |
45 } | |
46 | |
47 void _handlePointerCancel(_) { | |
48 highlight = false; | |
49 } | 41 } |
50 } | 42 } |
51 | 43 |
52 _init(script) => register(script, SkyButton); | 44 _init(script) => register(script, SkyButton); |
53 </script> | 45 </script> |
54 </sky-element> | 46 </sky-element> |
OLD | NEW |