Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Fix demo app flat button and waves effect (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
scote authored and jfcere committed Jan 29, 2018
1 parent d6de430 commit 4c3e984
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions demo-app/src/app/button/button.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ <h5 class="light">Flat button</h5>
<div class="row m-valign-wrapper">

<div class="col s12 m3">
<button mz-button
<a mz-button
[flat]="true"
>
button
</button>
</a>
</div>

<p class="col s12 m9">
The button has a flat elevation with <code class="language-markup">flat</code> property
The link has a flat elevation with <code class="language-markup">flat</code> property
</p>
</div>

Expand Down
5 changes: 4 additions & 1 deletion src/app/button/button.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export class MzButtonDirective extends HandlePropChanges implements OnInit {

handleNoWaves() {
this.renderer.setElementClass(this.elementRef.nativeElement, 'waves-effect', !this.noWaves);
this.renderer.setElementClass(this.elementRef.nativeElement, 'waves-light', !this.noWaves);

if (!this.flat) {
this.renderer.setElementClass(this.elementRef.nativeElement, 'waves-light', !this.noWaves);
}
}
}
13 changes: 13 additions & 0 deletions src/app/button/button.directive.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ describe('MzButtonDirective:unit', () => {
]);
});

it('should add only waves-effect on button element when flat is true', () => {

const rendererSpy = spyOn(renderer, 'setElementClass');

directive.flat = true;
directive.handleNoWaves();

expect(rendererSpy.calls.count()).toBe(1);
expect(rendererSpy.calls.allArgs()).toEqual([
[mockElementRef.nativeElement, 'waves-effect', !directive.noWaves],
]);
});

it('should not add waves-effect and waves-light on button element when noWaves is true', () => {

const rendererSpy = spyOn(renderer, 'setElementClass');
Expand Down

0 comments on commit 4c3e984

Please sign in to comment.