3.0.1 • Published 6 years ago

@polymer/paper-toast v3.0.1

Weekly downloads
8,981
License
BSD-3-Clause
Repository
github
Last release
6 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-731myscript-common-elementmyscript-text-webmhva-lugares-crudmammooc-rating-widgetnodecg@unicef-polymer/etools-file@uxland/uxl-interaction@uxland/ui-interaction@spriteful/spriteful-app-shell@spriteful/app-shell@smyd/app-shell@telecomsante/pdf-viewer@aspen-elements/firefly-loginapi-console@casper2020/casper-toast@casper2020/casper-wizard@casper2020/casper-loginoe-message-handleroe-data-tableuyarn-iconsrpdfviwercl-polymer-entity-toast-manager@advanced-rest-client/export-panel@advanced-rest-client/history-panel@advanced-rest-client/import-panel@advanced-rest-client/multipart-payload-editor@advanced-rest-client/oauth2-scope-selector@api-components/api-request-editor@anviltech/wuf-poly-paper-elements@anypoint-web-components/api-console@hass-ada/frontend-lite@advanced-rest-client/arc-app-mixin@advanced-rest-client/arc-request-workspace@advanced-rest-client/auth-methods@advanced-rest-client/arc-data-settings-panel@advanced-rest-client/arc-ie@advanced-rest-client/arc-info-messages@advanced-rest-client/client-certificates-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/rest-api-menu@advanced-rest-client/websocket-data-view@advanced-rest-client/websocket-request@advanced-rest-client/saved-request-detail@advanced-rest-client/saved-requests-panel@advanced-rest-client/themes-panel@advanced-rest-client/cookie-manager@01ht/ht-toast@firefly-elements/firefly-loginf-i18n-paper@lrnwebcomponents/lrnsys-comment@lrnwebcomponents/lrnsys-progress@myfrom/notifier@lrnwebcomponents/relative-heading@lrnwebcomponents/lrnapp-cis@lrnwebcomponents/haxcms-elements@lrnwebcomponents/game-show-quiz@nuskin/ns-account-elements@nuxeo/nuxeo-ui-elements@longlost/app-shellhomeassistant-frontend-racelandetools-file@polymer/iron-component-page
3.0.1

6 years ago

3.0.0

6 years ago

3.0.0-pre.26

6 years ago

3.0.0-pre.25

6 years ago

3.0.0-pre.24

6 years ago

3.0.0-pre.23

6 years ago

3.0.0-pre.22

6 years ago

3.0.0-pre.21

6 years ago

3.0.0-pre.20

6 years ago

3.0.0-pre.19

6 years ago

3.0.0-pre.18

6 years ago

3.0.0-pre.17

6 years ago

3.0.0-pre.16

6 years ago

3.0.0-pre.15

6 years ago

3.0.0-pre.14

6 years ago

3.0.0-pre.13

6 years ago

3.0.0-pre.12

6 years ago

3.0.0-pre.11

6 years ago

3.0.0-pre.10

6 years ago

3.0.0-pre.8

6 years ago

3.0.0-pre.7

6 years ago

3.0.0-pre.6

6 years ago

3.0.0-pre.4

6 years ago

3.0.0-pre.3

6 years ago

3.0.0-pre.2

6 years ago

3.0.0-pre.1

7 years ago

1.3.0-pre.3

7 years ago

1.3.0-pre.2

7 years ago

1.3.0-pre.1

7 years ago

0.0.4

7 years ago

0.0.3

8 years ago

0.0.1

8 years ago