Skip to content

Commit 3af3a37

Browse files
committed
feat(material-experimental/mdc-button): add extended fab
1 parent 5fc425b commit 3af3a37

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

src/dev-app/mdc-button/mdc-button-demo.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ <h4 class="demo-section-header">Anchors</h4>
3737
<a href="//www.google.com" mat-mini-fab>
3838
<mat-icon>check</mat-icon>
3939
</a>
40+
<a href="//www.google.com" mat-fab [extended]="true">Search</a>
41+
<a href="//www.google.com" mat-fab [extended]="true">
42+
<mat-icon>check</mat-icon>
43+
Search
44+
</a>
4045
</section>
4146
<section>
4247
<a href="//www.google.com" disabled mat-button color="primary">SEARCH</a>
@@ -49,6 +54,11 @@ <h4 class="demo-section-header">Anchors</h4>
4954
<a href="//www.google.com" disabled mat-mini-fab>
5055
<mat-icon>check</mat-icon>
5156
</a>
57+
<a href="//www.google.com" disabled mat-fab [extended]="true">Search</a>
58+
<a href="//www.google.com" disabled mat-fab [extended]="true">
59+
<mat-icon>check</mat-icon>
60+
Search
61+
</a>
5262
</section>
5363

5464
<h4 class="demo-section-header">Text Buttons [mat-button]</h4>
@@ -145,6 +155,18 @@ <h4 class="demo-section-header">Fab Buttons [mat-fab]</h4>
145155
</button>
146156
</section>
147157

158+
<h4 class="demo-section-header">Extended Fab Buttons</h4>
159+
<section>
160+
<button mat-fab [extended]="true">Extended</button>
161+
<button mat-fab [extended]="true" color="primary">Extended</button>
162+
<button mat-fab [extended]="true" color="accent">Extended</button>
163+
<button mat-fab [extended]="true" color="warn">Extended</button>
164+
<button mat-fab [extended]="true">
165+
<mat-icon>home</mat-icon>
166+
Extended
167+
</button>
168+
</section>
169+
148170
<h4 class="demo-section-header"> Mini Fab Buttons [mat-mini-fab]</h4>
149171
<section>
150172
<button mat-mini-fab>

src/material-experimental/mdc-button/button.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ describe('MDC-based MatButton', () => {
9494
});
9595
});
9696

97+
// describe('button[mat-fab] extended', () => {
98+
// it('should have accent palette by default', () => {
99+
// const fixture = TestBed.createComponent(TestApp);
100+
// const extendedFabButtonDebugEl = fixture.debugElement.query(By.css('.mat-mdc-extended-fab'))!;
101+
//
102+
// fixture.detectChanges();
103+
//
104+
// expect(extendedFabButtonDebugEl.nativeElement.classList)
105+
// .toContain('mat-accent', 'Expected extended fab buttons to use accent palette by default');
106+
// });
107+
});
108+
97109
// Regular button tests
98110
describe('button[mat-button]', () => {
99111
it('should handle a click on the button', () => {
@@ -281,6 +293,7 @@ describe('MDC-based MatButton', () => {
281293
Link
282294
</a>
283295
<button mat-fab>Fab Button</button>
296+
<button mat-fab [extended]="true">Extended</button>
284297
<button mat-mini-fab>Mini Fab Button</button>
285298
`
286299
})

src/material-experimental/mdc-button/fab.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ import {ThemePalette} from '@angular/material-experimental/mdc-core';
3939
selector: `button[mat-fab], button[mat-mini-fab]`,
4040
templateUrl: 'button.html',
4141
styleUrls: ['fab.css'],
42-
inputs: MAT_BUTTON_INPUTS,
43-
host: MAT_BUTTON_HOST,
42+
inputs: [...MAT_BUTTON_INPUTS, 'extended'],
43+
host: {
44+
'[class.mdc-fab--extended]': 'extended',
45+
'[class.mat-mdc-extended-fab]': 'extended', ...MAT_BUTTON_HOST
46+
},
4447
exportAs: 'matButton',
4548
encapsulation: ViewEncapsulation.None,
4649
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -49,6 +52,8 @@ export class MatFabButton extends MatButtonBase {
4952
// The FAB by default has its color set to accent.
5053
color = 'accent' as ThemePalette;
5154

55+
extended: boolean;
56+
5257
constructor(
5358
elementRef: ElementRef, platform: Platform, ngZone: NgZone,
5459
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
@@ -68,8 +73,11 @@ export class MatFabButton extends MatButtonBase {
6873
selector: `a[mat-fab], a[mat-mini-fab]`,
6974
templateUrl: 'button.html',
7075
styleUrls: ['fab.css'],
71-
inputs: MAT_ANCHOR_INPUTS,
72-
host: MAT_ANCHOR_HOST,
76+
inputs: [...MAT_ANCHOR_INPUTS, 'extended'],
77+
host: {
78+
'[class.mdc-fab--extended]': 'extended',
79+
'[class.mat-mdc-extended-fab]': 'extended', ...MAT_ANCHOR_HOST
80+
},
7381
exportAs: 'matButton, matAnchor',
7482
encapsulation: ViewEncapsulation.None,
7583
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -78,6 +86,8 @@ export class MatFabAnchor extends MatAnchor {
7886
// The FAB by default has its color set to accent.
7987
color = 'accent' as ThemePalette;
8088

89+
extended: boolean;
90+
8191
constructor(
8292
elementRef: ElementRef, platform: Platform, ngZone: NgZone,
8393
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {

0 commit comments

Comments
 (0)