Skip to content

Commit 95e35b1

Browse files
committed
fix floating placehodler and color
1 parent f98c567 commit 95e35b1

File tree

6 files changed

+42
-42
lines changed

6 files changed

+42
-42
lines changed

src/demo-app/select/select-demo.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<md-card>
77
<md-card-subtitle>ngModel</md-card-subtitle>
88

9-
<md-form-field>
10-
<md-select placeholder="Drink" [color]="drinksTheme" [(ngModel)]="currentDrink" [required]="drinksRequired"
9+
<md-form-field [floatPlaceholder]="floatPlaceholder" [color]="drinksTheme">
10+
<md-select placeholder="Drink" [(ngModel)]="currentDrink" [required]="drinksRequired"
1111
[disabled]="drinksDisabled" #drinkControl="ngModel">
1212
<md-option>None</md-option>
1313
<md-option *ngFor="let drink of drinks" [value]="drink.value" [disabled]="drink.disabled">
@@ -44,8 +44,8 @@
4444
<md-card-subtitle>Multiple selection</md-card-subtitle>
4545

4646
<md-card-content>
47-
<md-form-field>
48-
<md-select multiple [color]="pokemonTheme" placeholder="Pokemon" [(ngModel)]="currentPokemon"
47+
<md-form-field [color]="pokemonTheme">
48+
<md-select multiple placeholder="Pokemon" [(ngModel)]="currentPokemon"
4949
[required]="pokemonRequired" [disabled]="pokemonDisabled" #pokemonControl="ngModel">
5050
<md-option *ngFor="let creature of pokemon" [value]="creature.value">
5151
{{ creature.viewValue }}
@@ -109,9 +109,11 @@
109109
<md-card-subtitle>formControl</md-card-subtitle>
110110

111111
<md-card-content>
112-
<md-select placeholder="Food i would like to eat" [formControl]="foodControl">
113-
<md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }}</md-option>
114-
</md-select>
112+
<md-form-field>
113+
<md-select placeholder="Food i would like to eat" [formControl]="foodControl">
114+
<md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }}</md-option>
115+
</md-select>
116+
</md-form-field>
115117
<p> Value: {{ foodControl.value }} </p>
116118
<p> Touched: {{ foodControl.touched }} </p>
117119
<p> Dirty: {{ foodControl.dirty }} </p>

