|
12 | 12 | * |
13 | 13 | * @prop --border-width: Border width of the input boxes |
14 | 14 | * @prop --border-color: Border color of the input boxes |
| 15 | + * @prop --border-width-focused: Border width when focused |
15 | 16 | * @prop --border-color-focused: Border color when focused |
16 | 17 | * |
17 | 18 | * @prop --color: Text color of the input |
|
35 | 36 | * @prop --separator-height: Height of the separator between boxes |
36 | 37 | * @prop --separator-border-radius: Border radius of the separator between boxes |
37 | 38 | * |
38 | | - * @prop --highlight-color-invalid: Color used for the invalid state |
| 39 | + * @prop --highlight-color-focused: The color of the highlight on the input when focused |
| 40 | + * @prop --highlight-color-valid: The color of the highlight on the input when valid |
| 41 | + * @prop --highlight-color-invalid: The color of the highlight on the input when invalid |
39 | 42 | */ |
40 | 43 | --margin-top: 0; |
41 | 44 | --margin-end: 0; |
|
51 | 54 | --separator-border-radius: 999px; |
52 | 55 | --separator-color: #{$background-color-step-150}; |
53 | 56 | --background-focused: var(--background); |
54 | | - --border-color-focused: #{ion-color(primary, base, 0.4)}; |
| 57 | + --border-width-focused: 2px; |
| 58 | + --border-color-focused: var(--highlight-color); |
| 59 | + --highlight-color-focused: #{ion-color(primary, base, 0.4)}; |
| 60 | + --highlight-color-valid: #{ion-color(success, base)}; |
55 | 61 | --highlight-color-invalid: #{ion-color(danger, base)}; |
56 | 62 |
|
| 63 | + /** |
| 64 | + * This is a private API that is used to switch |
| 65 | + * out the highlight color based on the state |
| 66 | + * of the component without having to write |
| 67 | + * different selectors for different fill variants. |
| 68 | + */ |
| 69 | + --highlight-color: var(--highlight-color-focused); |
| 70 | + |
57 | 71 | display: block; |
58 | 72 | position: relative; |
| 73 | + |
| 74 | + font-size: dynamic-font(14px); |
59 | 75 | } |
60 | 76 |
|
61 | 77 | .input-otp-group { |
|
102 | 118 | .input-otp-description { |
103 | 119 | color: $text-color-step-400; |
104 | 120 |
|
105 | | - font-size: 12px; |
| 121 | + font-size: dynamic-font(12px); |
106 | 122 | font-weight: 500; |
107 | 123 |
|
108 | 124 | line-height: 20px; |
|
127 | 143 | :host(.input-otp-size-small) { |
128 | 144 | --width: 40px; |
129 | 145 | --height: 40px; |
130 | | - |
131 | | - font-size: 0.875em; |
132 | 146 | } |
133 | 147 |
|
134 | 148 | :host(.input-otp-size-small) .input-otp-group { |
|
138 | 152 | :host(.input-otp-size-medium) { |
139 | 153 | --width: 48px; |
140 | 154 | --height: 48px; |
141 | | - |
142 | | - font-size: 1em; |
143 | 155 | } |
144 | 156 |
|
145 | 157 | :host(.input-otp-size-large) { |
146 | 158 | --width: 56px; |
147 | 159 | --height: 56px; |
148 | | - |
149 | | - font-size: 1.125em; |
150 | 160 | } |
151 | 161 |
|
152 | 162 | :host(.input-otp-size-medium) .input-otp-group, |
|
179 | 189 |
|
180 | 190 | :host(.input-otp-fill-solid) { |
181 | 191 | --border-color: #{$background-color-step-50}; |
182 | | - --background: var(--border-color); |
| 192 | + --background: #{$background-color-step-50}; |
183 | 193 | } |
184 | 194 |
|
185 | 195 | // States |
|
188 | 198 | :host(.input-otp-fill-outline.input-otp-disabled) { |
189 | 199 | --background: #{$background-color-step-50}; |
190 | 200 | --border-color: #{$background-color-step-100}; |
| 201 | + |
| 202 | + color: #{$text-color-step-650}; |
191 | 203 | } |
192 | 204 |
|
193 | 205 | :host(.input-otp-disabled), |
|
196 | 208 | } |
197 | 209 |
|
198 | 210 | :host(.has-focus) .native-input:focus { |
199 | | - border-width: 2px; |
| 211 | + border-width: var(--border-width-focused); |
200 | 212 | border-color: var(--border-color-focused); |
201 | 213 |
|
202 | 214 | outline: none; |
203 | 215 |
|
204 | 216 | background: var(--background-focused); |
205 | 217 | } |
206 | 218 |
|
207 | | -:host(.ion-invalid) .native-input, |
208 | | -:host(.ion-invalid.has-focus) .native-input { |
209 | | - border-color: var(--highlight-color-invalid); |
210 | | -} |
211 | | - |
212 | 219 | :host(.input-otp-fill-outline.input-otp-readonly) { |
213 | 220 | --background: #{$background-color-step-50}; |
214 | 221 | } |
|
218 | 225 | --border-color: #{$background-color-step-100}; |
219 | 226 | } |
220 | 227 |
|
| 228 | +// Input Highlight |
| 229 | +// ---------------------------------------------------------------- |
| 230 | + |
| 231 | +:host(.ion-touched.ion-invalid) { |
| 232 | + --highlight-color: var(--highlight-color-invalid); |
| 233 | +} |
| 234 | + |
| 235 | +/** |
| 236 | + * The component highlight is only shown |
| 237 | + * on focus, so we can safely set the valid |
| 238 | + * color state when valid. If we |
| 239 | + * set it when .has-focus is present then |
| 240 | + * the highlight color would change |
| 241 | + * from the valid color to the component's |
| 242 | + * color during the transition after the |
| 243 | + * component loses focus. |
| 244 | + */ |
| 245 | +:host(.ion-valid) { |
| 246 | + --highlight-color: var(--highlight-color-valid); |
| 247 | +} |
| 248 | + |
| 249 | +:host(.has-focus.ion-valid), |
| 250 | +:host(.ion-touched.ion-invalid) { |
| 251 | + --border-color: var(--highlight-color); |
| 252 | +} |
| 253 | + |
221 | 254 | // Colors |
222 | 255 | // -------------------------------------------------- |
223 | 256 |
|
224 | 257 | :host(.input-otp-fill-outline.ion-color) .native-input { |
225 | | - border-color: current-color(base, 0.3); |
| 258 | + border-color: #{current-color(base, 0.3)}; |
226 | 259 | } |
227 | 260 |
|
228 | | -:host(.input-otp-fill-outline.ion-color.has-focus) .native-input:focus { |
229 | | - border-color: current-color(base, 0.4); |
| 261 | +// Focused |
| 262 | +:host(.input-otp-fill-outline.ion-color.has-focus) .native-input:focus, |
| 263 | +:host(.input-otp-fill-solid.ion-color.has-focus) .native-input:focus { |
| 264 | + border-color: #{current-color(base, 0.4)}; |
230 | 265 | } |
231 | 266 |
|
232 | | -:host(.input-otp-fill-solid.ion-color) .native-input { |
233 | | - border-color: transparent; |
234 | | - |
235 | | - background: current-color(base, 0.08); |
| 267 | +// Invalid |
| 268 | +:host(.input-otp-fill-outline.ion-color.ion-invalid) .native-input, |
| 269 | +:host(.input-otp-fill-solid.ion-color.ion-invalid) .native-input, |
| 270 | +:host(.input-otp-fill-outline.ion-color.has-focus.ion-invalid) .native-input, |
| 271 | +:host(.input-otp-fill-solid.ion-color.has-focus.ion-invalid) .native-input { |
| 272 | + border-color: #{ion-color(danger, base)}; |
236 | 273 | } |
237 | 274 |
|
238 | | -:host(.input-otp-fill-solid.ion-color.has-focus) .native-input:focus { |
239 | | - border-color: current-color(base, 0.4); |
| 275 | +// Valid |
| 276 | +:host(.input-otp-fill-outline.ion-color.ion-valid) .native-input, |
| 277 | +:host(.input-otp-fill-solid.ion-color.ion-valid) .native-input, |
| 278 | +:host(.input-otp-fill-outline.ion-color.has-focus.ion-valid) .native-input, |
| 279 | +:host(.input-otp-fill-solid.ion-color.has-focus.ion-valid) .native-input { |
| 280 | + border-color: #{ion-color(success, base)}; |
240 | 281 | } |
241 | 282 |
|
242 | 283 | // Outline & Disabled |
243 | 284 | :host(.input-otp-fill-outline.input-otp-disabled.ion-color) .native-input { |
244 | | - border-color: current-color(base, 0.1); |
245 | | -} |
246 | | - |
247 | | -// Solid & Disabled/Readonly |
248 | | -:host(.input-otp-fill-solid.input-otp-disabled.ion-color) .native-input, |
249 | | -:host(.input-otp-fill-solid.input-otp-readonly.ion-color) .native-input { |
250 | | - background: current-color(base, 0.16); |
| 285 | + border-color: #{current-color(base, 0.1)}; |
251 | 286 | } |
0 commit comments