Skip to content

Commit a0c7736

Browse files
committed
refactor(cdk/a11y): Refactor focus indicator theme mixins to match other theme mixins
1 parent bf99037 commit a0c7736

File tree

5 files changed

+22
-73
lines changed

5 files changed

+22
-73
lines changed

src/dev-app/theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ $candy-app-theme: mat.define-light-theme((
6565
@include mdc-slider-theme.color($dark-colors);
6666

6767
// Include the dark theme colors for focus indicators.
68-
.demo-strong-focus {
68+
&.demo-strong-focus {
6969
@include mat.strong-focus-indicators-color($dark-colors);
7070
@include experimental.mdc-strong-focus-indicators-color($dark-colors);
7171
}

src/material-experimental/mdc-helpers/_focus-indicators-theme.scss

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,21 @@
22
@use 'sass:map';
33
@use '../../material/core/theming/theming';
44

5-
// Mixin that applies the border color for the focus indicators.
6-
@mixin _border-color($color) {
7-
.mat-mdc-focus-indicator::before {
8-
border-color: $color;
9-
}
10-
}
11-
125
@mixin color($config-or-theme) {
136
$config: theming.get-color-config($config-or-theme);
147
$border-color: theming.get-color-from-palette(map.get($config, primary));
15-
@include _border-color($border-color);
16-
}
178

18-
/// Mixin that sets the color of the focus indicators.
19-
///
20-
/// @param {color|map} $theme-or-color
21-
/// If theme, focus indicators are set to the primary color of the theme. If
22-
/// color, focus indicators are set to that color.
23-
///
24-
/// @example
25-
/// .demo-dark-theme {
26-
/// @include mat-mdc-strong-focus-indicators-theme($dark-theme-map);
27-
/// }
28-
///
29-
/// @example
30-
/// .demo-red-theme {
31-
/// @include mat-mdc-strong-focus-indicators-theme(#f00);
32-
/// }
33-
// stylelint-disable-next-line material/theme-mixin-api
34-
@mixin theme($theme-or-color) {
35-
@if meta.type-of($theme-or-color) != 'map' {
36-
@include _border-color($theme-or-color);
9+
.mat-mdc-focus-indicator::before {
10+
border-color: $border-color;
3711
}
38-
@else {
39-
$theme: theming.private-legacy-get-theme($theme-or-color);
40-
@include theming.private-check-duplicate-theme-styles($theme,
41-
'mat-mdc-strong-focus-indicators') {
42-
$color: theming.get-color-config($theme);
43-
@if $color != null {
44-
@include color($color);
45-
}
12+
}
13+
14+
@mixin theme($theme-or-color-config) {
15+
$theme: theming.private-legacy-get-theme($theme-or-color-config);
16+
@include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-strong-focus-indicators') {
17+
$color: theming.get-color-config($theme);
18+
@if $color != null {
19+
@include color($color);
4620
}
4721
}
4822
}

src/material-experimental/mdc-helpers/_focus-indicators.import.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@forward '../../material/core/focus-indicators/focus-indicators.import';
22
@forward 'focus-indicators' hide strong-focus-indicators;
33
@forward 'focus-indicators-theme' hide color, theme;
4-
@forward 'focus-indicators' as mat-mdc-* hide mat-mdc-strong-focus-indicators-border-color;
4+
@forward 'focus-indicators' as mat-mdc-*;
55
@forward 'focus-indicators-theme' as mat-mdc-strong-focus-indicators-*;
66

77
@import '../../material/core/theming/theming';

src/material/core/focus-indicators/_focus-indicators-theme.scss

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,18 @@
55
@mixin color($config-or-theme) {
66
$config: theming.get-color-config($config-or-theme);
77
$border-color: theming.get-color-from-palette(map.get($config, primary));
8-
@include _border-color($border-color);
9-
}
108

11-
/// Mixin that sets the color of the focus indicators.
12-
///
13-
/// @param {color|map} $theme-or-color
14-
/// If theme, focus indicators are set to the primary color of the theme. If
15-
/// color, focus indicators are set to that color.
16-
///
17-
/// @example
18-
/// .demo-dark-theme {
19-
/// @include mat-strong-focus-indicators-theme($dark-theme-map);
20-
/// }
21-
///
22-
/// @example
23-
/// .demo-red-theme {
24-
/// @include mat-strong-focus-indicators-theme(#f00);
25-
/// }
26-
// stylelint-disable-next-line material/theme-mixin-api
27-
@mixin theme($theme-or-color) {
28-
@if meta.type-of($theme-or-color) != 'map' {
29-
@include _border-color($theme-or-color);
30-
}
31-
@else {
32-
$theme: theming.private-legacy-get-theme($theme-or-color);
33-
@include theming.private-check-duplicate-theme-styles($theme, 'mat-strong-focus-indicators') {
34-
$color: theming.get-color-config($theme);
35-
@if $color != null {
36-
@include color($color);
37-
}
38-
}
9+
.mat-focus-indicator::before {
10+
border-color: $border-color;
3911
}
4012
}
4113

42-
// Mixin that applies the border color for the focus indicators.
43-
@mixin _border-color($color) {
44-
.mat-focus-indicator::before {
45-
border-color: $color;
14+
@mixin theme($theme-or-color-config) {
15+
$theme: theming.private-legacy-get-theme($theme-or-color-config);
16+
@include theming.private-check-duplicate-theme-styles($theme, 'mat-strong-focus-indicators') {
17+
$color: theming.get-color-config($theme);
18+
@if $color != null {
19+
@include color($color);
20+
}
4621
}
4722
}

src/material/core/focus-indicators/_focus-indicators.import.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $mat-white-6-opacity, $mat-white-87-opacity;
1515
@forward 'focus-indicators' hide private-strong-focus-indicators-positioning,
1616
strong-focus-indicators;
1717
@forward 'focus-indicators-theme' hide color, theme;
18-
@forward 'focus-indicators' as mat-* hide mat-strong-focus-indicators-border-color;
18+
@forward 'focus-indicators' as mat-*;
1919
@forward 'focus-indicators-theme' as mat-strong-focus-indicators-*;
2020

2121
@import '../theming/theming';

0 commit comments

Comments
 (0)