OLD | NEW |
---|---|
1 <!-- TODO(crbug.com/603217): Use i18n instead of string literals. Figure out | 1 <!-- TODO(crbug.com/603217): Use i18n instead of string literals. Figure out |
2 what i18n to use for keypad, ie, does 1 ABC make | 2 what i18n to use for keypad, ie, does 1 ABC make |
3 sense in every scenario? --> | 3 sense in every scenario? --> |
4 | 4 |
5 <link rel="import" href="chrome://resources/cr_elements/icons.html"> | 5 <link rel="import" href="chrome://resources/cr_elements/icons.html"> |
6 <link rel="import" href="chrome://resources/html/i18n_behavior.html"> | 6 <link rel="import" href="chrome://resources/html/i18n_behavior.html"> |
7 <link rel="import" href="chrome://resources/html/polymer.html"> | 7 <link rel="import" href="chrome://resources/html/polymer.html"> |
8 <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-butt on.html"> | 8 <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-butt on.html"> |
9 <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper -icon-button.html"> | |
9 <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html "> | 10 <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html "> |
10 <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.htm l"> | 11 <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.htm l"> |
11 <link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-i conset-svg.html"> | 12 <link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-i conset-svg.html"> |
12 | 13 |
13 <iron-iconset-svg name="pin-keyboard" size="24"> | 14 <iron-iconset-svg name="pin-keyboard" size="24"> |
14 <svg> | 15 <svg> |
15 <defs> | 16 <defs> |
16 <!-- | 17 <!-- |
17 Inlined from Polymer's iron-icons to avoid importing everything. | 18 Inlined from Polymer's iron-icons to avoid importing everything. |
18 See http://goo.gl/Y1OdAq for instructions on adding additional icons. | 19 See http://goo.gl/Y1OdAq for instructions on adding additional icons. |
19 --> | 20 --> |
20 <g id="forward"><path d="M12 8V4l8 8-8 8v-4H4V8z"></path></g> | 21 <g id="arrow-forward"> |
22 <path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"> | |
23 </path> | |
24 </g> | |
25 <g id="backspace"> | |
26 <path d="M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59. 89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-3 12.59L17.59 17 14 13.41 10.41 17 9 15. 59 12.59 12 9 8.41 10.41 7 14 10.59 17.59 7 19 8.41 15.41 12 19 15.59z"> | |
27 </g> | |
21 </defs> | 28 </defs> |
22 </svg> | 29 </svg> |
23 </iron-iconset-svg> | 30 </iron-iconset-svg> |
24 | 31 |
25 <dom-module id="pin-keyboard"> | 32 <dom-module id="pin-keyboard"> |
26 <template> | 33 <template> |
27 <style> | 34 <style> |
28 #root { | 35 #root { |
29 direction: ltr; | 36 direction: ltr; |
30 display: flex; | 37 display: flex; |
31 } | 38 } |
32 | 39 |
33 .input-non-pin { | 40 .input-non-pin { |
34 direction: rtl; | 41 direction: rtl; |
35 } | 42 } |
36 | 43 |
37 .row { | 44 .row { |
38 display: flex; | 45 display: flex; |
39 } | 46 } |
40 | 47 |
41 .digit-button { | 48 .digit-button { |
42 align-items: center; | 49 align-items: center; |
43 background: none; | 50 background: none; |
44 border-radius: 20px; | 51 border-radius: 100px; |
45 box-sizing: border-box; | 52 box-sizing: border-box; |
46 color: var(--paper-blue-grey-700); | 53 color: #000; |
47 display: flex; | 54 display: flex; |
48 flex-direction: column; | 55 flex-direction: column; |
49 font-size: 32px; | 56 font-size: 18px; |
50 height: 70px; | 57 height: 48px; |
51 justify-content: center; | 58 justify-content: center; |
52 margin: 0; | 59 margin: 0 6px; |
53 min-height: 70px; | 60 min-height: 48px; |
54 min-width: 70px; | 61 min-width: 48px; |
55 padding: 15px 20px; | 62 opacity: 0.87; |
56 width: 70px; | 63 padding: 15px; |
64 width: 48px; | |
57 } | 65 } |
58 | 66 |
59 .digit-button.clear-button { | 67 .bottom-row { |
60 display: block; | 68 margin-bottom: 6px; |
61 } | 69 } |
62 | 70 |
63 .digit-button.center-button { | 71 .top-row { |
64 margin: 0 30px; | 72 margin-top: 6px; |
73 } | |
74 | |
75 .digit-button.backspace-button { | |
76 opacity: var(--dark-primary-opacity); | |
77 } | |
78 | |
79 .digit-button.backspace-button[disabled] { | |
80 color: #000; | |
81 opacity: 0.26; | |
82 padding: 14px; | |
65 } | 83 } |
66 | 84 |
67 .digit-button.submit-button { | 85 .digit-button.submit-button { |
68 left: 20px; | 86 color: var(--google-blue-500); |
69 position: relative; | 87 height: 43px; |
88 left: 137px; | |
89 margin: 0; | |
90 min-height: 43px; | |
91 min-width: 43px; | |
92 opacity: var(--light-primary-opacity); | |
93 padding: 11.5px 10px; | |
94 position: absolute; | |
95 width: 43px; | |
96 } | |
97 | |
98 .digit-button.submit-button[disabled] { | |
99 color: #000; | |
100 opacity: 0.26; | |
101 } | |
102 | |
103 .digit-button.submit-button.error-show, | |
104 .digit-button.submit-button.error-show[disabled] { | |
105 color: var(--google-red-700); | |
106 opacity: 1; | |
70 } | 107 } |
71 | 108 |
72 .digit-button.submit-button.submit-button-hidden { | 109 .digit-button.submit-button.submit-button-hidden { |
73 display: none; | 110 display: none; |
74 } | 111 } |
75 | 112 |
76 .digit-button .icon-container { | |
77 background: var(--paper-grey-400); | |
78 border-radius: 100px; | |
79 height: 24px; | |
80 margin: auto; | |
81 width: 24px; | |
82 } | |
83 | |
84 .digit-button .icon-container.ready-background { | |
85 background: var(--paper-blue-800); | |
86 } | |
87 | |
88 .digit-button .icon-container .icon { | |
89 color: white; | |
90 display: block; | |
91 height: 16px; | |
92 left: 4px; | |
93 top: 4px; | |
94 width: 16px; | |
95 } | |
96 | |
97 .digit-button .icon-subheading { | |
98 color: var(--paper-grey-400); | |
99 font-size: 10px; | |
100 left: 0; | |
101 position: absolute; | |
102 text-align: center; | |
103 text-transform: capitalize; | |
104 top: 44px; | |
105 width: 100%; | |
106 } | |
107 | |
108 .digit-button inner-text { | 113 .digit-button inner-text { |
109 color: var(--paper-blue-grey-700); | 114 color: var(--paper-blue-grey-700); |
110 display: flex; | 115 display: flex; |
111 flex-direction: column; | 116 flex-direction: column; |
112 height: 52px; | 117 height: 52px; |
113 } | 118 } |
114 | 119 |
115 .first-row { | 120 #error-message { |
116 height: 64px; | 121 color: var(--google-red-700); |
117 min-height: 64px; | 122 font-size: 12px; |
118 padding: 28px 15px 12px 15px; | 123 height: 0; |
124 left: 0; | |
125 padding: 0 10px; | |
126 position: relative; | |
127 width: 160px; | |
128 z-index: 1; | |
129 } | |
130 | |
131 #error-message.error-rtl { | |
132 direction: rtl; | |
119 } | 133 } |
120 | 134 |
121 #pin-input { | 135 #pin-input { |
122 -webkit-text-security: disc; | 136 -webkit-text-security: disc; |
123 background-color: white; | 137 background-color: white; |
124 border: 0; | 138 border: 0; |
125 box-sizing: border-box; | 139 box-sizing: border-box; |
126 font-size: 18px; | 140 font-face: Roboto-Regular; |
127 height: 64px; | 141 font-size: 13px; |
128 left: 20px; | 142 height: 43px; |
143 left: 10px; | |
144 opacity: var(--dark-secondary-opacity); | |
129 outline: 0; | 145 outline: 0; |
130 padding: 28px 3px 12px 3px; | |
131 position: relative; | 146 position: relative; |
147 text-color: #000; | |
148 width: 127px; | |
149 } | |
150 | |
151 #pin-input.has-content { | |
152 opacity: var(--dark-primary-opacity); | |
153 } | |
154 | |
155 #pin-input.submit-button-hidden { | |
156 left: 0; | |
157 text-align: center; | |
132 width: 180px; | 158 width: 180px; |
133 } | 159 } |
134 | 160 |
135 #pin-input.submit-button-hidden { | 161 hr { |
136 border-bottom: 2px; | 162 border: 0; |
137 border-bottom-style: solid; | 163 border-bottom: 1px solid #000; |
138 text-align: center; | 164 left: 10px; |
139 width: 230px; | 165 margin: 0; |
166 opacity: 0.14; | |
167 position: relative; | |
168 width: 160px; | |
140 } | 169 } |
141 | 170 |
142 #pin-input[type=number]::-webkit-inner-spin-button, | 171 #pin-input[type=number]::-webkit-inner-spin-button, |
143 #pin-input[type=number]::-webkit-outer-spin-button { | 172 #pin-input[type=number]::-webkit-outer-spin-button { |
144 -webkit-appearance: none; | 173 -webkit-appearance: none; |
145 margin: 0; | 174 margin: 0; |
146 } | 175 } |
147 | 176 |
148 /* Ensure that all children of paper-button do not consume events. This | 177 /* Ensure that all children of paper-button do not consume events. This |
149 * simplifies the event handler code. */ | 178 * simplifies the event handler code. */ |
150 paper-button * { | 179 paper-button * { |
151 pointer-events: none; | 180 pointer-events: none; |
152 } | 181 } |
153 </style> | 182 </style> |
154 | 183 |
155 <div id="root"> | 184 <div id="root"> |
156 <div id="container-constrained-width"> | 185 <div id="container-constrained-width"> |
157 <div class="row"> | 186 <div class="row"> |
158 <input id="pin-input" type="[[getInputType_(enablePassword)]]" | 187 <input id="pin-input" type="[[getInputType_(enablePassword)]]" |
159 class$="[[getInputClass_(value)]] | 188 class$="[[getInputClass_(value)]] |
160 [[getSubmitHiddenClass_(enableSubmitButton)]]" | 189 [[getSubmitClass_(enableSubmitButton)]] |
190 [[getContentClass_(value)]]" | |
161 placeholder="[[getInputPlaceholder_(enablePassword)]]" | 191 placeholder="[[getInputPlaceholder_(enablePassword)]]" |
162 value="{{value::input}}" | 192 value="{{value::input}}" |
163 on-keydown="onInputKeyDown_"></input> | 193 on-keydown="onInputKeyDown_"></input> |
164 <paper-button class$="digit-button first-row submit-button | 194 <paper-icon-button icon="pin-keyboard:arrow-forward" |
165 [[getSubmitHiddenClass_(enableSubmitButton)]]" | 195 class$="digit-button submit-button |
166 on-tap="firePinSubmitEvent_"> | 196 [[getSubmitClass_(enableSubmitButton)]] |
167 <div class$="icon-container [[getSubmitClass_(value)]]"> | 197 [[getErrorClass_(errorMessage)]]" |
168 <iron-icon class="icon" icon="pin-keyboard:forward"><iron-icon> | 198 disabled="[[!hasInput_(value)]]" |
169 </div> | 199 on-tap="firePinSubmitEvent_"> |
170 </paper-button> | 200 </paper-icon-button> |
171 </div> | 201 </div> |
172 | 202 <hr> |
173 <div class="row keyboard"> | 203 <template is="dom-if" if="[[hasErrorMessage_(errorMessage)]]"> |
204 <div id="error-message" class$="[getErrorDirection_]"> | |
jdufault
2016/08/22 20:56:39
[[getErrorDirection_()]]
sammiequon
2016/08/23 17:30:18
Done.
| |
205 [[errorMessage]] | |
jdufault
2016/08/22 20:56:40
Please also add support for warnings. I'd rename e
sammiequon
2016/08/23 17:30:18
Done.
| |
206 </div> | |
207 </template> | |
208 <div class="row keyboard top-row"> | |
174 <paper-button class="digit-button" on-tap="onNumberTap_" value="1"> | 209 <paper-button class="digit-button" on-tap="onNumberTap_" value="1"> |
175 <inner-text>$i18n{pinKeyboard1}</inner-text> | 210 <inner-text>$i18n{pinKeyboard1}</inner-text> |
176 </paper-button> | 211 </paper-button> |
177 <paper-button class="digit-button center-button" on-tap="onNumberTap_" | 212 <paper-button class="digit-button" on-tap="onNumberTap_" value="2"> |
178 value="2"> | |
179 <inner-text>$i18n{pinKeyboard2}</inner-text> | 213 <inner-text>$i18n{pinKeyboard2}</inner-text> |
180 </paper-button> | 214 </paper-button> |
181 <paper-button class="digit-button" on-tap="onNumberTap_" value="3"> | 215 <paper-button class="digit-button" on-tap="onNumberTap_" value="3"> |
182 <inner-text>$i18n{pinKeyboard3}</inner-text> | 216 <inner-text>$i18n{pinKeyboard3}</inner-text> |
183 </paper-button> | 217 </paper-button> |
184 </div> | 218 </div> |
185 <div class="row keyboard"> | 219 <div class="row keyboard"> |
186 <paper-button class="digit-button" on-tap="onNumberTap_" value="4"> | 220 <paper-button class="digit-button" on-tap="onNumberTap_" value="4"> |
187 <inner-text>$i18n{pinKeyboard4}</inner-text> | 221 <inner-text>$i18n{pinKeyboard4}</inner-text> |
188 </paper-button> | 222 </paper-button> |
189 <paper-button class="digit-button center-button" on-tap="onNumberTap_" | 223 <paper-button class="digit-button" on-tap="onNumberTap_" value="5"> |
190 value="5"> | |
191 <inner-text>$i18n{pinKeyboard5}</inner-text> | 224 <inner-text>$i18n{pinKeyboard5}</inner-text> |
192 </paper-button> | 225 </paper-button> |
193 <paper-button class="digit-button" on-tap="onNumberTap_" value="6"> | 226 <paper-button class="digit-button" on-tap="onNumberTap_" value="6"> |
194 <inner-text>$i18n{pinKeyboard6}</inner-text> | 227 <inner-text>$i18n{pinKeyboard6}</inner-text> |
195 </paper-button> | 228 </paper-button> |
196 </div> | 229 </div> |
197 <div class="row keyboard"> | 230 <div class="row keyboard"> |
198 <paper-button class="digit-button" on-tap="onNumberTap_" value="7"> | 231 <paper-button class="digit-button" on-tap="onNumberTap_" value="7"> |
199 <inner-text>$i18n{pinKeyboard7}</inner-text> | 232 <inner-text>$i18n{pinKeyboard7}</inner-text> |
200 </paper-button> | 233 </paper-button> |
201 <paper-button class="digit-button center-button" on-tap="onNumberTap_" | 234 <paper-button class="digit-button" on-tap="onNumberTap_" value="8"> |
202 value="8"> | |
203 <inner-text>$i18n{pinKeyboard8}</inner-text> | 235 <inner-text>$i18n{pinKeyboard8}</inner-text> |
204 </paper-button> | 236 </paper-button> |
205 <paper-button class="digit-button" on-tap="onNumberTap_" value="9"> | 237 <paper-button class="digit-button" on-tap="onNumberTap_" value="9"> |
206 <inner-text>$i18n{pinKeyboard9}</inner-text> | 238 <inner-text>$i18n{pinKeyboard9}</inner-text> |
207 </paper-button> | 239 </paper-button> |
208 </div> | 240 </div> |
209 <div class="row keyboard"> | 241 <div class="row keyboard bottom-row"> |
210 <div class="digit-button"></div> | 242 <div class="digit-button"></div> |
211 <paper-button class="digit-button center-button" on-tap="onNumberTap_" | 243 <paper-button class="digit-button" on-tap="onNumberTap_" value="0"> |
212 value="0"> | |
213 <inner-text>$i18n{pinKeyboard0}</inner-text> | 244 <inner-text>$i18n{pinKeyboard0}</inner-text> |
214 </paper-button> | 245 </paper-button> |
215 <paper-button class="digit-button clear-button" on-tap="onPinClear_"> | 246 <paper-icon-button class="digit-button backspace-button" |
216 <div class="icon-container"> | 247 disabled="[[!hasInput_(value)]]" |
217 <iron-icon class="icon" icon="cr:clear"><iron-icon> | 248 on-tap="onPinClear_" icon="pin-keyboard:backspace"> |
218 </div> | 249 </paper-icon-button> |
219 <inner-text class="icon-subheading"> | |
220 $i18n{pinKeyboardClear} | |
221 </inner-text> | |
222 </paper-button> | |
223 </div> | 250 </div> |
224 </div> | 251 </div> |
225 </div> | 252 </div> |
226 </template> | 253 </template> |
227 <script src="pin_keyboard.js"></script> | 254 <script src="pin_keyboard.js"></script> |
228 </dom-module> | 255 </dom-module> |
OLD | NEW |