src/demo-app/select/select-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class SelectDemo {
1919
currentPokemonFromGroup: string;
2020
currentDigimon: string;
2121
latestChangeEvent: MdSelectChange;
22-
floatPlaceholder: string = 'auto'; // add to form-field
22+
floatPlaceholder: string = 'auto';
2323
foodControl = new FormControl('pizza-1');
2424
topHeightCtrl = new FormControl(0);
2525
drinksTheme = 'primary';

src/lib/form-field/form-field.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ let nextUniqueId = 0;
7272
'[class.mat-input-invalid]': '_control.errorState',
7373
'[class.mat-form-field-invalid]': '_control.errorState',
7474
'[class.mat-focused]': '_control.focused',
75+
'[class.mat-primary]': 'color == "primary"',
76+
'[class.mat-accent]': 'color == "accent"',
77+
'[class.mat-warn]': 'color == "warn"',
7578
'[class.ng-untouched]': '_shouldForward("untouched")',
7679
'[class.ng-touched]': '_shouldForward("touched")',
7780
'[class.ng-pristine]': '_shouldForward("pristine")',

src/lib/select/_select-theme.scss

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
@import '../core/style/form-common';
44
@import '../core/typography/typography-utils';
55

6-
@mixin _mat-select-inner-content-theme($palette) {
7-
$color: mat-color($palette);
8-
9-
.mat-select-trigger, .mat-select-arrow {
10-
color: $color;
11-
}
12-
}
136

147
@mixin mat-select-theme($theme) {
158
$foreground: map-get($theme, foreground);
@@ -19,14 +12,8 @@
1912
$warn: map-get($theme, warn);
2013
$is-dark-theme: map-get($theme, is-dark);
2114

22-
.mat-select-trigger,
23-
.mat-select-arrow {
24-
color: mat-color($foreground, secondary-text);
25-
}
26-
2715
.mat-select-disabled .mat-select-value,
28-
.mat-select-arrow,
29-
.mat-select-trigger {
16+
.mat-select-arrow {
3017
color: mat-color($foreground, secondary-text);
3118
}
3219

@@ -44,23 +31,32 @@
4431
}
4532
}
4633

47-
.mat-select:focus:not(.mat-select-disabled) {
48-
&.mat-primary {
49-
@include _mat-select-inner-content-theme($primary);
34+
.mat-form-field {
35+
&.mat-focused {
36+
&.mat-primary .mat-select-arrow {
37+
color: mat-color($primary);
38+
}
39+
40+
&.mat-accent .mat-select-arrow {
41+
color: mat-color($accent);
42+
}
43+
44+
&.mat-warn .mat-select-arrow {
45+
color: mat-color($warn);
46+
}
5047
}
5148

52-
&.mat-accent {
53-
@include _mat-select-inner-content-theme($accent);
49+
.mat-select.mat-select-invalid .mat-select-arrow {
50+
color: mat-color($warn);
5451
}
5552

56-
&.mat-warn,
57-
&.mat-select-invalid {
58-
@include _mat-select-inner-content-theme($warn);
53+
.mat-select.mat-select-disabled .mat-select-arrow {
54+
color: mat-color($foreground, secondary-text);
5955
}
6056
}
6157

62-
.mat-select.mat-select-invalid:not(.mat-select-disabled) {
63-
@include _mat-select-inner-content-theme($warn);
58+
.mat-select.mat-select-disabled .mat-select-arrow {
59+
color: mat-color($warn);
6460
}
6561
}
6662

src/lib/select/select.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ $mat-select-item-height: 3em !default;
1212
.mat-select {
1313
display: inline-block;
1414
outline: none;
15-
16-
// Inside of a form field we want it to expand to take the available space.
17-
.mat-form-field & {
18-
width: 100%;
19-
}
2015
}
2116

2217
.mat-select-trigger {

src/lib/select/select.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import {Subscription} from 'rxjs/Subscription';
4949
import {fadeInContent, transformPanel} from './select-animations';
5050
import {SelectionModel} from '../core/selection/selection';
5151
import {getMdSelectDynamicMultipleError, getMdSelectNonArrayValueError} from './select-errors';
52-
import {CanColor, mixinColor} from '../core/common-behaviors/color';
5352
import {CanDisable, mixinDisabled} from '../core/common-behaviors/disabled';
5453
import {MdOptgroup, MdOption, MdOptionSelectionChange} from '../core/option/index';
5554
import {Platform} from '@angular/cdk/platform';
@@ -133,7 +132,7 @@ export class MdSelectChange {
133132
export class MdSelectBase {
134133
constructor(public _renderer: Renderer2, public _elementRef: ElementRef) {}
135134
}
136-
export const _MdSelectMixinBase = mixinColor(mixinDisabled(MdSelectBase), 'primary');
135+
export const _MdSelectMixinBase = mixinDisabled(MdSelectBase);
137136

138137

139138
/**
@@ -150,7 +149,7 @@ export class MdSelectTrigger {}
150149
selector: 'md-select, mat-select',
151150
templateUrl: 'select.html',
152151
styleUrls: ['select.css'],
153-
inputs: ['color', 'disabled'],
152+
inputs: ['disabled'],
154153
encapsulation: ViewEncapsulation.None,
155154
changeDetection: ChangeDetectionStrategy.OnPush,
156155
host: {
@@ -181,7 +180,7 @@ export class MdSelectTrigger {}
181180
exportAs: 'mdSelect',
182181
})
183182
export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, OnDestroy, OnInit,
184-
ControlValueAccessor, CanColor, CanDisable, MdFormFieldControl<any> {
183+
ControlValueAccessor, CanDisable, MdFormFieldControl<any> {
185184
/** Whether or not the overlay panel is open. */
186185
private _panelOpen = false;
187186

@@ -354,7 +353,6 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
354353
set value(newValue: any) {
355354
this.writeValue(newValue);
356355
this._value = newValue;
357-
this.stateChanges.next();
358356
}
359357
private _value: any;
360358

@@ -430,6 +428,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
430428

431429
ngOnInit() {
432430
this._selectionModel = new SelectionModel<MdOption>(this.multiple, undefined, false);
431+
this.stateChanges.next();
433432
}
434433

435434
ngAfterContentInit() {
@@ -718,6 +717,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
718717
if (correspondingOption) {
719718
isUserInput ? correspondingOption._selectViaInteraction() : correspondingOption.select();
720719
this._selectionModel.select(correspondingOption);
720+
this.stateChanges.next();
721721
}
722722

723723
return correspondingOption;
@@ -734,6 +734,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
734734
option.deselect();
735735
}
736736
});
737+
this.stateChanges.next();
737738
}
738739

739740
private _getTriggerRect(): ClientRect {
@@ -774,6 +775,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
774775
// TODO(crisbeto): handle blank/null options inside multi-select.
775776
if (this.multiple) {
776777
this._selectionModel.toggle(option);
778+
this.stateChanges.next();
777779
wasSelected ? option.deselect() : option.select();
778780
this._sortValues();
779781
} else {
@@ -783,6 +785,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
783785
this._propagateChanges(option.value);
784786
} else {
785787
this._selectionModel.select(option);
788+
this.stateChanges.next();
786789
}
787790
}
788791

@@ -804,6 +807,7 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
804807
this._selectionModel.select(option);
805808
}
806809
});
810+
this.stateChanges.next();
807811
}
808812
}
809813

0 commit comments

Comments
 (0)