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