paper-toast

WebJar for paper-toast

License

License

BSD 3-Clause
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

paper-toast
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

paper-toast
WebJar for paper-toast
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/PolymerElements/paper-toast

Download paper-toast

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/paper-toast/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>paper-toast</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/paper-toast/
implementation 'org.webjars.bower:paper-toast:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.bower/paper-toast/
implementation ("org.webjars.bower:paper-toast:2.0.0")
'org.webjars.bower:paper-toast:jar:2.0.0'
<dependency org="org.webjars.bower" name="paper-toast" rev="2.0.0">
  <artifact name="paper-toast" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='paper-toast', version='2.0.0')
)
libraryDependencies += "org.webjars.bower" % "paper-toast" % "2.0.0"
[org.webjars.bower/paper-toast "2.0.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.webjars.bower : github-com-polymerelements-iron-a11y-announcer jar [1,3)
org.webjars.bower : github-com-polymerelements-iron-overlay-behavior jar [1,3)
org.webjars.bower : github-com-polymerelements-iron-fit-behavior jar [1,3)
org.webjars.bower : github-com-polymer-polymer jar [1.9,3)

Project Modules

There are no modules declared in this project.

Published on NPM Build status Published on webcomponents.org

<paper-toast>

paper-toast provides a subtle notification toast. Only one paper-toast will be visible on screen.

Use opened to show the toast:

Example:

<paper-toast text="Hello world!" opened></paper-toast>

Also open() or show() can be used to show the toast:

Example:

<paper-button on-click="openToast">Open Toast</paper-button>
<paper-toast id="toast" text="Hello world!"></paper-toast>

...

openToast: function() {
  this.$.toast.open();
}

Set duration to 0, a negative number or Infinity to persist the toast on screen:

Example:

<paper-toast text="Terms and conditions" opened duration="0">
  <a href="#">Show more</a>
</paper-toast>

<paper-toast> is affected by the stacking context of its container. Adding <paper-toast> inside elements that create a new stacking context - e.g. <app-drawer>, <app-layout> or <iron-list> - might result in toasts partially obstructed or clipped. Add <paper-toast> to the top level (<body>) element, outside the structure, e.g.:

  <!-- ... -->
  </app-drawer-layout>
  <paper-toast id="toast"></paper-toast>
</template>

You can then use custom events to communicate with it from within child components, using addEventListener and dispatchEvent.

Styling

The following custom properties and mixins are available for styling:

Custom property Description Default
--paper-toast-background-color The paper-toast background-color #323232
--paper-toast-color The paper-toast color #f1f1f1

This element applies the mixin --paper-font-common-base but does not import paper-styles/typography.html. In order to apply the Roboto font to this element, make sure you've imported paper-styles/typography.html.

See: Documentation, Demo.

Usage

Installation

npm install --save @polymer/paper-toast

In an html file

<html>
  <head>
    <script type="module">
      import '@polymer/paper-toast/paper-toast.js';
    </script>
  </head>
  <body>
    <paper-toast text="Hello world!" opened></paper-toast>
  </body>
</html>

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import '@polymer/paper-toast/paper-toast.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
      <paper-toast text="Hello world!" opened></paper-toast>
    `;
  }
}
customElements.define('sample-element', SampleElement);

Contributing

If you want to send a PR to this element, here are the instructions for running the tests and demo locally:

Installation

git clone https://github.com/PolymerElements/paper-toast
cd paper-toast
npm install
npm install -g polymer-cli

Running the demo locally

polymer serve --npm
open http://127.0.0.1:<port>/demo/

Running the tests

polymer test --npm
org.webjars.bower

Versions

Version
2.0.0
1.2.2