ngc-float-button v1.2.1
ngc-float-button
Google Material Floating Action Button,
Implementation for Angular v4+

Demo
Installation
First, you need to install the npm module:
npm install ngc-float-button --saveDependencies
Google Material Icons
Angular Material >= beta.12
Angular >= 4.4.4
Usage
1. You need to add the Google Material icons in your index.html:
The Google Material Icons is required by Angular Material component
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">Check the Google Material Icons site to see all icons
2. Import the NgcFloatButtonModule in your project:
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {NgcFloatButtonModule} from 'ngc-float-button';
@NgModule({
imports: [
BrowserModule,
NgcFloatButtonModule
],
bootstrap: [AppComponent]
})
export class AppModule { }SharedModule
If you use a SharedModule that you import in multiple other feature modules,
you can export the NgcFloatButtonModule to make sure you don't have to import it in every module.
@NgModule({
exports: [
CommonModule,
NgcFloatButtonModule
]
})
export class SharedModule { }Finally, you can use ngc-float-button in your Angular project.
Sample
The FAB template
<ngc-float-button icon="add">
<ngc-float-item-button icon="person_add" content="float item 1"></ngc-float-item-button>
<ngc-float-item-button icon="gps_fixed" content="float item 2"></ngc-float-item-button>
<ngc-float-item-button icon="mode_edit" content="float item 3"></ngc-float-item-button>
</ngc-float-button>API
@Input properties
ngc-float-button properties:
iconproperty expects foricon_namelisted in Google Material Icons site.[open]property expects forBehaviorSubjecttype, with this you can open or close the FAB dispatching events.disabledproperty expects abooleanto toggle if a button is clickable. Defaults tofalse.colorproperty define the background color and expects abackground:{value}valid value. Defaults to#dd0031.directionproperty expects forstringvalue type value that's acceptedtop,right,bottom,left. Defaults totopspaceBetweenButtons- property expects a valid number value inpxto define the space between eachngc-float-item-button, Defaults to55
Sample: [open]
...
//our parent component
// with 'true' our FAB will be started open.
public open:BehaviorSubject<boolean> = new BehaviorSubject(true); // true is the initial state of FAB
... <div>
<button md-button (click)="open.next(true)">Open</button>
<button md-button (click)="open.next(false)">Close</button>
</div>
<ngc-float-button icon="add" [open]="open">
...Sample: [direction]
<div>
<button md-button (click)="direction='top'">Top</button>
<button md-button (click)="direction='right'">Right</button>
<button md-button (click)="direction='bottom'">Bottom</button>
<button md-button (click)="direction='left'">Left</button>
</div>
<ngc-float-button icon="add" direction="{{direction}}">
...ngc-float-item-button properties:
iconproperty expects foricon_namelisted in Google Material Icons site.colorproperty define the background color and expects abackground:{value}valid value. Defaults towhite.disabledproperty expects abooleanto toggle if a button is clickable. Defaults tofalse.contentproperty expectsstringvalue to show additional text inngc-float-item-button
@Output property
You can listen the all events emitted by ngc-float-button subscribing in the (events) observable output.
Sample:
...
output(log) {
console.log(log);
}
... <ngc-float-button (events)="output($event)">
...Customization
If you need change some css property in ngc-float-button you need to use /deep/ selector in parent css component.
More info about customization soon.
CSS animations credits
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago