OLD | NEW |
| (Empty) |
1 <!-- | |
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 | |
4 // found in the LICENSE file. | |
5 --> | |
6 <import src="/sky/framework/sky-button/sky-button.sky" as="SkyButton" /> | |
7 | |
8 <sky-element | |
9 name="sky-checkbox" | |
10 attributes="checked:boolean" | |
11 on-click="handleClick"> | |
12 <template> | |
13 <style> | |
14 :host { | |
15 display: flex; | |
16 justify-content: center; | |
17 align-items: center; | |
18 -webkit-user-select: none; | |
19 cursor: pointer; | |
20 width: 30px; | |
21 height: 30px; | |
22 } | |
23 #container { | |
24 border: solid 2px; | |
25 border-color: rgba(90, 90, 90, 0.25); | |
26 width: 10px; | |
27 height: 10px; | |
28 } | |
29 #container.highlight { | |
30 border-radius: 10px; | |
31 background-color: orange; | |
32 border-color: orange; | |
33 } | |
34 #check { | |
35 top: 0px; | |
36 left: 0px; | |
37 } | |
38 #check.checked { | |
39 transform: translate(2px, -15px) rotate(45deg); | |
40 width: 10px; | |
41 height: 20px; | |
42 border-style: solid; | |
43 border-top: none; | |
44 border-left: none; | |
45 border-right-width: 2px; | |
46 border-bottom-width: 2px; | |
47 border-color: #0f9d58; | |
48 } | |
49 </style> | |
50 <div id="container" class="{{ containerStyle }}"> | |
51 <div id="check" class="{{ checkStyle }}" /> | |
52 </div> | |
53 </template> | |
54 <script> | |
55 module.exports = class extends SkyButton { | |
56 created() { | |
57 super.created(); | |
58 | |
59 this.containerStyle = ''; | |
60 this.checkStyle = ''; | |
61 } | |
62 checkedChanged(oldValue, newValue) { | |
63 this.checkStyle = newValue ? 'checked' : ''; | |
64 } | |
65 highlightChanged(oldValue, newValue) { | |
66 this.containerStyle = newValue ? 'highlight' : ''; | |
67 } | |
68 handleClick() { | |
69 this.checked = !this.checked; | |
70 } | |
71 }.register(); | |
72 </script> | |
73 </sky-element> | |
OLD | NEW |