diff --git a/src/demo-app/select/select-demo.html b/src/demo-app/select/select-demo.html
index f5cddc897323..7b9c87a3ccfe 100644
--- a/src/demo-app/select/select-demo.html
+++ b/src/demo-app/select/select-demo.html
@@ -4,7 +4,7 @@
+ + +
@@ -33,7 +39,7 @@Touched: {{ pokemonControl.touched }}
Dirty: {{ pokemonControl.dirty }}
Status: {{ pokemonControl.control?.status }}
++ + +
diff --git a/src/demo-app/select/select-demo.ts b/src/demo-app/select/select-demo.ts index 04813bdae4e9..6e2ff635a202 100644 --- a/src/demo-app/select/select-demo.ts +++ b/src/demo-app/select/select-demo.ts @@ -19,6 +19,8 @@ export class SelectDemo { latestChangeEvent: MdSelectChange; floatPlaceholder: string = 'auto'; foodControl = new FormControl('pizza-1'); + drinksTheme = 'primary'; + pokemonTheme = 'primary'; foods = [ {value: 'steak-0', viewValue: 'Steak'}, @@ -48,6 +50,12 @@ export class SelectDemo { {value: 'psyduck-6', viewValue: 'Psyduck'}, ]; + availableThemes = [ + {value: 'primary', name: 'Primary' }, + {value: 'accent', name: 'Accent' }, + {value: 'warn', name: 'Warn' } + ]; + toggleDisabled() { this.foodControl.enabled ? this.foodControl.disable() : this.foodControl.enable(); } diff --git a/src/lib/core/option/_option-theme.scss b/src/lib/core/option/_option-theme.scss index 499b41c7a989..01fcc8585fd2 100644 --- a/src/lib/core/option/_option-theme.scss +++ b/src/lib/core/option/_option-theme.scss @@ -5,19 +5,29 @@ $foreground: map-get($theme, foreground); $background: map-get($theme, background); $primary: map-get($theme, primary); + $accent: map-get($theme, accent); + $warn: map-get($theme, warn); .mat-option { &:hover:not(.mat-option-disabled), &:focus:not(.mat-option-disabled) { background: mat-color($background, hover); } - &.mat-selected { + &.mat-selected.mat-primary, .mat-primary &.mat-selected { color: mat-color($primary); + } + + &.mat-selected.mat-accent, .mat-accent &.mat-selected { + color: mat-color($accent); + } - // In multiple mode there is a checkbox to show that the option is selected. - &:not(.mat-option-multiple) { - background: mat-color($background, hover); - } + &.mat-selected.mat-warn, .mat-warn &.mat-selected { + color: mat-color($warn); + } + + // In multiple mode there is a checkbox to show that the option is selected. + &.mat-selected:not(.mat-option-multiple) { + background: mat-color($background, hover); } &.mat-active { @@ -28,6 +38,5 @@ &.mat-option-disabled { color: mat-color($foreground, hint-text); } - } } diff --git a/src/lib/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss b/src/lib/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss index 118235123d26..260b8d1601f1 100644 --- a/src/lib/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss +++ b/src/lib/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss @@ -1,5 +1,16 @@ @import '../../theming/theming'; +@mixin _mat-pseudo-checkbox-inner-content-theme($theme, $pallete-name) { + $pallete: map-get($theme, $pallete-name); + $color: mat-color($pallete, 500); + + .mat-pseudo-checkbox-checked.mat-#{$pallete-name}, + .mat-pseudo-checkbox-indeterminate.mat-#{$pallete-name}, + .mat-#{$pallete-name} .mat-pseudo-checkbox-checked, + .mat-#{$pallete-name} .mat-pseudo-checkbox-indeterminate { + background: $color; + } +} @mixin mat-pseudo-checkbox-theme($theme) { $is-dark-theme: map-get($theme, is-dark); @@ -14,6 +25,7 @@ $white-30pct-opacity-on-dark: #686868; $black-26pct-opacity-on-light: #b0b0b0; $disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light); + $colored-box-selector: '.mat-pseudo-checkbox-checked, .mat-pseudo-checkbox-indeterminate'; .mat-pseudo-checkbox { color: mat-color(map-get($theme, foreground), secondary-text); @@ -23,19 +35,11 @@ } } - .mat-pseudo-checkbox-checked, .mat-pseudo-checkbox-indeterminate { - &.mat-primary { - background: mat-color($primary, 500); - } - - &.mat-accent { - background: mat-color($accent, 500); - } - - &.mat-warn { - background: mat-color($warn, 500); - } + @include _mat-pseudo-checkbox-inner-content-theme($theme, primary); + @include _mat-pseudo-checkbox-inner-content-theme($theme, accent); + @include _mat-pseudo-checkbox-inner-content-theme($theme, warn); + .mat-pseudo-checkbox-checked, .mat-pseudo-checkbox-indeterminate { &.mat-pseudo-checkbox-disabled { background: $disabled-color; } diff --git a/src/lib/select/_select-theme.scss b/src/lib/select/_select-theme.scss index 09e7849932e6..d996f4de8165 100644 --- a/src/lib/select/_select-theme.scss +++ b/src/lib/select/_select-theme.scss @@ -1,46 +1,33 @@ @import '../core/theming/palette'; @import '../core/theming/theming'; +@mixin _mat-select-inner-content-theme($palette) { + $color: mat-color($palette); + + .mat-select-trigger, .mat-select-arrow { + color: $color; + } + + .mat-select-underline { + background-color: $color; + } +} + @mixin mat-select-theme($theme) { $foreground: map-get($theme, foreground); $background: map-get($theme, background); $primary: map-get($theme, primary); + $accent: map-get($theme, accent); $warn: map-get($theme, warn); - .mat-select-trigger { - color: mat-color($foreground, hint-text); - - .mat-select:focus:not(.mat-select-disabled) & { - color: mat-color($primary); - } - - .mat-select:not(:focus).ng-invalid.ng-touched:not(.mat-select-disabled) & { - color: mat-color($warn); - } - } - .mat-select-underline { background-color: mat-color($foreground, divider); - - .mat-select:focus:not(.mat-select-disabled) & { - background-color: mat-color($primary); - } - - .mat-select:not(:focus).ng-invalid.ng-touched:not(.mat-select-disabled) & { - background-color: mat-color($warn); - } } - .mat-select-arrow { + .mat-select-disabled .mat-select-value, + .mat-select-arrow, + .mat-select-trigger { color: mat-color($foreground, hint-text); - - .mat-select:focus:not(.mat-select-disabled) & { - color: mat-color($primary); - } - - .mat-select:not(:focus).ng-invalid.ng-touched:not(.mat-select-disabled) & { - color: mat-color($warn); - } } .mat-select-content, .mat-select-panel-done-animating { @@ -49,9 +36,20 @@ .mat-select-value { color: mat-color($foreground, text); + } - .mat-select-disabled & { - color: mat-color($foreground, hint-text); + .mat-select:focus:not(.mat-select-disabled) { + &.mat-primary { + @include _mat-select-inner-content-theme($primary); } + + &.mat-accent { + @include _mat-select-inner-content-theme($accent); + } + } + + .mat-select:focus:not(.mat-select-disabled).mat-warn, + .mat-select:not(:focus).ng-invalid.ng-touched:not(.mat-select-disabled) { + @include _mat-select-inner-content-theme($warn); } } diff --git a/src/lib/select/select.html b/src/lib/select/select.html index c31a4b3f3518..917a89d9c20a 100644 --- a/src/lib/select/select.html +++ b/src/lib/select/select.html @@ -18,7 +18,7 @@ [offsetY]="_offsetY" [offsetX]="_offsetX" (attach)="_setScrollTop()" (detach)="close()">