3.0.1 • Published 7 years ago

@polymer/paper-toast v3.0.1

Weekly downloads
8,981
License
BSD-3-Clause
Repository
github
Last release
7 years ago

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 propertyDescriptionDefault
--paper-toast-background-colorThe paper-toast background-color#323232
--paper-toast-colorThe 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
zagen-zagen@infinitebrahmanuniverse/nolb-_poltest-pkg-form-builder@everything-registry/sub-chunk-731uyarn-icons@anviltech/wuf-poly-paper-elements@anypoint-web-components/api-console@api-components/api-request-editor@aspen-elements/firefly-login@advanced-rest-client/export-panel@advanced-rest-client/websocket-data-view@advanced-rest-client/websocket-request@advanced-rest-client/rest-api-menu@advanced-rest-client/saved-request-detail@advanced-rest-client/saved-requests-panel@advanced-rest-client/themes-panel@advanced-rest-client/raw-payload-editor@advanced-rest-client/request-actions-panel@advanced-rest-client/project-details@advanced-rest-client/project-requests-list@advanced-rest-client/projects-menu@advanced-rest-client/arc-app-mixin@advanced-rest-client/arc-data-settings-panel@advanced-rest-client/arc-request-workspace@advanced-rest-client/auth-methods@advanced-rest-client/multipart-payload-editor@advanced-rest-client/oauth2-scope-selector@advanced-rest-client/history-panel@advanced-rest-client/import-panel@advanced-rest-client/client-certificates-panel@advanced-rest-client/arc-ie@advanced-rest-client/arc-info-messages@advanced-rest-client/cookie-manager@casper2020/casper-login@casper2020/casper-toast@casper2020/casper-wizard@01ht/ht-toast@haxtheweb/lrnsys-comment@haxtheweb/lrnsys-progress@haxtheweb/relative-heading@haxtheweb/haxcms-elements@hass-ada/frontend-lite@firefly-elements/firefly-login@lrnwebcomponents/lrnsys-comment@lrnwebcomponents/lrnsys-progress@lrnwebcomponents/lrnapp-cis@lrnwebcomponents/haxcms-elements@lrnwebcomponents/game-show-quiz@longlost/app-shell@lrnwebcomponents/relative-heading@myfrom/notifier@polymer/iron-component-page@nuskin/ns-account-elements@nuxeo/nuxeo-ui-elementsmhva-lugares-crudmyscript-common-elementmyscript-text-weboe-message-handleroe-data-tablerpdfviwernodecghomeassistant-frontend-racelandmammooc-rating-widget@unicef-polymer/etools-file@telecomsante/pdf-viewer@uxland/ui-interaction@uxland/uxl-interactionapi-consolecl-polymer-entity-toast-manageretools-filef-i18n-paper@spriteful/spriteful-app-shell@spriteful/app-shell@smyd/app-shell
3.0.1

7 years ago

3.0.0

7 years ago

3.0.0-pre.26

7 years ago

3.0.0-pre.25

7 years ago

3.0.0-pre.24

7 years ago

3.0.0-pre.23

7 years ago

3.0.0-pre.22

7 years ago

3.0.0-pre.21

7 years ago

3.0.0-pre.20

7 years ago

3.0.0-pre.19

7 years ago

3.0.0-pre.18

7 years ago

3.0.0-pre.17

7 years ago

3.0.0-pre.16

7 years ago

3.0.0-pre.15

7 years ago

3.0.0-pre.14

7 years ago

3.0.0-pre.13

7 years ago

3.0.0-pre.12

7 years ago

3.0.0-pre.11

7 years ago

3.0.0-pre.10

7 years ago

3.0.0-pre.8

7 years ago

3.0.0-pre.7

7 years ago

3.0.0-pre.6

7 years ago

3.0.0-pre.4

7 years ago

3.0.0-pre.3

7 years ago

3.0.0-pre.2

7 years ago

3.0.0-pre.1

8 years ago

1.3.0-pre.3

8 years ago

1.3.0-pre.2

8 years ago

1.3.0-pre.1

8 years ago

0.0.4

8 years ago

0.0.3

9 years ago

0.0.1

9 years ago