ngx-widget-grid
ngx-widget-grid
A flexible grid layout for responsive dashboards
This library got its inspiration from angular-widget-grid and has been written as a pure Angular 2.x [+] module.
https://envyn.github.io/ngx-widget-grid
Demo:Installation
Install with npm:
$ npm install ngx-widget-grid
or with yarn
$ yarn add ngx-widget-grid
Add the ngx-widget-grid module as a dependency to your application module:
import { NgxWidgetGridModule } from 'ngx-widget-grid';
@NgModule({
declarations: [
...
],
imports: [
...
NgxWidgetGridModule,
...
],
bootstrap: [AppComponent]
})
export class AppModule { }
Usage
Minimal Example
Adding Traits
Widgets
position
You can bind the position of the widget to data received from server so that even if the widget is moved, the new positions are always updated in the widget configuration.
movable
If movable
is true, users will be able to move the respective widget.
resizable
If resizable
is true, users will be able to resize the respective widget.
Optionally, you can limit the resize directions:
swapOnMove
If swapOnMove
is true
, dragged widget will swap position and size with the widget over which the current one is dropped.
Default is false
which means, widget will be placed in the nearest available area.
Grid: Options
showGrid
(default: false
)
Toggles the gridlines.
highlightNextPosition
(default: false
)
Highlights the largest free area in the grid, if any. This area will be automatically assigned to the next widget with a falsy or conflicting position.
Events
gridFull
The grid emits gridFull
event as true
(when grid has been fully occupied) or false
when there is still some space left in the grid, so that you can e.g. enable/disable UI elements accordingly.
{ ifisGridFull ... //make add widget button disabled ... else ... //make add widget button enabled ... }
widgetPositionChange
Emitted whenever the position of a widget is changed. The event comes with an attached object argument, which contains the affected widget's index
and its newPosition
.
Functions
getNextPosition
getNextPosition
is a function you could call to get details about the next available position that is being highlighted as part of highlightNextPosition
.
Build (for developers/contributors)
- Install yarn
- Install dependenciesyarn install
- Runyarn start
- Buildyarn build
- Linkcd dist && yarn link
- Publish (from repo root directory)yarn publish:lib --new-version <version>
License
MIT