Skip to content

Commit

Permalink
fix(material/core): Focus indicator theme and color mixins should acc…
Browse files Browse the repository at this point in the history
…ept a basic color as well. (#23016)

fix(core/material): Disable styelint for focus indicator theme mixins.
  • Loading branch information
zelliott committed Jun 22, 2021
1 parent 4caf039 commit 6a8c965
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 24 deletions.
38 changes: 27 additions & 11 deletions src/material-experimental/mdc-helpers/_focus-indicators-theme.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
@use 'sass:map';
@use 'sass:meta';
@use '../../material/core/theming/theming';

@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);
$border-color: theming.get-color-from-palette(map.get($config, primary));

@mixin _border-color($color) {
.mat-mdc-focus-indicator::before {
border-color: $border-color;
border-color: $color;
}
}

// stylelint-disable-next-line material/theme-mixin-api
@mixin color($config-or-theme-or-color) {
@if meta.type-of($config-or-theme-or-color) == 'color' {
@include _border-color($config-or-theme-or-color);
}
@else {
$config: theming.get-color-config($config-or-theme-or-color);
$border-color: theming.get-color-from-palette(map.get($config, primary));
@include _border-color($border-color);
}
}

@mixin theme($theme-or-color-config) {
$theme: theming.private-legacy-get-theme($theme-or-color-config);
@include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-focus-indicators') {
$color: theming.get-color-config($theme);
@if $color != null {
@include color($color);
// stylelint-disable-next-line material/theme-mixin-api
@mixin theme($theme-or-color-config-or-color) {
@if meta.type-of($theme-or-color-config-or-color) == 'color' {
@include _border-color($theme-or-color-config-or-color);
}
@else {
$theme: theming.private-legacy-get-theme($theme-or-color-config-or-color);
@include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-focus-indicators') {
$color: theming.get-color-config($theme);
@if $color != null {
@include color($color);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
@forward 'focus-indicators' hide strong-focus-indicators;
@forward 'focus-indicators-theme' hide color, theme;
@forward 'focus-indicators' as mat-mdc-*;
@forward 'focus-indicators-theme' as mat-mdc-strong-focus-indicators-*;
@forward 'focus-indicators-theme' as mat-mdc-strong-focus-indicators-* hide
mat-mdc-strong-focus-indicators-border-color;

@import '../../material/core/theming/theming';
@import '../../material/core/style/layout-common';
Expand Down
38 changes: 27 additions & 11 deletions src/material/core/focus-indicators/_focus-indicators-theme.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
@use 'sass:map';
@use 'sass:meta';
@use '../theming/theming';

@mixin color($config-or-theme) {
$config: theming.get-color-config($config-or-theme);
$border-color: theming.get-color-from-palette(map.get($config, primary));

@mixin _border-color($color) {
.mat-focus-indicator::before {
border-color: $border-color;
border-color: $color;
}
}

// stylelint-disable-next-line material/theme-mixin-api
@mixin color($config-or-theme-or-color) {
@if meta.type-of($config-or-theme-or-color) == 'color' {
@include _border-color($config-or-theme-or-color);
}
@else {
$config: theming.get-color-config($config-or-theme-or-color);
$border-color: theming.get-color-from-palette(map.get($config, primary));
@include _border-color($border-color);
}
}

@mixin theme($theme-or-color-config) {
$theme: theming.private-legacy-get-theme($theme-or-color-config);
@include theming.private-check-duplicate-theme-styles($theme, 'mat-focus-indicators') {
$color: theming.get-color-config($theme);
@if $color != null {
@include color($color);
// stylelint-disable-next-line material/theme-mixin-api
@mixin theme($theme-or-color-config-or-color) {
@if meta.type-of($theme-or-color-config-or-color) == 'color' {
@include _border-color($theme-or-color-config-or-color);
}
@else {
$theme: theming.private-legacy-get-theme($theme-or-color-config-or-color);
@include theming.private-check-duplicate-theme-styles($theme, 'mat-focus-indicators') {
$color: theming.get-color-config($theme);
@if $color != null {
@include color($color);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ $mat-white-6-opacity, $mat-white-87-opacity;
strong-focus-indicators;
@forward 'focus-indicators-theme' hide color, theme;
@forward 'focus-indicators' as mat-*;
@forward 'focus-indicators-theme' as mat-strong-focus-indicators-*;
@forward 'focus-indicators-theme' as mat-strong-focus-indicators-* hide
mat-strong-focus-indicators-border-color;

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

0 comments on commit 6a8c965

Please sign in to comment.