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 | 7 |
8 <sky-element name="sky-input" attributes="value:string"> | 8 <sky-element name="sky-input" attributes="value:string"> |
9 <template> | 9 <template> |
10 <style> | 10 <style> |
11 :host { | 11 :host { |
12 display: flex; | 12 display: flex; |
13 border: 1px solid blue; | |
14 margin: 5px; | |
15 padding: 4px; | |
16 } | 13 } |
17 #control { | 14 #control { |
| 15 margin: 8px; |
| 16 padding: 8px; |
| 17 border-bottom: 1px solid #E7E7E7; |
18 flex: 1; | 18 flex: 1; |
19 align-self: center; | 19 align-self: center; |
20 height: 1.2em; | 20 height: 1.2em; |
21 white-space: nowrap; | 21 white-space: nowrap; |
22 overflow: hidden; | 22 overflow: hidden; |
23 } | 23 } |
| 24 #control.focused { |
| 25 padding-bottom: 7px; |
| 26 border-bottom: 2px solid #009cf3; |
| 27 } |
24 </style> | 28 </style> |
25 <div id="control" contenteditable /> | 29 <div id="control" contenteditable /> |
26 </template> | 30 </template> |
27 <script> | 31 <script> |
28 import "dart:sky"; | 32 import "dart:sky"; |
29 | 33 |
30 // TODO(abarth): Connect to the mojo:keyboard service. | 34 // TODO(abarth): Connect to the mojo:keyboard service. |
31 | 35 |
32 @Tagname('sky-input') | 36 @Tagname('sky-input') |
33 class SkyInput extends SkyElement { | 37 class SkyInput extends SkyElement { |
(...skipping 16 matching lines...) Expand all Loading... |
50 _control.setChild(new Text(_textForValue(newValue))); | 54 _control.setChild(new Text(_textForValue(newValue))); |
51 } | 55 } |
52 | 56 |
53 void _handleKeyDown(KeyboardEvent event) { | 57 void _handleKeyDown(KeyboardEvent event) { |
54 // TODO(abarth): You can still get newlines if the user pastes them. | 58 // TODO(abarth): You can still get newlines if the user pastes them. |
55 if (event.key == 0xD) | 59 if (event.key == 0xD) |
56 event.preventDefault(); | 60 event.preventDefault(); |
57 } | 61 } |
58 | 62 |
59 void _handleFocus(_) { | 63 void _handleFocus(_) { |
| 64 if (_control) |
| 65 _control.setAttribute('class', 'focused'); |
60 // TODO(abarth): Show the keyboard. | 66 // TODO(abarth): Show the keyboard. |
61 } | 67 } |
62 | 68 |
63 void _handleBlur(_) { | 69 void _handleBlur(_) { |
| 70 if (_control) |
| 71 _control.removeAttribute('class'); |
64 // TODO(abarth): Hide the keyboard. | 72 // TODO(abarth): Hide the keyboard. |
65 } | 73 } |
66 } | 74 } |
67 | 75 |
68 _init(script) => register(script, SkyInput); | 76 _init(script) => register(script, SkyInput); |
69 </script> | 77 </script> |
70 </sky-element> | 78 </sky-element> |
OLD | NEW |