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