|
14 | 14 | ////
|
15 | 15 |
|
16 | 16 | /// @param {Map} $schema [$light-schema] - The schema used as basis for styling the component.
|
17 |
| -/// |
18 | 17 | /// @param {Color} $thumb-on-color [null] - The color of the thumb when the switch is on.
|
19 | 18 | /// @param {Color} $track-on-color [null] - The color of the track when the switch is on.
|
20 | 19 | /// @param {Color} $track-on-hover-color [null] - The color of the track when the switch is on and hovered.
|
|
29 | 28 | /// @param {box-shadow} $resting-shadow [null] - The shadow used for the thumb in resting state of the switch.
|
30 | 29 | /// @param {box-shadow} $hover-shadow [null] - The shadow used for the thumb in hover state of the switch.
|
31 | 30 | /// @param {box-shadow} $disabled-shadow [null] - The shadow used for the thumb in disable state of the switch.
|
32 |
| -/// |
33 | 31 | /// @param {border-radius} $border-radius-track [null] - The border radius used for switch track.
|
34 | 32 | /// @param {border-radius} $border-radius-thumb [null] - The border radius used for switch thumb.
|
35 | 33 | /// @param {border-radius} $border-radius-ripple [null] - The border radius used for switch ripple.
|
|
41 | 39 | /// @param {Color} $focus-outline-color [null] - The focus outlined color.
|
42 | 40 | /// @param {Color} $focus-outline-color-focused [null] - The focus outlined color for focused state.
|
43 | 41 | /// @param {Color} $focus-fill-color [null] - The focus fill color.
|
44 |
| -/// |
| 42 | +/// @param {Color} $label-invalid-color [null] - The color of the switch label in invalid state. |
| 43 | +/// @param {Color} $track-error-color [null] - The color of the track in invalid state when the switch is off. |
| 44 | +/// @param {Color} $error-color [null] - The border and fill colors in invalid state. |
| 45 | +/// @param {Color} $error-color-hover [null] - The border and fill colors in invalid state on hover. |
45 | 46 | /// @requires $light-schema
|
46 | 47 | ///
|
47 |
| -/// |
48 |
| -/// |
49 | 48 | /// @example scss Set custom track and thumb on colors
|
50 | 49 | /// $my-switch-theme: switch-theme($thumb-on-color: black, $track-on-color: yellow);
|
51 | 50 | /// // Pass the theme to the css-vars() mixin
|
|
67 | 66 |
|
68 | 67 | $label-color: null,
|
69 | 68 | $label-disabled-color: null,
|
| 69 | + $label-invalid-color: null, |
70 | 70 |
|
71 | 71 | $resting-shadow: null,
|
72 | 72 | $hover-shadow: null,
|
|
82 | 82 | $border-on-hover-color: null,
|
83 | 83 | $focus-outline-color: null,
|
84 | 84 | $focus-outline-color-focused: null,
|
85 |
| - $focus-fill-color: null |
| 85 | + $focus-fill-color: null, |
| 86 | + $track-error-color: null, |
| 87 | + $error-color: null, |
| 88 | + $error-color-hover: null, |
86 | 89 | ) {
|
87 | 90 | $name: 'igx-switch';
|
88 | 91 | $switch-schema: ();
|
|
139 | 142 |
|
140 | 143 | label-color: $label-color,
|
141 | 144 | label-disabled-color: $label-disabled-color,
|
| 145 | + label-invalid-color: $label-invalid-color, |
142 | 146 |
|
143 | 147 | resting-shadow: $resting-shadow,
|
144 | 148 | hover-shadow: $hover-shadow,
|
|
154 | 158 | border-on-hover-color: $border-on-hover-color,
|
155 | 159 | focus-outline-color: $focus-outline-color,
|
156 | 160 | focus-outline-color-focused: $focus-outline-color-focused,
|
157 |
| - focus-fill-color: $focus-fill-color |
| 161 | + focus-fill-color: $focus-fill-color, |
| 162 | + track-error-color: $track-error-color, |
| 163 | + error-color: $error-color, |
| 164 | + error-color-hover: $error-color-hover, |
158 | 165 | ));
|
159 | 166 | }
|
160 | 167 |
|
|
165 | 172 | @include css-vars($theme);
|
166 | 173 | @include scale-in-out($start-scale: .9);
|
167 | 174 |
|
| 175 | + $type: map.get($theme, type); |
168 | 176 | $variant: map.get($theme, variant);
|
169 | 177 |
|
170 | 178 | $switch-width: map.get((
|
|
232 | 240 |
|
233 | 241 | $switch-thumb-height: $switch-thumb-width;
|
234 | 242 |
|
235 |
| - $ripple-size: rem(48px); |
| 243 | + $ripple-size: rem(40px); |
236 | 244 | $ripple-radius: math.div($ripple-size, 2);
|
237 | 245 |
|
238 | 246 | $label-margin: rem(8px);
|
|
276 | 284 | @if $variant == 'indigo-design' {
|
277 | 285 | border: rem(2px) solid var-get($theme, 'border-color');
|
278 | 286 | }
|
| 287 | + } |
279 | 288 |
|
280 |
| - @if $variant != 'bootstrap' { |
281 |
| - &:hover, |
282 |
| - &:focus { |
283 |
| - border-color: var-get($theme, 'border-hover-color'); |
| 289 | + %switch-composite--hover { |
| 290 | + @if $variant == 'material' or $variant == 'fluent' { |
| 291 | + border-color: var-get($theme, 'border-hover-color'); |
| 292 | + } |
| 293 | + |
| 294 | + @if $variant == 'fluent' { |
| 295 | + %switch-composite-thumb { |
| 296 | + background: var-get($theme, 'border-hover-color'); |
| 297 | + } |
| 298 | + |
| 299 | + %switch-composite-thumb--x { |
| 300 | + background: var-get($theme, 'thumb-on-color'); |
284 | 301 | }
|
285 | 302 | }
|
| 303 | + } |
| 304 | + |
| 305 | + %switch-composite--invalid { |
| 306 | + border-color: var-get($theme, 'error-color'); |
| 307 | + |
| 308 | + @if $variant == 'material' { |
| 309 | + border-color: var-get($theme, 'track-error-color'); |
| 310 | + background: var-get($theme, 'track-error-color'); |
| 311 | + } |
| 312 | + } |
286 | 313 |
|
| 314 | + %switch-composite--invalid--hover { |
287 | 315 | @if $variant == 'fluent' {
|
288 |
| - &:hover { |
289 |
| - %switch-composite-thumb { |
290 |
| - background: var-get($theme, 'border-hover-color'); |
291 |
| - } |
| 316 | + border-color: var-get($theme, 'error-color-hover'); |
292 | 317 |
|
293 |
| - %switch-composite-thumb--x { |
294 |
| - background: var-get($theme, 'thumb-on-color'); |
295 |
| - } |
| 318 | + %switch-composite-thumb { |
| 319 | + background: var-get($theme, 'error-color-hover'); |
296 | 320 | }
|
297 | 321 | }
|
298 | 322 | }
|
299 | 323 |
|
300 | 324 | %switch-composite--x {
|
301 | 325 | background: var-get($theme, 'track-on-color');
|
302 | 326 | border-color: var-get($theme, 'border-on-color');
|
| 327 | + } |
303 | 328 |
|
304 |
| - &:hover, |
305 |
| - &:focus { |
| 329 | + %switch-composite--x--hover { |
| 330 | + @if $variant != 'bootstrap' { |
306 | 331 | border-color: var-get($theme, 'border-on-hover-color');
|
307 | 332 | }
|
308 | 333 |
|
309 | 334 | @if $variant == 'fluent' {
|
310 |
| - &:hover { |
311 |
| - background: var-get($theme, 'track-on-hover-color'); |
| 335 | + background: var-get($theme, 'track-on-hover-color'); |
| 336 | + |
| 337 | + %switch-composite-thumb { |
| 338 | + background: var-get($theme, 'thumb-on-color'); |
312 | 339 | }
|
313 | 340 | }
|
314 | 341 | }
|
|
350 | 377 | }
|
351 | 378 | }
|
352 | 379 |
|
| 380 | + %switch-composite-thumb--invalid { |
| 381 | + background: var-get($theme, 'error-color'); |
| 382 | + } |
| 383 | + |
353 | 384 | %switch-composite-thumb--disabled {
|
354 | 385 | background: var-get($theme, 'thumb-disabled-color');
|
355 | 386 | box-shadow: $thumb-disabled-shadow;
|
|
392 | 423 | @if $variant == 'bootstrap' {
|
393 | 424 | %switch-composite {
|
394 | 425 | border-color: var-get($theme, 'focus-fill-color');
|
395 |
| - box-shadow: 0 0 0 rem(4px) var-get($theme, 'focus-outline-color'); |
| 426 | + box-shadow: 0 0 0 rem(2px) var-get($theme, 'focus-outline-color'); |
396 | 427 | }
|
397 | 428 |
|
398 | 429 | %switch-composite-thumb {
|
|
408 | 439 | }
|
409 | 440 | }
|
410 | 441 |
|
| 442 | + %igx-switch--focused--invalid { |
| 443 | + @if $variant == 'bootstrap' { |
| 444 | + %switch-composite { |
| 445 | + border-color: var-get($theme, 'error-color'); |
| 446 | + box-shadow: 0 0 0 rem(2px) var-get($theme, 'error-color-hover'); |
| 447 | + } |
| 448 | + |
| 449 | + %switch-composite-thumb { |
| 450 | + background: var-get($theme, 'error-color'); |
| 451 | + } |
| 452 | + } |
| 453 | + |
| 454 | + @if $variant == 'indigo-design' { |
| 455 | + %switch-composite { |
| 456 | + box-shadow: 0 0 0 rem(3px) var-get($theme, 'error-color-hover'); |
| 457 | + } |
| 458 | + } |
| 459 | + } |
| 460 | + |
411 | 461 | %igx-switch--focused-checked {
|
412 | 462 | @if $variant == 'bootstrap' {
|
413 | 463 | %switch-composite {
|
|
448 | 498 | background: var-get($theme, 'track-off-color');
|
449 | 499 | transition: background .2s $ease-out-quad;
|
450 | 500 | opacity: .12;
|
| 501 | + |
| 502 | + @if $type == 'dark' { |
| 503 | + opacity: .24; |
| 504 | + } |
451 | 505 | }
|
452 | 506 |
|
453 | 507 | %switch-ripple--focused-checked {
|
454 | 508 | background: var-get($theme, 'thumb-on-color');
|
455 | 509 | }
|
456 | 510 |
|
| 511 | + %switch-ripple--focused-invalid { |
| 512 | + background: var-get($theme, 'error-color-hover'); |
| 513 | + } |
| 514 | + |
457 | 515 | %switch-label {
|
458 | 516 | display: inline-block;
|
459 | 517 | color: var-get($theme, 'label-color');
|
|
486 | 544 | color: var-get($theme, 'label-disabled-color');
|
487 | 545 | }
|
488 | 546 |
|
| 547 | + %switch-label--invalid { |
| 548 | + color: var-get($theme, 'label-invalid-color'); |
| 549 | + } |
| 550 | + |
489 | 551 | %switch-ripple--hover {
|
490 | 552 | &::after {
|
491 | 553 | position: absolute;
|
492 | 554 | content: '';
|
493 | 555 | opacity: .06;
|
494 | 556 | inset: 0;
|
| 557 | + |
| 558 | + @if $type == 'dark' { |
| 559 | + opacity: .12; |
| 560 | + } |
495 | 561 | }
|
496 | 562 | }
|
497 | 563 |
|
|
507 | 573 | }
|
508 | 574 | }
|
509 | 575 |
|
| 576 | + %switch-ripple--hover-invalid { |
| 577 | + &::after { |
| 578 | + background: var-get($theme, 'error-color-hover'); |
| 579 | + } |
| 580 | + } |
| 581 | + |
510 | 582 | %switch-ripple--pressed {
|
511 | 583 | &::after {
|
512 | 584 | opacity: .12;
|
| 585 | + |
| 586 | + @if $type == 'dark' { |
| 587 | + opacity: .24; |
| 588 | + } |
513 | 589 | }
|
514 | 590 | }
|
515 | 591 | }
|
516 | 592 |
|
517 |
| -/// Adds typography styles for the igx-checkbox component. |
| 593 | +/// Adds typography styles for the igx-switch component. |
518 | 594 | /// Uses the 'subtitle-1' category from the typographic scale.
|
519 | 595 | /// @group typography
|
520 | 596 | /// @param {Map} $categories [(label: 'subtitle-1')] - The categories from the typographic scale used for type styles.
|
|
0 commit comments