6
6
HostBinding ,
7
7
Input ,
8
8
OnDestroy ,
9
+ Optional ,
9
10
Renderer2 ,
11
+ Self ,
10
12
ViewEncapsulation
11
13
} from '@angular/core' ;
12
14
import { coerceBooleanProperty , FocusOriginMonitor , Platform } from '../core' ;
@@ -15,6 +17,9 @@ import {mixinDisabled, CanDisable} from '../core/common-behaviors/disabled';
15
17
16
18
// TODO(kara): Convert attribute selectors to classes when attr maps become available
17
19
20
+ /** Default color palette for round buttons (md-fab and md-mini-fab) */
21
+ const DEFAULT_ROUND_BUTTON_COLOR = 'accent' ;
22
+
18
23
19
24
/**
20
25
* Directive whose purpose is to add the mat- CSS styling to this selector.
@@ -57,17 +62,28 @@ export class MdIconButtonCssMatStyler {}
57
62
selector : 'button[md-fab], button[mat-fab], a[md-fab], a[mat-fab]' ,
58
63
host : { 'class' : 'mat-fab' }
59
64
} )
60
- export class MdFabCssMatStyler { }
65
+ export class MdFab {
66
+ constructor ( @Self ( ) @Optional ( ) button : MdButton , @Self ( ) @Optional ( ) anchor : MdAnchor ) {
67
+ // Set the default color palette for the md-fab components.
68
+ ( button || anchor ) . color = DEFAULT_ROUND_BUTTON_COLOR ;
69
+ }
70
+ }
61
71
62
72
/**
63
- * Directive whose purpose is to add the mat- CSS styling to this selector.
73
+ * Directive that targets mini-fab buttons and anchors. It's used to apply the `mat-` class
74
+ * to all mini-fab buttons and also is responsible for setting the default color palette.
64
75
* @docs -private
65
76
*/
66
77
@Directive ( {
67
78
selector : 'button[md-mini-fab], button[mat-mini-fab], a[md-mini-fab], a[mat-mini-fab]' ,
68
79
host : { 'class' : 'mat-mini-fab' }
69
80
} )
70
- export class MdMiniFabCssMatStyler { }
81
+ export class MdMiniFab {
82
+ constructor ( @Self ( ) @Optional ( ) button : MdButton , @Self ( ) @Optional ( ) anchor : MdAnchor ) {
83
+ // Set the default color palette for the md-mini-fab components.
84
+ ( button || anchor ) . color = DEFAULT_ROUND_BUTTON_COLOR ;
85
+ }
86
+ }
71
87
72
88
73
89
// Boilerplate for applying mixins to MdButton.
@@ -117,10 +133,6 @@ export class MdButton extends _MdButtonMixinBase implements OnDestroy, CanDisabl
117
133
private _focusOriginMonitor : FocusOriginMonitor ) {
118
134
super ( ) ;
119
135
this . _focusOriginMonitor . monitor ( this . _elementRef . nativeElement , this . _renderer , true ) ;
120
-
121
- if ( this . _isRoundButton ) {
122
- this . color = 'accent' ;
123
- }
124
136
}
125
137
126
138
ngOnDestroy ( ) {
0 commit comments