| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 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/framework/sky-element/sky-element.sky" as="SkyElement" /> | 6 <import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" /> |
| 7 | 7 |
| 8 <sky-element name="sky-button" attributes="highlight:boolean"> | 8 <sky-element |
| 9 name="sky-button" |
| 10 attributes="highlight:boolean" |
| 11 on-mousedown="handleMouseDown" |
| 12 on-mouseup="handleMouseUp" |
| 13 on-mouseout="handleMouseOut"> |
| 9 <template> | 14 <template> |
| 10 <style> | 15 <style> |
| 11 :host { | 16 :host { |
| 12 display: inline-flex; | 17 display: inline-flex; |
| 13 border-radius: 4px; | 18 border-radius: 4px; |
| 14 justify-content: center; | 19 justify-content: center; |
| 15 align-items: center; | 20 align-items: center; |
| 16 border: 1px solid blue; | 21 border: 1px solid blue; |
| 17 -webkit-user-select: none; | 22 -webkit-user-select: none; |
| 18 margin: 5px; | 23 margin: 5px; |
| 19 } | 24 } |
| 20 :host([highlight=true]) { | 25 :host([highlight=true]) { |
| 21 background-color: orange; | 26 background-color: orange; |
| 22 } | 27 } |
| 23 </style> | 28 </style> |
| 24 <content /> | 29 <content /> |
| 25 </template> | 30 </template> |
| 26 <script> | 31 <script> |
| 27 module.exports = class extends SkyElement { | 32 module.exports = class extends SkyElement { |
| 28 created() { | 33 created() { |
| 34 super.created(); |
| 35 |
| 29 this.tabIndex = 0; // Make focusable. | 36 this.tabIndex = 0; // Make focusable. |
| 30 | 37 } |
| 31 this.addEventListener('mousedown', function() { | 38 handleMouseDown() { |
| 32 this.highlight = true; | 39 this.highlight = true; |
| 33 }); | 40 } |
| 34 this.addEventListener('mouseup', function() { | 41 handleMouseUp() { |
| 35 this.highlight = false; | 42 this.highlight = false; |
| 36 }); | 43 } |
| 37 this.addEventListener('mouseout', function() { | 44 handleMouseOut() { |
| 38 this.highlight = false; | 45 this.highlight = false; |
| 39 }); | |
| 40 } | 46 } |
| 41 }.register(); | 47 }.register(); |
| 42 </script> | 48 </script> |
| 43 </sky-element> | 49 </sky-element> |
| OLD | NEW |