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

https://github.com/zecat/paper-toast-patterns

Factorize your paper-toasts using patterns.
https://github.com/zecat/paper-toast-patterns

Last synced: over 1 year ago
JSON representation

Factorize your paper-toasts using patterns.

Awesome Lists containing this project

README

          

# paper-toast-patterns

[Demo & Doc](http://zecat.github.io/paper-toast-patterns)

```
bower install --save Zecat/paper-toast-patterns
```

## Factorize your paper-toasts using patterns.

First create some <paper-toast> as child of <paper-toast-patterns>, give them a 'type'
attribute to retrieve them later and configure/style them as you please.

Exemple :

```html

paper-toast[type="warn"] {
font-weight: bold;
--paper-toast-color: var(--google-red-500);
}
paper-toast[type="info"] {
--paper-toast-color: var(--google-blue-500);
}






```

Then, implement Zecat.PaperToastFirerBehavior in your favorite elements and use
fireToast(type, text) method to open the matching type toast. If text param
isn't provide, the text from your 'toast pattern' will be used.

Exemple :

```html


warning
info


Polymer({
is: 'toast-sender',
behaviors: [
Zecat.PaperToastFirerBehavior
],
sendWarn: function() {
this.fireToast('warn');
},
sendInfo: function() {
this.fireToast('info', 'A spermatozoid contains 37.5 mb of data.');
}
});

```

You can also trigger yourself the toast from anywhere by firing an event
with this exact structure :

```js
this.fire('iron-signal', {
name: 'toast',
data: {
type: "your-type",
text: "your-text"
}
});
```