Giter Club home page Giter Club logo

ngc-float-button's Introduction

ngc-float-button

Google Material Floating Action Button, Implementation for Angular v4+

Installation

First you need to install the npm module:

npm install ngc-float-button --save

Dependencies

Angular Material

Google Material Icons

Angular v4+

Usage

1. You need to add the Google Material icons in your index.html:

    <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:

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

The ngc-float-button component has two @Input properties:

[open]="open" and [direction]="direction"

[open] property waiting for BehaviorSubject type, with this you can open or close the FAB dispatching events.

Sample:

    ...
    //our parent component

    // with this our FAB will be started open.
    private open:BehaviorSubject<boolean> = new BehaviorSubject(true);

    ...
    <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">
    ...

[direction] property waiting for string type value that's accepted top, right, bottom, left, remember the [property-binding] is optional but if you need change this property dynamically it's required.

Sample:

    <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">
    ...

@Output property

You can listener events in ngc-float-button subscribing the (events) 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

The css animations were inspired by this

ngc-float-button's People

Contributors

gustavocostaw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.