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

Side by Side Diff: sky/framework/sky-button/sky-button.sky

Issue 836923002: Automate reflected properties in SkyElement. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
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"> 8 <sky-element name="sky-button" attributes="highlight:boolean">
9 <template> 9 <template>
10 <style> 10 <style>
11 :host { 11 :host {
12 display: inline-flex; 12 display: inline-flex;
13 border-radius: 4px; 13 border-radius: 4px;
14 justify-content: center; 14 justify-content: center;
15 align-items: center; 15 align-items: center;
16 border: 1px solid blue; 16 border: 1px solid blue;
17 -webkit-user-select: none; 17 -webkit-user-select: none;
18 margin: 5px; 18 margin: 5px;
19 } 19 }
20 :host([highlight=true]) { 20 :host([highlight=true]) {
21 background-color: orange; 21 background-color: orange;
22 } 22 }
23 </style> 23 </style>
24 <content></content> 24 <content />
25 </template> 25 </template>
26 <script> 26 <script>
27 module.exports = class extends SkyElement { 27 module.exports = class extends SkyElement {
28 created() { 28 created() {
29 this.tabIndex = 0; // Make focusable. 29 this.tabIndex = 0; // Make focusable.
30 this.setHighlight(false);
31 30
32 this.addEventListener("mousedown", function() { 31 this.addEventListener("mousedown", function() {
33 this.setHighlight(true); 32 this.highlight = true;
34 }); 33 });
35 this.addEventListener("mouseup", function() { 34 this.addEventListener("mouseup", function() {
36 this.setHighlight(false); 35 this.highlight = false;
37 }); 36 });
38 this.addEventListener("mouseout", function() { 37 this.addEventListener("mouseout", function() {
39 this.setHighlight(false); 38 this.highlight = false;
40 }); 39 });
41 } 40 }
42 setHighlight(newValue) {
43 // Set both a property and an attribute to keep both parents happy.
44 this.setAttribute('highlight', newValue);
45 this.highlight = newValue;
46 }
47 }.register(); 41 }.register();
48 </script> 42 </script>
49 </sky-element> 43 </sky-element>
OLDNEW
« no previous file with comments | « no previous file | sky/framework/sky-checkbox/sky-checkbox.sky » ('j') | sky/framework/sky-element/sky-element.sky » ('J')

Powered by Google App Engine
This is Rietveld 408576698