|
19 | 19 |
|
20 | 20 | <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
21 | 21 |
|
| 22 | + <link rel="import" href="../../iron-demo-helpers/demo-snippet.html"> |
| 23 | + <link rel="import" href="../../iron-demo-helpers/demo-pages-shared-styles.html"> |
22 | 24 | <link rel="import" href="../paper-input.html"> |
23 | 25 | <link rel="import" href="../paper-input-container.html"> |
24 | 26 | <link rel="import" href="../paper-input-error.html"> |
|
28 | 30 | <link rel="import" href="../../iron-icon/iron-icon.html"> |
29 | 31 | <link rel="import" href="../../iron-icons/iron-icons.html"> |
30 | 32 | <link rel="import" href="../../paper-icon-button/paper-icon-button.html"> |
31 | | - <link rel="import" href="ssn-input.html"> |
32 | 33 |
|
| 34 | + <link rel="import" href="ssn-input.html"> |
33 | 35 | <link rel="stylesheet" href="../../paper-styles/color.html"> |
34 | | - <link rel="import" href="../../paper-styles/demo-pages.html"> |
35 | 36 |
|
36 | | - <style is="custom-style"> |
37 | | - body { |
38 | | - padding: 40px; |
| 37 | + <style is="custom-style" include="demo-pages-shared-styles"> |
| 38 | + paper-input { |
| 39 | + display: block; |
| 40 | + } |
| 41 | + |
| 42 | + demo-snippet.horizontal { |
| 43 | + --demo-snippet-demo: { |
| 44 | + @apply(--layout-horizontal); |
| 45 | + @apply(--layout-justified); |
| 46 | + @apply(--layout-wrap); |
| 47 | + } |
| 48 | + } |
| 49 | + demo-snippet.horizontal paper-input { |
| 50 | + display: inline-block; |
39 | 51 | } |
40 | 52 |
|
41 | | - paper-input.short { |
42 | | - width: 200px; |
| 53 | + button { |
| 54 | + width: 70px; |
| 55 | + } |
| 56 | + #inputForValidation { |
| 57 | + display: inline-block; |
| 58 | + width: calc(100% - 75px); |
| 59 | + } |
| 60 | + |
| 61 | + |
| 62 | + .vertical-section-container { |
| 63 | + max-width: 600px; |
43 | 64 | } |
44 | 65 |
|
45 | 66 | paper-icon-button { |
|
49 | 70 | height: 23px; |
50 | 71 | padding: 0px 4px; |
51 | 72 | } |
52 | | - </style> |
53 | | - |
54 | | -</head> |
55 | | -<body unresolved> |
56 | | - |
57 | | - <div class="vertical center-justified layout"> |
58 | | - <h4>Text input</h4> |
59 | | - |
60 | | - <div class="vertical-section"> |
61 | | - <paper-input label="label"></paper-input> |
62 | | - |
63 | | - <paper-input label="password" type="password"></paper-input> |
64 | | - |
65 | | - <paper-input no-label-float label="label (no-label-float)"></paper-input> |
66 | | - |
67 | | - <paper-input label="disabled" disabled></paper-input> |
68 | | - </div> |
69 | 73 |
|
70 | | - <h4>Text area</h4> |
71 | | - <div class="vertical-section"> |
72 | | - <paper-textarea label="textarea label"></paper-textarea> |
73 | | - </div> |
74 | | - |
75 | | - <h4>Validation</h4> |
76 | | - <div class="vertical-section"> |
77 | | - <paper-input label="input validates on blur (required, auto-validate)" required auto-validate error-message="needs some text!"></paper-input> |
78 | | - |
79 | | - <paper-input label="only type letters (auto-validate)" auto-validate pattern="[a-zA-Z]*" error-message="letters only!"></paper-input> |
80 | | - |
81 | | - <paper-input id="inputForValidation" required label="only type letters (no auto validate)" pattern="[a-zA-Z]*" error-message="letters only, required input!"></paper-input> |
82 | | - <br> |
83 | | - <button onclick="validate()">Validate!</button> |
84 | | - </div> |
85 | | - |
86 | | - <h4>Character counter</h4> |
87 | | - <div class="vertical-section"> |
88 | | - <paper-input label="label" char-counter></paper-input> |
89 | | - |
90 | | - <paper-input label="at most 10 letters" char-counter auto-validate pattern="[a-zA-Z]*" maxlength="10" error-message="letters only!"></paper-input> |
91 | | - |
92 | | - <paper-textarea label="textarea" char-counter></paper-textarea> |
93 | | - |
94 | | - <paper-textarea label="textarea with maxlength" maxlength="10" char-counter></paper-textarea> |
| 74 | + iron-icon { |
| 75 | + padding-right: 5px; |
| 76 | + } |
95 | 77 |
|
96 | | - <paper-textarea label="text area with rows and max-rows" rows="3" max-rows="4"></paper-textarea> |
97 | | - </div> |
98 | 78 |
|
99 | | - <h4>Prefixes and Suffixes</h4> |
100 | | - <div class="vertical-section"> |
101 | | - <paper-input class="short" label="total" type="number"> |
102 | | - <div prefix>$</div> |
103 | | - </paper-input> |
| 79 | + </style> |
104 | 80 |
|
105 | | - <paper-input class="short" label="username"> |
106 | | - <div suffix>@email.com</div> |
107 | | - </paper-input> |
| 81 | +</head> |
| 82 | +<body unresolved> |
| 83 | + <div class="vertical-section-container centered"> |
| 84 | + <h3>Inputs can have different types, and be disabled</h3> |
| 85 | + <demo-snippet> |
| 86 | + <template> |
| 87 | + <paper-input label="text input"></paper-input> |
| 88 | + <paper-textarea label="autoresizing textarea input"></paper-textarea> |
| 89 | + <paper-input label="password input" type="password"></paper-input> |
| 90 | + <paper-input label="disabled input" disabled></paper-input> |
| 91 | + </template> |
| 92 | + </demo-snippet> |
108 | 93 |
|
109 | | - <paper-input class="short" label="icons and buttons" id="inputWithButton"> |
110 | | - <iron-icon icon="search" prefix></iron-icon> |
111 | | - <paper-icon-button suffix onclick="clearInput()" |
112 | | - icon="clear" alt="clear" title="clear"> |
113 | | - </paper-icon-button> |
114 | | - </paper-input> |
115 | | - </div> |
| 94 | + <h3>Inputs can have character counters</h3> |
| 95 | + <demo-snippet> |
| 96 | + <template> |
| 97 | + <paper-input label="simple character counter" char-counter></paper-input> |
| 98 | + <paper-input label="input with at most 10 characters" char-counter maxlength="10"></paper-input> |
| 99 | + </template> |
| 100 | + </demo-snippet> |
| 101 | + |
| 102 | + <h3>The label can have different floating states</h3> |
| 103 | + <demo-snippet> |
| 104 | + <template> |
| 105 | + <paper-input label="this label floats after typing"></paper-input> |
| 106 | + <paper-input label="this label is always floating" always-float-label></paper-input> |
| 107 | + <paper-input label="this label never floats" no-label-float></paper-input> |
| 108 | + <paper-input label="this label is always floating" always-float-label placeholder="placeholder text"></paper-input> |
| 109 | + </template> |
| 110 | + </demo-snippet> |
| 111 | + |
| 112 | + <h3>Inputs can validate automatically or on demand, and can have custom error messages</h3> |
| 113 | + <demo-snippet> |
| 114 | + <template> |
| 115 | + <paper-input label="this input requires some text" required auto-validate error-message="needs some text!"></paper-input> |
| 116 | + <paper-input label="this input requires letters only" auto-validate pattern="[a-zA-Z]*" error-message="letters only!"></paper-input> |
| 117 | + <paper-input label="this input will only let you type letters" auto-validate allowed-pattern="[a-zA-Z]"></paper-input> |
| 118 | + <paper-input id="inputForValidation" required label="this input is manually validated" pattern="[a-zA-Z]*" error-message="letters only!"></paper-input> |
| 119 | + <button onclick="validate()">Validate!</button> |
| 120 | + </template> |
| 121 | + </demo-snippet> |
| 122 | + |
| 123 | + <h3>Inputs can have prefixes and suffixes</h3> |
| 124 | + <demo-snippet class="horizontal"> |
| 125 | + <template> |
| 126 | + <paper-input class="short" label="total" type="number"> |
| 127 | + <div prefix>$</div> |
| 128 | + </paper-input> |
| 129 | + <paper-input class="short" label="username" id="inputWithButton"> |
| 130 | + <iron-icon icon="mail" prefix></iron-icon> |
| 131 | + <div suffix>@email.com</div> |
| 132 | + <paper-icon-button suffix onclick="clearInput()" |
| 133 | + icon="clear" alt="clear" title="clear"> |
| 134 | + </paper-icon-button> |
| 135 | + </paper-input> |
| 136 | + </template> |
| 137 | + </demo-snippet> |
116 | 138 |
|
117 | | - <h4>Complex inputs</h4> |
118 | | - <div class="vertical-section"> |
119 | | - <template is="dom-bind"> |
| 139 | + <h3>Inputs can have custom logic</h3> |
| 140 | + <demo-snippet> |
| 141 | + <template> |
120 | 142 | <paper-input-container always-float-label auto-validate attr-for-value="value"> |
121 | 143 | <label>Social Security Number</label> |
122 | 144 | <ssn-input class="paper-input-input"></ssn-input> |
123 | 145 | <paper-input-error>SSN invalid!</paper-input-error> |
124 | 146 | </paper-input-container> |
125 | 147 | </template> |
126 | | - </div> |
| 148 | + </demo-snippet> |
127 | 149 | </div> |
| 150 | + |
128 | 151 | <script> |
129 | 152 | function validate() { |
130 | 153 | document.getElementById('inputForValidation').validate(); |
|
0 commit comments