@@ -27,22 +27,33 @@ import {
27
27
MatButtonBase
28
28
} from './button-base' ;
29
29
import { ThemePalette } from '@angular/material-experimental/mdc-core' ;
30
+ import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
30
31
31
32
/**
32
33
* Material Design floating action button (FAB) component. These buttons represent the primary
33
34
* or most common action for users to interact with.
34
35
* See https://material.io/components/buttons-floating-action-button/
35
36
*
36
- * The `MatFabButton` class has two appearances: normal and mini .
37
+ * The `MatFabButton` class has two appearances: normal and extended .
37
38
*/
38
39
@Component ( {
39
- selector : `button[mat-fab], button[mat-mini-fab] ` ,
40
+ selector : `button[mat-fab]` ,
40
41
templateUrl : 'button.html' ,
41
42
styleUrls : [ 'fab.css' ] ,
42
- inputs : [ ...MAT_BUTTON_INPUTS , 'extended' ] ,
43
+ // TODO: change to MAT_BUTTON_INPUTS/MAT_BUTTON_HOST with spread after ViewEngine is deprecated
44
+ inputs : [ 'disabled' , 'disableRipple' , 'color' , 'extended' ] ,
43
45
host : {
44
46
'[class.mdc-fab--extended]' : 'extended' ,
45
- '[class.mat-mdc-extended-fab]' : 'extended' , ...MAT_BUTTON_HOST
47
+ '[class.mat-mdc-extended-fab]' : 'extended' ,
48
+ '[attr.disabled]' : 'disabled || null' ,
49
+ '[class._mat-animation-noopable]' : '_animationMode === "NoopAnimations"' ,
50
+ // MDC automatically applies the primary theme color to the button, but we want to support
51
+ // an unthemed version. If color is undefined, apply a CSS class that makes it easy to
52
+ // select and style this "theme".
53
+ '[class.mat-unthemed]' : '!color' ,
54
+ // Add a class that applies to all buttons. This makes it easier to target if somebody
55
+ // wants to target all Material buttons.
56
+ '[class.mat-mdc-button-base]' : 'true' ,
46
57
} ,
47
58
exportAs : 'matButton' ,
48
59
encapsulation : ViewEncapsulation . None ,
@@ -52,7 +63,9 @@ export class MatFabButton extends MatButtonBase {
52
63
// The FAB by default has its color set to accent.
53
64
color = 'accent' as ThemePalette ;
54
65
55
- extended : boolean ;
66
+ private _extended : boolean ;
67
+ get extended ( ) { return this . _extended ; }
68
+ set extended ( extended : any ) { this . _extended = coerceBooleanProperty ( extended ) ; }
56
69
57
70
constructor (
58
71
elementRef : ElementRef , platform : Platform , ngZone : NgZone ,
@@ -61,22 +74,64 @@ export class MatFabButton extends MatButtonBase {
61
74
}
62
75
}
63
76
77
+ /**
78
+ * Material Design mini floating action button (FAB) component. These buttons represent the primary
79
+ * or most common action for users to interact with.
80
+ * See https://material.io/components/buttons-floating-action-button/
81
+ */
82
+ @Component ( {
83
+ selector : `button[mat-mini-fab]` ,
84
+ templateUrl : 'button.html' ,
85
+ styleUrls : [ 'fab.css' ] ,
86
+ inputs : MAT_BUTTON_INPUTS ,
87
+ host : MAT_BUTTON_HOST ,
88
+ exportAs : 'matButton' ,
89
+ encapsulation : ViewEncapsulation . None ,
90
+ changeDetection : ChangeDetectionStrategy . OnPush ,
91
+ } )
92
+ export class MatMiniFabButton extends MatButtonBase {
93
+ // The FAB by default has its color set to accent.
94
+ color = 'accent' as ThemePalette ;
95
+
96
+ constructor (
97
+ elementRef : ElementRef , platform : Platform , ngZone : NgZone ,
98
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) animationMode ?: string ) {
99
+ super ( elementRef , platform , ngZone , animationMode ) ;
100
+ }
101
+ }
102
+
64
103
65
104
/**
66
105
* Material Design floating action button (FAB) component for anchor elements. Anchor elements
67
106
* are used to provide links for the user to navigate across different routes or pages.
68
107
* See https://material.io/components/buttons-floating-action-button/
69
108
*
70
- * The `MatFabAnchor` class has two appearances: normal and mini .
109
+ * The `MatFabAnchor` class has two appearances: normal and extended .
71
110
*/
72
111
@Component ( {
73
- selector : `a[mat-fab], a[mat-mini-fab] ` ,
112
+ selector : `a[mat-fab]` ,
74
113
templateUrl : 'button.html' ,
75
114
styleUrls : [ 'fab.css' ] ,
76
- inputs : [ ...MAT_ANCHOR_INPUTS , 'extended' ] ,
115
+ // TODO: change to MAT_ANCHOR_INPUTS/MAT_ANCHOR_HOST with spread after ViewEngine is deprecated
116
+ inputs : [ 'disabled' , 'disableRipple' , 'color' , 'tabIndex' , 'extended' ] ,
77
117
host : {
78
118
'[class.mdc-fab--extended]' : 'extended' ,
79
- '[class.mat-mdc-extended-fab]' : 'extended' , ...MAT_ANCHOR_HOST
119
+ '[class.mat-mdc-extended-fab]' : 'extended' ,
120
+ '[attr.disabled]' : 'disabled || null' ,
121
+ '[class._mat-animation-noopable]' : '_animationMode === "NoopAnimations"' ,
122
+
123
+ // Note that we ignore the user-specified tabindex when it's disabled for
124
+ // consistency with the `mat-button` applied on native buttons where even
125
+ // though they have an index, they're not tabbable.
126
+ '[attr.tabindex]' : 'disabled ? -1 : (tabIndex || 0)' ,
127
+ '[attr.aria-disabled]' : 'disabled.toString()' ,
128
+ // MDC automatically applies the primary theme color to the button, but we want to support
129
+ // an unthemed version. If color is undefined, apply a CSS class that makes it easy to
130
+ // select and style this "theme".
131
+ '[class.mat-unthemed]' : '!color' ,
132
+ // Add a class that applies to all buttons. This makes it easier to target if somebody
133
+ // wants to target all Material buttons.
134
+ '[class.mat-mdc-button-base]' : 'true' ,
80
135
} ,
81
136
exportAs : 'matButton, matAnchor' ,
82
137
encapsulation : ViewEncapsulation . None ,
@@ -86,11 +141,39 @@ export class MatFabAnchor extends MatAnchor {
86
141
// The FAB by default has its color set to accent.
87
142
color = 'accent' as ThemePalette ;
88
143
89
- extended : boolean ;
144
+ private _extended : boolean ;
145
+ get extended ( ) { return this . _extended ; }
146
+ set extended ( extended : any ) { this . _extended = coerceBooleanProperty ( extended ) ; }
90
147
91
148
constructor (
92
149
elementRef : ElementRef , platform : Platform , ngZone : NgZone ,
93
150
@Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) animationMode ?: string ) {
94
151
super ( elementRef , platform , ngZone , animationMode ) ;
95
152
}
96
153
}
154
+
155
+ /**
156
+ * Material Design mini floating action button (FAB) component for anchor elements. Anchor elements
157
+ * are used to provide links for the user to navigate across different routes or pages.
158
+ * See https://material.io/components/buttons-floating-action-button/
159
+ */
160
+ @Component ( {
161
+ selector : `a[mat-mini-fab]` ,
162
+ templateUrl : 'button.html' ,
163
+ styleUrls : [ 'fab.css' ] ,
164
+ inputs : MAT_ANCHOR_INPUTS ,
165
+ host : MAT_ANCHOR_HOST ,
166
+ exportAs : 'matButton, matAnchor' ,
167
+ encapsulation : ViewEncapsulation . None ,
168
+ changeDetection : ChangeDetectionStrategy . OnPush ,
169
+ } )
170
+ export class MatMiniFabAnchor extends MatAnchor {
171
+ // The FAB by default has its color set to accent.
172
+ color = 'accent' as ThemePalette ;
173
+
174
+ constructor (
175
+ elementRef : ElementRef , platform : Platform , ngZone : NgZone ,
176
+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) animationMode ?: string ) {
177
+ super ( elementRef , platform , ngZone , animationMode ) ;
178
+ }
179
+ }
0 commit comments