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