|
1 | | -@use '@angular/material' as mat; |
2 | 1 | @use 'sass:map'; |
| 2 | +@use '@angular/material' as mat; |
3 | 3 |
|
4 | | -/// Mixin that turns on strong focus indicators. |
5 | | -/// |
6 | | -/// @example |
7 | | -/// .my-app { |
8 | | -/// @include mat-mdc-strong-focus-indicators($config); |
9 | | -/// } |
10 | 4 | @mixin strong-focus-indicators($config: ()) { |
11 | 5 | // Default focus indicator config. |
12 | 6 | $default-config: ( |
13 | | - border-style: solid, |
14 | | - border-width: 3px, |
15 | | - border-radius: 4px, |
| 7 | + border-color: black, |
| 8 | + display: block, |
16 | 9 | ); |
17 | 10 |
|
18 | 11 | // Merge default config with user config. |
19 | 12 | $config: map.merge($default-config, $config); |
20 | | - $border-style: map.get($config, border-style); |
21 | | - $border-width: map.get($config, border-width); |
22 | | - $border-radius: map.get($config, border-radius); |
23 | | - |
24 | | - // Base styles for focus indicators. |
25 | | - .mat-mdc-focus-indicator::before { |
26 | | - @include mat.private-fill(); |
27 | | - box-sizing: border-box; |
28 | | - pointer-events: none; |
29 | | - border: $border-width $border-style transparent; |
30 | | - border-radius: $border-radius; |
31 | | - |
32 | | - .cdk-high-contrast-active & { |
33 | | - display: none; |
34 | | - } |
35 | | - } |
36 | | - |
37 | | - // By default, all focus indicators are flush with the bounding box of their |
38 | | - // host element. For particular elements (listed below), default inset/offset |
39 | | - // values are necessary to ensure that the focus indicator is sufficiently |
40 | | - // contrastive and renders appropriately. |
41 | | - |
42 | | - .mat-mdc-unelevated-button .mat-mdc-focus-indicator::before, |
43 | | - .mat-mdc-raised-button .mat-mdc-focus-indicator::before, |
44 | | - .mdc-fab .mat-mdc-focus-indicator::before, |
45 | | - .mat-mdc-chip-action-label .mat-mdc-focus-indicator::before { |
46 | | - margin: -($border-width + 2px); |
47 | | - } |
48 | | - |
49 | | - .mat-mdc-outlined-button .mat-mdc-focus-indicator::before { |
50 | | - margin: -($border-width + 3px); |
51 | | - } |
52 | | - |
53 | | - .mat-mdc-focus-indicator.mat-mdc-chip-remove::before { |
54 | | - margin: -$border-width; |
55 | | - } |
56 | | - |
57 | | - // MDC sets a padding a on the button which stretches out the focus indicator. |
58 | | - .mat-mdc-focus-indicator.mat-mdc-chip-remove::before { |
59 | | - left: 8px; |
60 | | - right: 8px; |
61 | | - } |
62 | | - |
63 | | - .mat-mdc-focus-indicator.mat-mdc-tab::before, |
64 | | - .mat-mdc-focus-indicator.mat-mdc-tab-link::before { |
65 | | - margin: 5px; |
66 | | - } |
67 | | - |
68 | | - // These components have to set `border-radius: 50%` in order to support density scaling |
69 | | - // which will clip a square focus indicator so we have to turn it into a circle. |
70 | | - .mat-mdc-checkbox-ripple.mat-mdc-focus-indicator::before, |
71 | | - .mat-radio-ripple.mat-mdc-focus-indicator::before, |
72 | | - .mat-mdc-slider .mat-mdc-focus-indicator::before, |
73 | | - .mat-mdc-slide-toggle .mat-mdc-focus-indicator::before { |
74 | | - border-radius: 50%; |
75 | | - } |
76 | | - |
77 | | - // Render the focus indicator on focus. Defining a pseudo element's |
78 | | - // content will cause it to render. |
79 | | - |
80 | | - // For checkboxes, radios and slide toggles, render the focus indicator when we know |
81 | | - // the hidden input is focused (slightly different for each control). |
82 | | - .mdc-checkbox__native-control:focus ~ .mat-mdc-focus-indicator::before, |
83 | | - .mat-mdc-slide-toggle-focused .mat-mdc-focus-indicator::before, |
84 | | - .mat-mdc-radio-button.cdk-focused .mat-mdc-focus-indicator::before, |
85 | | - |
86 | | - // In the chips the individual actions have focus so we target a different element. |
87 | | - .mat-mdc-chip-action:focus .mat-mdc-focus-indicator::before, |
88 | | - |
89 | | - // For buttons and list items, render the focus indicator when the parent |
90 | | - // button or list item is focused. |
91 | | - .mat-mdc-button-base:focus .mat-mdc-focus-indicator::before, |
92 | | - .mat-mdc-list-item:focus > .mat-mdc-focus-indicator::before, |
93 | | - |
94 | | - // For options, render the focus indicator when the class .mat-mdc-option-active is present. |
95 | | - .mat-mdc-focus-indicator.mat-mdc-option-active::before, |
96 | | - |
97 | | - // In the MDC slider the focus indicator is inside the thumb. |
98 | | - .mdc-slider__thumb--focused .mat-mdc-focus-indicator::before, |
99 | 13 |
|
100 | | - // For all other components, render the focus indicator on focus. |
101 | | - .mat-mdc-focus-indicator:focus::before { |
102 | | - content: ''; |
103 | | - } |
| 14 | + @include mat.focus-indicators-private-private-customize-focus-indicators($config, 'mat-mdc'); |
104 | 15 | } |
0 commit comments