-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Attila Németh
committed
Jan 4, 2021
1 parent
c77cb31
commit 839ebff
Showing
6 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="fab-button-content"> | ||
<span class="label"> | ||
<ng-content></ng-content> | ||
</span> | ||
</div> | ||
|
||
<div matRipple class="fab-button-ripple"> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
:host { | ||
.fab-button-ripple { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
} | ||
.fab-button-content { | ||
span { | ||
&.label { | ||
::ng-deep mat-icon { | ||
vertical-align: middle; | ||
margin-right: 0.75rem; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
:host(.mat-raised-button) { | ||
padding: 0.375rem 1.25rem 0.375rem 0.75rem; | ||
border-radius: 1.5rem; | ||
position: relative; | ||
top: -0.75rem; | ||
left: 1.5rem; | ||
&.attus-fab-mobile { | ||
position: absolute; | ||
bottom: 1rem; | ||
right: 1rem; | ||
top: auto; | ||
left: auto; | ||
padding-right: 0.75rem; | ||
min-width: 0; | ||
span { | ||
&.label { | ||
display: block; | ||
width: 1.5rem; | ||
overflow: hidden; | ||
::ng-deep mat-icon { | ||
margin-right: 0; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { FabComponent } from './fab.component'; | ||
|
||
describe('FabComponent', () => { | ||
let component: FabComponent; | ||
let fixture: ComponentFixture<FabComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ FabComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(FabComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @file Floating Action Button | ||
* | ||
* @author Attila Németh | ||
* @date 04.01.2021 | ||
*/ | ||
|
||
import {Component, Input, HostBinding} from '@angular/core'; | ||
|
||
import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout'; | ||
|
||
@Component({ | ||
selector: '[attus-fab-button]', | ||
templateUrl: './fab.component.html', | ||
styleUrls: ['./fab.component.scss'] | ||
}) | ||
export class AttusElementsFabComponent { | ||
|
||
@HostBinding('class') elementClass: string = 'mat-raised-button'; | ||
isMobile: boolean = true | ||
@Input() set color(color: string) { | ||
this.colorString = color; | ||
this.updateElementClass(); | ||
} | ||
colorString: string = null | ||
|
||
constructor(breakpointObserver: BreakpointObserver) { | ||
breakpointObserver.observe([Breakpoints.Handset]).subscribe(status => { | ||
if (status.matches) { | ||
this.isMobile = true; | ||
} | ||
else { | ||
this.isMobile = false; | ||
} | ||
this.updateElementClass(); | ||
}); | ||
} | ||
|
||
private updateElementClass(): void { | ||
let classes: Array<string> = [ | ||
'attus-fab-button', | ||
'mat-raised-button', | ||
'mat-focus-indicator', | ||
'mat-button-base', | ||
'mat-' + this.colorString, | ||
]; | ||
if (this.isMobile) { | ||
classes.push('attus-fab-mobile'); | ||
} | ||
this.elementClass = classes.join(' '); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters