Skip to content

Commit fa40336

Browse files
committed
fix(material/core): Focus indicator theme and color mixins should accept a basic color as well.
1 parent 2cd745a commit fa40336

File tree

4 files changed

+54
-24
lines changed

4 files changed

+54
-24
lines changed
Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
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+
@mixin color($config-or-theme-or-color) {
12+
@if meta.type-of($config-or-theme-or-color) == 'color' {
13+
@include _border-color($config-or-theme-or-color);
14+
}
15+
@else {
16+
$config: theming.get-color-config($config-or-theme-or-color);
17+
$border-color: theming.get-color-from-palette(map.get($config, primary));
18+
@include _border-color($border-color);
1019
}
1120
}
1221

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);
22+
@mixin theme($theme-or-color-config-or-color) {
23+
@if meta.type-of($theme-or-color-config-or-color) == 'color' {
24+
@include _border-color($theme-or-color-config-or-color);
25+
}
26+
@else {
27+
$theme: theming.private-legacy-get-theme($theme-or-color-config-or-color);
28+
@include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-focus-indicators') {
29+
$color: theming.get-color-config($theme);
30+
@if $color != null {
31+
@include color($color);
32+
}
1933
}
2034
}
2135
}

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: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
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+
@mixin color($config-or-theme-or-color) {
12+
@if meta.type-of($config-or-theme-or-color) == 'color' {
13+
@include _border-color($config-or-theme-or-color);
14+
}
15+
@else {
16+
$config: theming.get-color-config($config-or-theme-or-color);
17+
$border-color: theming.get-color-from-palette(map.get($config, primary));
18+
@include _border-color($border-color);
1019
}
1120
}
1221

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);
22+
@mixin theme($theme-or-color-config-or-color) {
23+
@if meta.type-of($theme-or-color-config-or-color) == 'color' {
24+
@include _border-color($theme-or-color-config-or-color);
25+
}
26+
@else {
27+
$theme: theming.private-legacy-get-theme($theme-or-color-config-or-color);
28+
@include theming.private-check-duplicate-theme-styles($theme, 'mat-focus-indicators') {
29+
$color: theming.get-color-config($theme);
30+
@if $color != null {
31+
@include color($color);
32+
}
1933
}
2034
}
2135
}

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)