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

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

Issue 999873002: Move sky-*.sky into framework/elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: One missing Created 5 years, 9 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
« no previous file with comments | « sky/framework/sky-ink-splash.sky ('k') | sky/framework/sky-menu-divider.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!--
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
4 // found in the LICENSE file.
5 -->
6 <import src="sky-element.sky" />
7
8 <sky-element name="sky-input" attributes="value:string">
9 <template>
10 <style>
11 :host {
12 display: flex;
13 }
14 #control {
15 margin: 8px;
16 padding: 8px;
17 border-bottom: 1px solid #E7E7E7;
18 flex: 1;
19 align-self: center;
20 height: 1.2em;
21 white-space: nowrap;
22 overflow: hidden;
23 }
24 #control.focused {
25 padding-bottom: 7px;
26 border-bottom: 2px solid #009cf3;
27 }
28 </style>
29 <div id="control" contenteditable />
30 </template>
31 <script>
32 import "dart:sky";
33
34 // TODO(abarth): Connect to the mojo:keyboard service.
35
36 @Tagname('sky-input')
37 class SkyInput extends SkyElement {
38 Element _control;
39
40 static String _textForValue(String value) => value == null ? '' : value;
41
42 shadowRootReady() {
43 _control = shadowRoot.getElementById('control');
44 _control.setChild(new Text(_textForValue(getAttribute('text'))));
45 _control.addEventListener('focus', _handleFocus);
46 _control.addEventListener('blur', _handleBlur);
47 _control.addEventListener('keydown', _handleKeyDown);
48 }
49
50 String get text => _control == null ? null : _control.textContent;
51
52 void textChanged(String oldValue, String newValue) {
53 if (_control != null)
54 _control.setChild(new Text(_textForValue(newValue)));
55 }
56
57 void _handleKeyDown(KeyboardEvent event) {
58 // TODO(abarth): You can still get newlines if the user pastes them.
59 if (event.key == 0xD)
60 event.preventDefault();
61 }
62
63 void _handleFocus(_) {
64 if (_control)
65 _control.setAttribute('class', 'focused');
66 // TODO(abarth): Show the keyboard.
67 }
68
69 void _handleBlur(_) {
70 if (_control)
71 _control.removeAttribute('class');
72 // TODO(abarth): Hide the keyboard.
73 }
74 }
75
76 _init(script) => register(script, SkyInput);
77 </script>
78 </sky-element>
OLDNEW
« no previous file with comments | « sky/framework/sky-ink-splash.sky ('k') | sky/framework/sky-menu-divider.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698