|
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 | }
|
|
29 | 29 | margin-top: 10px;
|
30 | 30 | }
|
31 | 31 |
|
32 |
| - @media screen and (max-width: 800px) { |
33 |
| - .grid { |
34 |
| - grid-template-columns: 1fr; |
35 |
| - padding: 0; |
36 |
| - } |
37 |
| - } |
38 |
| - |
39 | 32 | ion-textarea.custom-error-color {
|
40 | 33 | --highlight-color-invalid: purple;
|
41 | 34 | }
|
42 | 35 | </style>
|
43 | 36 | </head>
|
44 | 37 |
|
45 |
| - <body> |
| 38 | + <body onLoad="onLoad()"> |
46 | 39 | <ion-app>
|
47 | 40 | <ion-header>
|
48 | 41 | <ion-toolbar>
|
|
54 | 47 | <div class="grid">
|
55 | 48 | <div class="grid-item">
|
56 | 49 | <h2>No Hint</h2>
|
57 |
| - <ion-textarea label="Email"></ion-textarea> |
| 50 | + <ion-textarea label="Label"></ion-textarea> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div class="grid-item"> |
| 54 | + <h2>No Hint: Stacked</h2> |
| 55 | + <ion-textarea label="Label" label-placement="stacked"></ion-textarea> |
| 56 | + </div> |
| 57 | + |
| 58 | + <div class="grid-item"> |
| 59 | + <h2>Helper Text</h2> |
| 60 | + <ion-textarea label="Label" helper-text="Helper text"></ion-textarea> |
| 61 | + </div> |
| 62 | + |
| 63 | + <div class="grid-item"> |
| 64 | + <h2>Helper Text: Stacked</h2> |
| 65 | + <ion-textarea label="Label" label-placement="stacked" helper-text="Helper text"></ion-textarea> |
58 | 66 | </div>
|
59 | 67 |
|
60 | 68 | <div class="grid-item">
|
61 |
| - <h2>Helper Hint</h2> |
62 |
| - <ion-textarea label="Email" helper-text="Enter your email"></ion-textarea> |
| 69 | + <h2>Error Text</h2> |
| 70 | + <ion-textarea class="ion-touched ion-invalid" label="Label" error-text="Error text"></ion-textarea> |
63 | 71 | </div>
|
64 | 72 |
|
65 | 73 | <div class="grid-item">
|
66 |
| - <h2>Error Hint</h2> |
| 74 | + <h2>Error Text: Stacked</h2> |
67 | 75 | <ion-textarea
|
68 | 76 | class="ion-touched ion-invalid"
|
69 |
| - label="Email" |
70 |
| - error-text="Please enter a valid email" |
| 77 | + label="Label" |
| 78 | + label-placement="stacked" |
| 79 | + error-text="Error text" |
71 | 80 | ></ion-textarea>
|
72 | 81 | </div>
|
73 | 82 |
|
74 | 83 | <div class="grid-item">
|
75 |
| - <h2>Custom Error Color</h2> |
| 84 | + <h2>Error Text: Custom Color</h2> |
76 | 85 | <ion-textarea
|
77 | 86 | class="ion-touched ion-invalid custom-error-color"
|
78 |
| - label="Email" |
79 |
| - error-text="Please enter a valid email" |
| 87 | + label="Label" |
| 88 | + error-text="Error text" |
80 | 89 | ></ion-textarea>
|
81 | 90 | </div>
|
82 | 91 |
|
| 92 | + <div class="grid-item"> |
| 93 | + <h2>Helper Text: Wrapping</h2> |
| 94 | + <ion-textarea |
| 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-textarea> |
| 99 | + </div> |
| 100 | + |
83 | 101 | <div class="grid-item">
|
84 | 102 | <h2>Counter</h2>
|
85 |
| - <ion-textarea label="Email" counter="true" maxlength="100"></ion-textarea> |
| 103 | + <ion-textarea label="Label" counter="true" maxlength="100"></ion-textarea> |
86 | 104 | </div>
|
87 | 105 |
|
88 | 106 | <div class="grid-item">
|
89 |
| - <h2>Custom Counter</h2> |
90 |
| - <ion-textarea id="custom-counter" label="Email" counter="true" maxlength="100"></ion-textarea> |
| 107 | + <h2>Counter: Custom</h2> |
| 108 | + <ion-textarea id="custom-counter" label="Label" counter="true" maxlength="100"></ion-textarea> |
91 | 109 | </div>
|
92 | 110 |
|
93 | 111 | <div class="grid-item">
|
94 |
| - <h2>Counter with Helper</h2> |
95 |
| - <ion-textarea label="Email" counter="true" maxlength="100" helper-text="Enter an email"></ion-textarea> |
| 112 | + <h2>Counter: with Helper</h2> |
| 113 | + <ion-textarea label="Label" counter="true" maxlength="100" helper-text="Helper text"></ion-textarea> |
96 | 114 | </div>
|
97 | 115 |
|
98 | 116 | <div class="grid-item">
|
99 |
| - <h2>Counter with Error</h2> |
| 117 | + <h2>Counter: with Error</h2> |
100 | 118 | <ion-textarea
|
101 | 119 | class="ion-touched ion-invalid"
|
102 |
| - label="Email" |
| 120 | + label="Label" |
103 | 121 | counter="true"
|
104 | 122 | maxlength="100"
|
105 |
| - error-text="Please enter a valid email" |
| 123 | + error-text="Error text" |
106 | 124 | ></ion-textarea>
|
107 | 125 | </div>
|
108 | 126 | </div>
|
109 | 127 |
|
110 |
| - <script> |
111 |
| - const customCounterTextarea = document.querySelector('ion-textarea#custom-counter'); |
112 |
| - customCounterTextarea.counterFormatter = (inputLength, maxLength) => { |
113 |
| - const length = maxLength - inputLength; |
114 |
| - return `${maxLength - inputLength} characters left`; |
115 |
| - }; |
116 |
| - </script> |
| 128 | + <button class="expand" onclick="toggleFill()">Toggle Fill</button> |
117 | 129 | </ion-content>
|
118 | 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 customCounterTextarea = document.querySelector('ion-textarea#custom-counter'); |
| 143 | + customCounterTextarea.counterFormatter = (inputLength, maxLength) => { |
| 144 | + const length = maxLength - inputLength; |
| 145 | + return `${maxLength - inputLength} characters left`; |
| 146 | + }; |
| 147 | + |
| 148 | + const textareas = document.querySelectorAll('ion-textarea'); |
| 149 | + |
| 150 | + function toggleFill() { |
| 151 | + textareas.forEach((textarea) => { |
| 152 | + switch (textarea.fill) { |
| 153 | + case 'outline': |
| 154 | + textarea.fill = 'solid'; |
| 155 | + break; |
| 156 | + case 'solid': |
| 157 | + textarea.fill = undefined; |
| 158 | + break; |
| 159 | + default: |
| 160 | + textarea.fill = 'outline'; |
| 161 | + } |
| 162 | + }); |
| 163 | + } |
| 164 | + </script> |
119 | 165 | </body>
|
120 | 166 | </html>
|
0 commit comments