Skip to content

Commit 6a8c965

Browse files
authored
fix(material/core): Focus indicator theme and color mixins should accept a basic color as well. (#23016)
fix(core/material): Disable styelint for focus indicator theme mixins.
1 parent 4caf039 commit 6a8c965

File tree

4 files changed

+58
-24
lines changed

4 files changed

+58
-24
lines changed
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
@use 'sass:map';
2+
@use 'sass:meta';
23
@use '../../material/core/theming/theming';
34

4-
@mixin color($config-or-theme) {
5-
$config: theming.get-color-config($config-or-theme);
6-
$border-color: theming.get-color-from-palette(map.get($config, primary));
7-
5+
@mixin _border-color($color) {
86
.mat-mdc-focus-indicator::before {
9-
border-color: $border-color;
7+
border-color: $color;
8+
}
9+
}
10+
11+
// stylelint-disable-next-line material/theme-mixin-api
12+
@mixin color($config-or-theme-or-color) {
13+
@if meta.type-of($config-or-theme-or-color) == 'color' {
14+
@include _border-color($config-or-theme-or-color);
15+
}
16+
@else {
17+
$config: theming.get-color-config($config-or-theme-or-color);
18+
$border-color: theming.get-color-from-palette(map.get($config, primary));
19+
@include _border-color($border-color);
1020
}
1121
}
1222

13-
@mixin theme($theme-or-color-config) {
14-
$theme: theming.private-legacy-get-theme($theme-or-color-config);
15-
@include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-focus-indicators') {
16-
$color: theming.get-color-config($theme);
17-
@if $color != null {
18-
@include color($color);
23+
// stylelint-disable-next-line material/theme-mixin-api
24+
@mixin theme($theme-or-color-config-or-color) {
25+
@if meta.type-of($theme-or-color-config-or-color) == 'color' {
26+
@include _border-color($theme-or-color-config-or-color);
27+
}
28+
@else {
29+
$theme: theming.private-legacy-get-theme($theme-or-color-config-or-color);
30+
@include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-focus-indicators') {
31+
$color: theming.get-color-config($theme);
32+
@if $color != null {
33+
@include color($color);
34+
}
1935
}
2036
}
2137
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
@forward 'focus-indicators' hide strong-focus-indicators;
33
@forward 'focus-indicators-theme' hide color, theme;
44
@forward 'focus-indicators' as mat-mdc-*;
5-
@forward 'focus-indicators-theme' as mat-mdc-strong-focus-indicators-*;
5+
@forward 'focus-indicators-theme' as mat-mdc-strong-focus-indicators-* hide
6+
mat-mdc-strong-focus-indicators-border-color;
67

78
@import '../../material/core/theming/theming';
89
@import '../../material/core/style/layout-common';
Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
@use 'sass:map';
2+
@use 'sass:meta';
23
@use '../theming/theming';
34

4-
@mixin color($config-or-theme) {
5-
$config: theming.get-color-config($config-or-theme);
6-
$border-color: theming.get-color-from-palette(map.get($config, primary));
7-
5+
@mixin _border-color($color) {
86
.mat-focus-indicator::before {
9-
border-color: $border-color;
7+
border-color: $color;
8+
}
9+
}
10+
11+
// stylelint-disable-next-line material/theme-mixin-api
12+
@mixin color($config-or-theme-or-color) {
13+
@if meta.type-of($config-or-theme-or-color) == 'color' {
14+
@include _border-color($config-or-theme-or-color);
15+
}
16+
@else {
17+
$config: theming.get-color-config($config-or-theme-or-color);
18+
$border-color: theming.get-color-from-palette(map.get($config, primary));
19+
@include _border-color($border-color);
1020
}
1121
}
1222

13-
@mixin theme($theme-or-color-config) {
14-
$theme: theming.private-legacy-get-theme($theme-or-color-config);
15-
@include theming.private-check-duplicate-theme-styles($theme, 'mat-focus-indicators') {
16-
$color: theming.get-color-config($theme);
17-
@if $color != null {
18-
@include color($color);
23+
// stylelint-disable-next-line material/theme-mixin-api
24+
@mixin theme($theme-or-color-config-or-color) {
25+
@if meta.type-of($theme-or-color-config-or-color) == 'color' {
26+
@include _border-color($theme-or-color-config-or-color);
27+
}
28+
@else {
29+
$theme: theming.private-legacy-get-theme($theme-or-color-config-or-color);
30+
@include theming.private-check-duplicate-theme-styles($theme, 'mat-focus-indicators') {
31+
$color: theming.get-color-config($theme);
32+
@if $color != null {
33+
@include color($color);
34+
}
1935
}
2036
}
2137
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ $mat-white-6-opacity, $mat-white-87-opacity;
1616
strong-focus-indicators;
1717
@forward 'focus-indicators-theme' hide color, theme;
1818
@forward 'focus-indicators' as mat-*;
19-
@forward 'focus-indicators-theme' as mat-strong-focus-indicators-*;
19+
@forward 'focus-indicators-theme' as mat-strong-focus-indicators-* hide
20+
mat-strong-focus-indicators-border-color;
2021

2122
@import '../theming/theming';
2223
@import '../style/layout-common';

0 commit comments

Comments
 (0)