|
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 | } |
|
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> |
58 | 56 | </div> |
59 | 57 |
|
60 | 58 | <div class="grid-item"> |
61 | | - <h2>Helper Hint</h2> |
62 | | - <ion-textarea label="Email" helper-text="Enter your email"></ion-textarea> |
| 59 | + <h2>Helper Text</h2> |
| 60 | + <ion-textarea label="Label" helper-text="Helper text"></ion-textarea> |
63 | 61 | </div> |
64 | 62 |
|
65 | 63 | <div class="grid-item"> |
66 | | - <h2>Error Hint</h2> |
| 64 | + <h2>Helper Text: Stacked</h2> |
| 65 | + <ion-textarea label="Label" label-placement="stacked" helper-text="Helper text"></ion-textarea> |
| 66 | + </div> |
| 67 | + |
| 68 | + <div class="grid-item"> |
| 69 | + <h2>Error Text</h2> |
| 70 | + <ion-textarea class="ion-touched ion-invalid" label="Label" error-text="Error text"></ion-textarea> |
| 71 | + </div> |
| 72 | + |
| 73 | + <div class="grid-item"> |
| 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 | + const customCounterTextarea = document.querySelector('ion-textarea#custom-counter'); |
| 134 | + customCounterTextarea.counterFormatter = (inputLength, maxLength) => { |
| 135 | + const length = maxLength - inputLength; |
| 136 | + return `${maxLength - inputLength} characters left`; |
| 137 | + }; |
| 138 | + |
| 139 | + const textareas = document.querySelectorAll('ion-textarea'); |
| 140 | + |
| 141 | + function toggleFill() { |
| 142 | + textareas.forEach((textarea) => { |
| 143 | + switch (textarea.fill) { |
| 144 | + case 'outline': |
| 145 | + textarea.fill = 'solid'; |
| 146 | + break; |
| 147 | + case 'solid': |
| 148 | + textarea.fill = undefined; |
| 149 | + break; |
| 150 | + default: |
| 151 | + textarea.fill = 'outline'; |
| 152 | + } |
| 153 | + }); |
| 154 | + } |
| 155 | + </script> |
119 | 156 | </body> |
120 | 157 | </html> |
0 commit comments