16
16
17
17
< title > paper-input demo</ title >
18
18
19
- < script src ="../../webcomponentsjs/webcomponents-lite.js "> </ script >
20
-
21
- < link rel ="import " href ="../../iron-demo-helpers/demo-pages-shared-styles.html ">
22
- < link rel ="import " href ="../../iron-demo-helpers/demo-snippet.html ">
23
- < link rel ="import " href ="../../iron-icon/iron-icon.html ">
24
- < link rel ="import " href ="../../iron-icons/iron-icons.html ">
25
- < link rel ="import " href ="../../iron-input/iron-input.html ">
26
- < link rel ="import " href ="../../paper-icon-button/paper-icon-button.html ">
27
- < link rel ="import " href ="../../paper-styles/color.html ">
28
- < link rel ="import " href ="../paper-input-container.html ">
29
- < link rel ="import " href ="../paper-input-error.html ">
30
- < link rel ="import " href ="../paper-input.html ">
31
- < link rel ="import " href ="../paper-textarea.html ">
32
- < link rel ="import " href ="ssn-input.html ">
33
-
34
- < custom-style >
19
+ < script src ="../../../@webcomponents/webcomponentsjs/webcomponents-bundle.js "> </ script >
20
+
21
+ < script type ="module " src ="../../iron-demo-helpers/demo-pages-shared-styles.js "> </ script >
22
+ < script type ="module " src ="../../iron-demo-helpers/demo-snippet.js "> </ script >
23
+ < script type ="module " src ="../../iron-icon/iron-icon.js "> </ script >
24
+ < script type ="module " src ="../../iron-icons/iron-icons.js "> </ script >
25
+ < script type ="module " src ="../../iron-input/iron-input.js "> </ script >
26
+ < script type ="module " src ="../../paper-icon-button/paper-icon-button.js "> </ script >
27
+ < script type ="module " src ="../../paper-styles/color.js "> </ script >
28
+ < script type ="module " src ="../paper-input-container.js "> </ script >
29
+ < script type ="module " src ="../paper-input-error.js "> </ script >
30
+ < script type ="module " src ="../paper-input.js "> </ script >
31
+ < script type ="module " src ="../paper-textarea.js "> </ script >
32
+ < script type ="module " src ="./ssn-input.js "> </ script >
33
+
34
+ <!-- FIXME(polymer-modulizer):
35
+ These imperative modules that innerHTML your HTML are
36
+ a hacky way to be sure that any mixins in included style
37
+ modules are ready before any elements that reference them are
38
+ instantiated, otherwise the CSS @apply mixin polyfill won't be
39
+ able to expand the underlying CSS custom properties.
40
+ See: https://github.com/Polymer/polymer-modulizer/issues/154
41
+ -->
42
+ < script type ="module ">
43
+ const $_documentContainer = document . createElement ( 'template' ) ;
44
+
45
+ $_documentContainer . innerHTML = `<custom-style>
35
46
<style is="custom-style" include="demo-pages-shared-styles">
36
47
paper-input {
37
48
display: block;
69
80
display: inline-block;
70
81
}
71
82
</style>
72
- </ custom-style >
83
+ </custom-style>` ;
84
+
85
+ document . body . appendChild ( $_documentContainer . content ) ;
86
+ </ script >
73
87
</ head >
74
88
< body unresolved >
75
- < div class ="vertical-section-container centered ">
89
+ < script type ="module ">
90
+ const $_documentContainer = document . createElement ( 'template' ) ;
91
+
92
+ $_documentContainer . innerHTML = `<div class="vertical-section-container centered">
76
93
<h3>Inputs can have different types, and be disabled</h3>
77
94
<demo-snippet>
78
95
<template>
79
96
<paper-input label="text input"></paper-input>
80
97
<paper-input label="text input" value="pre-filled"></paper-input>
81
98
<paper-textarea label="autoresizing textarea input"></paper-textarea>
82
99
<paper-input label="password input" type="password"></paper-input>
83
- < paper-input label ="disabled input " disabled value ="batman "> </ paper-input >
100
+ <paper-input label="disabled input" disabled="" value="batman"></paper-input>
84
101
</template>
85
102
</demo-snippet>
86
103
87
104
<h3>Inputs can have character counters</h3>
88
105
<demo-snippet>
89
106
<template>
90
- < paper-input label ="simple character counter " char-counter > </ paper-input >
91
- < paper-input label ="input with at most 10 characters " char-counter maxlength ="10 "> </ paper-input >
107
+ <paper-input label="simple character counter" char-counter="" ></paper-input>
108
+ <paper-input label="input with at most 10 characters" char-counter="" maxlength="10"></paper-input>
92
109
</template>
93
110
</demo-snippet>
94
111
95
112
<h3>The label can have different floating states</h3>
96
113
<demo-snippet>
97
114
<template>
98
115
<paper-input label="this label floats after typing"></paper-input>
99
- < paper-input label ="this label is always floating " always-float-label > </ paper-input >
100
- < paper-input label ="this label never floats " no-label-float > </ paper-input >
101
- < paper-input label ="this label is always floating " always-float-label placeholder ="placeholder text "> </ paper-input >
116
+ <paper-input label="this label is always floating" always-float-label="" ></paper-input>
117
+ <paper-input label="this label never floats" no-label-float="" ></paper-input>
118
+ <paper-input label="this label is always floating" always-float-label="" placeholder="placeholder text"></paper-input>
102
119
</template>
103
120
</demo-snippet>
104
121
105
122
<h3>Inputs can validate automatically or on demand, and can have custom error messages</h3>
106
123
<demo-snippet>
107
124
<template>
108
- < paper-input label ="this input requires some text " required auto-validate error-message ="needs some text! "> </ paper-input >
109
- < paper-input label ="this input requires letters only " auto-validate pattern ="[a-zA-Z]* " error-message ="letters only! "> </ paper-input >
110
- < paper-input label ="this input requires letters only " auto-validate pattern ="[a-zA-Z]* " error-message ="letters only! " value ="pre-filled 123 "> </ paper-input >
111
- < paper-input label ="this input will only let you type letters " auto-validate allowed-pattern ="[a-zA-Z] "> </ paper-input >
112
- < paper-input id ="inputForValidation " required label ="this input is manually validated " pattern ="[a-zA-Z]* " error-message ="letters only! "> </ paper-input >
125
+ <paper-input label="this input requires some text" required="" auto-validate="" error-message="needs some text!"></paper-input>
126
+ <paper-input label="this input requires letters only" auto-validate="" pattern="[a-zA-Z]*" error-message="letters only!"></paper-input>
127
+ <paper-input label="this input requires letters only" auto-validate="" pattern="[a-zA-Z]*" error-message="letters only!" value="pre-filled 123"></paper-input>
128
+ <paper-input label="this input will only let you type letters" auto-validate="" allowed-pattern="[a-zA-Z]"></paper-input>
129
+ <paper-input id="inputForValidation" required="" label="this input is manually validated" pattern="[a-zA-Z]*" error-message="letters only!"></paper-input>
113
130
114
131
<button onclick="validate()">Validate!</button>
115
132
</template>
@@ -119,14 +136,13 @@ <h3>Inputs can have prefixes and suffixes</h3>
119
136
<demo-snippet class="horizontal">
120
137
<template>
121
138
<paper-input label="total" type="number">
122
- < div slot ="prefix "> $</ div >
139
+ <div slot="prefix">\ $</div>
123
140
</paper-input>
124
141
125
142
<paper-input label="username" id="inputWithButton">
126
143
<iron-icon icon="mail" slot="prefix"></iron-icon>
127
144
<div slot="suffix">@email.com</div>
128
- < paper-icon-button slot ="suffix " onclick ="clearInput() "
129
- icon ="clear " alt ="clear " title ="clear ">
145
+ <paper-icon-button slot="suffix" onclick="clearInput()" icon="clear" alt="clear" title="clear">
130
146
</paper-icon-button>
131
147
</paper-input>
132
148
</template>
@@ -135,7 +151,7 @@ <h3>Inputs can have prefixes and suffixes</h3>
135
151
<h3>Inputs can have custom logic</h3>
136
152
<demo-snippet>
137
153
<template>
138
- < paper-input-container always-float-label auto-validate attr-for-value ="value ">
154
+ <paper-input-container always-float-label="" auto-validate="" attr-for-value="value">
139
155
<label slot="label">Social Security Number</label>
140
156
<ssn-input class="paper-input-input" slot="input"></ssn-input>
141
157
<paper-input-error slot="add-on">SSN invalid!</paper-input-error>
@@ -214,24 +230,38 @@ <h3>Inputs can be completely restyled</h3>
214
230
</style>
215
231
</custom-style>
216
232
<div class="custom-parent">
217
- < paper-input class ="custom " label ="Name " value ="Batman " always-float-label >
233
+ <paper-input class="custom" label="Name" value="Batman" always-float-label="" >
218
234
</paper-input>
219
- < paper-input class ="custom " label ="Address (letters only, will autovalidate) "
220
- always-float-label auto-validate pattern ="[a-zA-Z]* ">
235
+ <paper-input class="custom" label="Address (letters only, will autovalidate)" always-float-label="" auto-validate="" pattern="[a-zA-Z]*">
221
236
</paper-input>
222
237
</div>
223
238
</template>
224
239
</demo-snippet>
225
- </ div >
240
+ </div>` ;
241
+
242
+ document . body . appendChild ( $_documentContainer . content ) ;
243
+ </ script >
226
244
227
- < script >
228
- function validate ( ) {
229
- document . getElementById ( 'inputForValidation' ) . validate ( ) ;
230
- }
245
+ < script type ="module ">
246
+ import '@polymer/iron-demo-helpers/demo-pages-shared-styles.js' ;
247
+ import '@polymer/iron-demo-helpers/demo-snippet.js' ;
248
+ import '@polymer/iron-icon/iron-icon.js' ;
249
+ import '@polymer/iron-icons/iron-icons.js' ;
250
+ import '@polymer/iron-input/iron-input.js' ;
251
+ import '@polymer/paper-icon-button/paper-icon-button.js' ;
252
+ import '@polymer/paper-styles/color.js' ;
253
+ import '../paper-input-container.js' ;
254
+ import '../paper-input-error.js' ;
255
+ import '../paper-input.js' ;
256
+ import '../paper-textarea.js' ;
257
+ import './ssn-input.js' ;
258
+ function validate ( ) {
259
+ document . getElementById ( 'inputForValidation' ) . validate ( ) ;
260
+ }
231
261
232
- function clearInput ( ) {
233
- document . getElementById ( 'inputWithButton' ) . value = '' ;
234
- }
235
- </ script >
262
+ function clearInput ( ) {
263
+ document . getElementById ( 'inputWithButton' ) . value = '' ;
264
+ }
265
+ </ script >
236
266
</ body >
237
267
</ html >
0 commit comments