speeddial
Speed dial button inspired by Google Material design
Getting started
Download this plugin from the Github repository or install it through this command:
$ npm install speeddial --save
Required assets
Import the CSS:
Import the Javascript:
This Javascript library is UMD compliant, so you can consume it even like this:
Required markup
B C D A
Start it up
The selector passed as first parameter must be the container's selector and must be unique:
var sd = ;
The second optional parameter is a literal object meant to override the default settings:
// Default settingsvar options = // The actual speed dial button's default class button: '.speed-dial__btn' // List of options' default class list: '.speed-dial__list' // Default direction // Available directions are: up, down, left, right direction: 'up';
Available CSS modifiers
To customize the appearence there are some built-in CSS modifier classes:
/* If you want a blue button */.speed-dial--blue /* If you want a pink button */.speed-dial--pink /* If you want a small button */.speed-dial--small /* If you want to add cool shadows */.speed-dial--material /* If you want to toggle the button state when the list of options is open */.speed-dial--toggle
You can dive into ./scss/speeddial.scss and change the modifiers to meet your needs. Then compile it by running one of the following command:
$ npm run watch-css
$ npm run build-css
Those classes have to be added to the container. That is:
... A
API
var sd = ; // Returns the container sd; // Returns the button which triggers the list to open/close sd; // Returns the list of options sd; // Returns the direction which the list is opening to sd; /** * Set the direction, the parameter is a string among: * 'up', 'down', 'right', 'left' */ sd; // Opens the list of options sd; // Close the list of options sd;