Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ile/derby-ui-toast

Notification messages for Derby
https://github.com/ile/derby-ui-toast

Last synced: about 2 months ago
JSON representation

Notification messages for Derby

Awesome Lists containing this project

README

        

#derby-ui-toast

Notification messages ([toasts](http://en.wikipedia.org/wiki/Toast_(computing\))) for Derby.

![toast](https://f.cloud.github.com/assets/433707/966450/571f6b72-0549-11e3-946b-8b062879d7c5.png)

##Requirements

- [Node.js](http://nodejs.org)
- [Derby](http://derbyjs.com/)

##Demo

https://derby-demos.herokuapp.com/derby-ui-toast

##Installation

Using [npm](https://npmjs.org/)

`npm install derby-ui-toast`

##Usage

###Add CSS

First you have to import the base CSS:
```css
@import '../../node_modules/derby-ui-toast/css/'
```

If you want to use the default background images on the notification boxes:
```css
@import '../../node_modules/derby-ui-toast/css/bg-images.css'
```

Or if you want to use the Font Awesome icons:

```css
@import '../../node_modules/derby-ui-toast/css/bg-fontawesome.css'
```

###Add JS

Also you have to enable the component in JavaScript:

```javascript
app.component(require('derby-ui-toast'));
```

###Add HTML

And in HTML:

```html

```

###Adding messages

```javascript
model.toast(type, message, options);
```

*type* : string, the default possibilities are:

- 'info'
- 'success'
- 'warning'
- 'error'

*message*: string

*options*: object

### options

- *sticky*
default: false
- *timeout*
default: 5000
- *click*
default: none

####This will also work:

```javascript
model.toast({ info: 'Info message' }, options);
model.toast({ success: 'Success message' });
```

###Examples:

```javascript
model.toast('info', 'Everything is ok!');
model.toast('success', 'It worked!');
model.toast('warning', 'Beware!');
model.toast('error', 'An error happened!', { sticky: true });
model.toast('error', 'An error happened again!', { timeout: 1000 });
model.toast('error', 'And again!', { click: myFunction });
model.toast({ info: 'Info message' });
```

###Removing messages

Messages will disappear in 5 seconds by default. They can also be removed by clicking the message dialog box.