|
6 | 6 | /// .my-app {
|
7 | 7 | /// @include mat-strong-focus-indicators();
|
8 | 8 | /// }
|
9 |
| - |
10 | 9 | @mixin mat-strong-focus-indicators() {
|
11 |
| - // Reference to the root selector, used to simplify the nested selectors |
12 |
| - // in this mixin. |
13 |
| - $root-selector: #{&}; |
14 |
| - |
15 | 10 | // Border width of the focus indicators.
|
16 | 11 | $border-width: 2px;
|
17 | 12 |
|
18 |
| - @at-root .mat-focus-indicator { |
19 |
| - // Base styles for the focus indicators. |
20 |
| - #{$root-selector} &::before { |
21 |
| - border: $border-width solid transparent; |
22 |
| - border-radius: 4px; |
23 |
| - box-sizing: border-box; |
24 |
| - pointer-events: none; |
25 |
| - position: absolute; |
26 |
| - top: 0; |
27 |
| - right: 0; |
28 |
| - bottom: 0; |
29 |
| - left: 0; |
30 |
| - } |
| 13 | + // Base styles for the focus indicators. |
| 14 | + .mat-focus-indicator::before { |
| 15 | + border-radius: 4px; |
| 16 | + border: $border-width solid transparent; |
| 17 | + box-sizing: border-box; |
| 18 | + position: absolute; |
| 19 | + pointer-events: none; |
| 20 | + top: 0; |
| 21 | + right: 0; |
| 22 | + bottom: 0; |
| 23 | + left: 0; |
| 24 | + } |
31 | 25 |
|
32 |
| - // By default, all focus indicators are flush with the bounding box of their |
33 |
| - // host element. For particular elements (listed below), default inset/offset |
34 |
| - // values are necessary to ensure that the focus indicator is sufficiently |
35 |
| - // contrastive and renders appropriately. |
| 26 | + // By default, all focus indicators are flush with the bounding box of their |
| 27 | + // host element. For particular elements (listed below), default inset/offset |
| 28 | + // values are necessary to ensure that the focus indicator is sufficiently |
| 29 | + // contrastive and renders appropriately. |
36 | 30 |
|
37 |
| - #{$root-selector} &.mat-button-base::before, |
38 |
| - #{$root-selector} &.mat-card::before, |
39 |
| - #{$root-selector} &.mat-sort-header-button::before { |
40 |
| - margin: $border-width * -2; |
41 |
| - } |
| 31 | + .mat-focus-indicator.mat-button-base::before, |
| 32 | + .mat-focus-indicator.mat-button-base::before, |
| 33 | + .mat-focus-indicator.mat-card::before, |
| 34 | + .mat-focus-indicator.mat-sort-header-button::before { |
| 35 | + margin: $border-width * -2; |
| 36 | + } |
42 | 37 |
|
43 |
| - #{$root-selector} &.mat-calendar-body-cell::before { |
44 |
| - margin: $border-width * -1; |
45 |
| - } |
| 38 | + .mat-focus-indicator.mat-calendar-body-cell::before { |
| 39 | + margin: $border-width * -1; |
| 40 | + } |
46 | 41 |
|
47 |
| - #{$root-selector} &.mat-tab-link::before, |
48 |
| - #{$root-selector} &.mat-tab-label::before { |
49 |
| - margin: $border-width * 2; |
50 |
| - } |
| 42 | + .mat-focus-indicator.mat-tab-link::before, |
| 43 | + .mat-focus-indicator.mat-tab-label::before { |
| 44 | + margin: $border-width * 2; |
| 45 | + } |
51 | 46 |
|
52 |
| - // Render the focus indicator on focus. Defining a pseudo element's |
53 |
| - // content will cause it to render. |
| 47 | + // Render the focus indicator on focus. Defining a pseudo element's |
| 48 | + // content will cause it to render. |
54 | 49 |
|
55 |
| - // For checkboxes, radios, and slide toggles, render the focus indicator |
56 |
| - // when the class .cdk-focused is present. |
57 |
| - #{$root-selector} .cdk-focused.mat-checkbox &::before, |
58 |
| - #{$root-selector} .cdk-focused.mat-radio-button &::before, |
59 |
| - #{$root-selector} .cdk-focused.mat-slide-toggle &::before, |
| 50 | + // For checkboxes, radios, and slide toggles, render the focus indicator |
| 51 | + // when the class .cdk-focused is present. |
| 52 | + .cdk-focused.mat-checkbox .mat-focus-indicator::before, |
| 53 | + .cdk-focused.mat-radio-button .mat-focus-indicator::before, |
| 54 | + .cdk-focused.mat-slide-toggle .mat-focus-indicator::before, |
60 | 55 |
|
61 |
| - // For options, render the focus indicator when the class .mat-active |
62 |
| - // is present. |
63 |
| - #{$root-selector} &.mat-active.mat-option::before, |
| 56 | + // For options, render the focus indicator when the class .mat-active |
| 57 | + // is present. |
| 58 | + .mat-focus-indicator.mat-option.mat-active::before, |
64 | 59 |
|
65 |
| - // For all other components, render the focus indicator on focus. |
66 |
| - #{$root-selector} &:focus::before { |
67 |
| - content: ''; |
68 |
| - } |
| 60 | + // For all other components, render the focus indicator on focus. |
| 61 | + .mat-focus-indicator:focus::before { |
| 62 | + content: ''; |
69 | 63 | }
|
70 | 64 | }
|
71 | 65 |
|
|
84 | 78 | /// .demo-red-theme {
|
85 | 79 | /// @include mat-strong-focus-indicators-theme(#F00);
|
86 | 80 | /// }
|
87 |
| - |
88 | 81 | @mixin mat-strong-focus-indicators-theme($themeOrColor) {
|
89 | 82 | .mat-focus-indicator::before {
|
90 | 83 | border-color: if(
|
|
0 commit comments