|
15 | 15 | <style> |
16 | 16 | .grid { |
17 | 17 | display: grid; |
18 | | - grid-template-columns: repeat(3, minmax(250px, 1fr)); |
| 18 | + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); |
19 | 19 | grid-row-gap: 20px; |
20 | 20 | grid-column-gap: 20px; |
21 | 21 | } |
| 22 | + |
22 | 23 | h2 { |
23 | 24 | font-size: 12px; |
24 | 25 | font-weight: normal; |
|
27 | 28 |
|
28 | 29 | margin-top: 10px; |
29 | 30 | } |
30 | | - @media screen and (max-width: 800px) { |
31 | | - .grid { |
32 | | - grid-template-columns: 1fr; |
33 | | - padding: 0; |
34 | | - } |
35 | | - } |
36 | 31 |
|
37 | 32 | ion-input.custom-error-color { |
38 | 33 | --highlight-color-invalid: purple; |
39 | 34 | } |
40 | 35 | </style> |
41 | 36 | </head> |
42 | 37 |
|
43 | | - <body> |
| 38 | + <body onLoad="onLoad()"> |
44 | 39 | <ion-app> |
45 | 40 | <ion-header> |
46 | 41 | <ion-toolbar> |
|
52 | 47 | <div class="grid"> |
53 | 48 | <div class="grid-item"> |
54 | 49 | <h2>No Hint</h2> |
55 | | - <ion-input label="Email"></ion-input> |
| 50 | + <ion-input label="Label"></ion-input> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div class="grid-item"> |
| 54 | + <h2>No Hint: Stacked</h2> |
| 55 | + <ion-input label="Label" label-placement="stacked"></ion-input> |
| 56 | + </div> |
| 57 | + |
| 58 | + <div class="grid-item"> |
| 59 | + <h2>Helper Text</h2> |
| 60 | + <ion-input label="Label" helper-text="Helper text"></ion-input> |
| 61 | + </div> |
| 62 | + |
| 63 | + <div class="grid-item"> |
| 64 | + <h2>Helper Text: Stacked</h2> |
| 65 | + <ion-input label="Label" label-placement="stacked" helper-text="Helper text"></ion-input> |
56 | 66 | </div> |
57 | 67 |
|
58 | 68 | <div class="grid-item"> |
59 | | - <h2>Helper Hint</h2> |
60 | | - <ion-input label="Email" helper-text="Enter your email"></ion-input> |
| 69 | + <h2>Error Text</h2> |
| 70 | + <ion-input class="ion-touched ion-invalid" label="Label" error-text="Error text"></ion-input> |
61 | 71 | </div> |
62 | 72 |
|
63 | 73 | <div class="grid-item"> |
64 | | - <h2>Error Hint</h2> |
| 74 | + <h2>Error Text: Stacked</h2> |
65 | 75 | <ion-input |
66 | 76 | class="ion-touched ion-invalid" |
67 | | - label="Email" |
68 | | - error-text="Please enter a valid email" |
| 77 | + label="Label" |
| 78 | + label-placement="stacked" |
| 79 | + error-text="Error text" |
69 | 80 | ></ion-input> |
70 | 81 | </div> |
71 | 82 |
|
72 | 83 | <div class="grid-item"> |
73 | | - <h2>Custom Error Color</h2> |
| 84 | + <h2>Error Text: Custom Color</h2> |
74 | 85 | <ion-input |
75 | 86 | class="ion-touched ion-invalid custom-error-color" |
76 | | - label="Email" |
77 | | - error-text="Please enter a valid email" |
| 87 | + label="Label" |
| 88 | + error-text="Error text" |
78 | 89 | ></ion-input> |
79 | 90 | </div> |
80 | 91 |
|
| 92 | + <div class="grid-item"> |
| 93 | + <h2>Helper Text: Wrapping</h2> |
| 94 | + <ion-input |
| 95 | + label="Label" |
| 96 | + helper-text="Helper text helper text helper text helper text helper text helper text helper text helper text helper text" |
| 97 | + > |
| 98 | + </ion-input> |
| 99 | + </div> |
| 100 | + |
81 | 101 | <div class="grid-item"> |
82 | 102 | <h2>Counter</h2> |
83 | | - <ion-input label="Email" counter="true" maxlength="100"></ion-input> |
| 103 | + <ion-input label="Label" counter="true" maxlength="100"></ion-input> |
84 | 104 | </div> |
85 | 105 |
|
86 | 106 | <div class="grid-item"> |
87 | | - <h2>Custom Counter</h2> |
88 | | - <ion-input id="custom-counter" label="Email" counter="true" maxlength="100"></ion-input> |
| 107 | + <h2>Counter: Custom</h2> |
| 108 | + <ion-input id="custom-counter" label="Label" counter="true" maxlength="100"></ion-input> |
89 | 109 | </div> |
90 | 110 |
|
91 | 111 | <div class="grid-item"> |
92 | | - <h2>Counter with Helper</h2> |
93 | | - <ion-input label="Email" counter="true" maxlength="100" helper-text="Enter an email"></ion-input> |
| 112 | + <h2>Counter: with Helper</h2> |
| 113 | + <ion-input label="Label" counter="true" maxlength="100" helper-text="Helper text"></ion-input> |
94 | 114 | </div> |
95 | 115 |
|
96 | 116 | <div class="grid-item"> |
97 | | - <h2>Counter with Error</h2> |
| 117 | + <h2>Counter: with Error</h2> |
98 | 118 | <ion-input |
99 | 119 | class="ion-touched ion-invalid" |
100 | | - label="Email" |
| 120 | + label="Label" |
101 | 121 | counter="true" |
102 | 122 | maxlength="100" |
103 | | - error-text="Please enter a valid email" |
| 123 | + error-text="Error text" |
104 | 124 | ></ion-input> |
105 | 125 | </div> |
106 | 126 | </div> |
107 | 127 |
|
108 | | - <script> |
109 | | - const customCounterInput = document.querySelector('ion-input#custom-counter'); |
110 | | - customCounterInput.counterFormatter = (inputLength, maxLength) => { |
111 | | - const length = maxLength - inputLength; |
112 | | - return `${maxLength - inputLength} characters left`; |
113 | | - }; |
114 | | - </script> |
| 128 | + <button class="expand" onclick="toggleFill()">Toggle Fill</button> |
115 | 129 | </ion-content> |
116 | 130 | </ion-app> |
| 131 | + |
| 132 | + <script> |
| 133 | + // Hide the toggle fill button on ios mode since it's not supported |
| 134 | + function onLoad() { |
| 135 | + const toggleFillButton = document.querySelector('button'); |
| 136 | + |
| 137 | + if (Ionic.mode === 'ios' && toggleFillButton) { |
| 138 | + toggleFillButton.style.display = 'none'; |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + const customCounterInput = document.querySelector('ion-input#custom-counter'); |
| 143 | + customCounterInput.counterFormatter = (inputLength, maxLength) => { |
| 144 | + const length = maxLength - inputLength; |
| 145 | + return `${maxLength - inputLength} characters left`; |
| 146 | + }; |
| 147 | + |
| 148 | + const inputs = document.querySelectorAll('ion-input'); |
| 149 | + |
| 150 | + function toggleFill() { |
| 151 | + inputs.forEach((input) => { |
| 152 | + switch (input.fill) { |
| 153 | + case 'outline': |
| 154 | + input.fill = 'solid'; |
| 155 | + break; |
| 156 | + case 'solid': |
| 157 | + input.fill = undefined; |
| 158 | + break; |
| 159 | + default: |
| 160 | + input.fill = 'outline'; |
| 161 | + } |
| 162 | + }); |
| 163 | + } |
| 164 | + </script> |
117 | 165 | </body> |
118 | 166 | </html> |
0 commit comments