Skip to content

Commit a9da72e

Browse files
authored
fix(multiple): consolidate strong focus indicators (angular#29623)
We currently ship two strong focus indicator variants. This is a leftover from when we had two sets of components. These changes combine them into one and under the `mat-` prefix.
1 parent 64ed7ca commit a9da72e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+77
-162
lines changed

src/material/_index.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
// Structural
3939
@forward './core/core' show core;
4040
@forward './core/ripple/ripple' show ripple;
41-
@forward './core/focus-indicators/focus-indicators' show strong-focus-indicators;
42-
@forward './core/focus-indicators/private' as private-strong-focus-indicators-*;
41+
@forward './core/focus-indicators/private' show strong-focus-indicators,
42+
strong-focus-indicators-color, strong-focus-indicators-theme;
4343
@forward './core/style/elevation' show elevation, overridable-elevation, elevation-transition;
4444

4545
// Theme bundles
@@ -61,8 +61,6 @@
6161
pseudo-checkbox-base, pseudo-checkbox-overrides;
6262
@forward './core/selection/pseudo-checkbox/pseudo-checkbox-common' as pseudo-checkbox-* show
6363
pseudo-checkbox-legacy-size;
64-
@forward './core/focus-indicators/focus-indicators-theme' as strong-focus-indicators-* show
65-
strong-focus-indicators-color, strong-focus-indicators-theme;
6664
@forward './autocomplete/autocomplete-theme' as autocomplete-* show autocomplete-theme,
6765
autocomplete-color, autocomplete-typography, autocomplete-density, autocomplete-base,
6866
autocomplete-overrides;

src/material/button/_button-base.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
}
4949

5050
// The focus indicator should match the bounds of the entire button.
51-
.mat-mdc-focus-indicator {
51+
.mat-focus-indicator {
5252
@include layout-common.fill();
5353
}
5454

55-
&:focus .mat-mdc-focus-indicator::before {
55+
&:focus .mat-focus-indicator::before {
5656
content: '';
5757
}
5858
}

src/material/button/button.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
The indicator can't be directly on the button, because MDC uses ::before for high contrast
1616
indication and it can't be on the ripple, because it has a border radius and overflow: hidden.
1717
-->
18-
<span class="mat-mdc-focus-indicator"></span>
18+
<span class="mat-focus-indicator"></span>
1919

2020
<span class="mat-mdc-button-touch-target"></span>

src/material/button/button.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,17 @@
315315
// the focus indicator is sufficiently contrastive and renders appropriately.
316316
.mat-mdc-unelevated-button,
317317
.mat-mdc-raised-button {
318-
.mat-mdc-focus-indicator::before {
318+
.mat-focus-indicator::before {
319319
$default-border-width: focus-indicators-private.$default-border-width;
320-
$border-width: var(--mat-mdc-focus-indicator-border-width, #{$default-border-width});
320+
$border-width: var(--mat-focus-indicator-border-width, #{$default-border-width});
321321
$offset: calc(#{$border-width} + 2px);
322322
margin: calc(#{$offset} * -1);
323323
}
324324
}
325325

326-
.mat-mdc-outlined-button .mat-mdc-focus-indicator::before {
326+
.mat-mdc-outlined-button .mat-focus-indicator::before {
327327
$default-border-width: focus-indicators-private.$default-border-width;
328-
$border-width: var(--mat-mdc-focus-indicator-border-width, #{$default-border-width});
328+
$border-width: var(--mat-focus-indicator-border-width, #{$default-border-width});
329329
$offset: calc(#{$border-width} + 3px);
330330
margin: calc(#{$offset} * -1);
331331
}

src/material/button/button.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ describe('MatButton', () => {
285285
];
286286

287287
expect(
288-
buttonNativeElements.every(element => !!element.querySelector('.mat-mdc-focus-indicator')),
288+
buttonNativeElements.every(element => !!element.querySelector('.mat-focus-indicator')),
289289
).toBe(true);
290290
});
291291

src/material/button/fab.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@
8181
will-change: transform;
8282
}
8383

84-
.mat-mdc-focus-indicator::before {
84+
.mat-focus-indicator::before {
8585
$default-border-width: focus-indicators-private.$default-border-width;
86-
$border-width: var(--mat-mdc-focus-indicator-border-width, #{$default-border-width});
86+
$border-width: var(--mat-focus-indicator-border-width, #{$default-border-width});
8787
$offset: calc(#{$border-width} + 2px);
8888
margin: calc(#{$offset} * -1);
8989
}

src/material/button/icon-button.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
The indicator can't be directly on the button, because MDC uses ::before for high contrast
77
indication and it can't be on the ripple, because it has a border radius and overflow: hidden.
88
-->
9-
<span class="mat-mdc-focus-indicator"></span>
9+
<span class="mat-focus-indicator"></span>
1010

1111
<span class="mat-mdc-button-touch-target"></span>

src/material/checkbox/checkbox.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</svg>
3535
<div class="mdc-checkbox__mixedmark"></div>
3636
</div>
37-
<div class="mat-mdc-checkbox-ripple mat-mdc-focus-indicator" mat-ripple
37+
<div class="mat-mdc-checkbox-ripple mat-focus-indicator" mat-ripple
3838
[matRippleTrigger]="checkbox"
3939
[matRippleDisabled]="disableRipple || disabled"
4040
[matRippleCentered]="true"></div>

src/material/checkbox/checkbox.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@
114114

115115
// For checkboxes render the focus indicator when we know
116116
// the hidden input is focused (slightly different for each control).
117-
.mdc-checkbox__native-control:focus ~ .mat-mdc-focus-indicator::before {
117+
.mdc-checkbox__native-control:focus ~ .mat-focus-indicator::before {
118118
content: '';
119119
}

src/material/checkbox/checkbox.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ describe('MatCheckbox', () => {
674674
'.mat-mdc-checkbox-ripple',
675675
)!;
676676

677-
expect(checkboxRippleNativeElement.classList.contains('mat-mdc-focus-indicator')).toBe(true);
677+
expect(checkboxRippleNativeElement.classList.contains('mat-focus-indicator')).toBe(true);
678678
});
679679
});
680680

0 commit comments

Comments
 (0)