Package detail

@anypoint-web-components/anypoint-dialog

anypoint-web-components2.3kApache-2.00.1.10

A Material design dialog with compatibility with Anypoint platform

anypoint-web-components, dropdown-menu, icon-button

readme

anypoint-dialog

A material design dialog, also styled for Anypoint platform.

Anypoint web components are set of components that allows to build Anypoint enabled UI in open source projects.

Dialogs inform users about a task and can contain critical information, require decisions, or involve multiple tasks.

Published on NPM

tests

Usage

Installation

npm install @anypoint-web-components/anypoint-dialog --save

In an html file

<html>
  <head>
    <script type="module">
      import '@anypoint-web-components/anypoint-dialog/anypoint-dialog.js';
      import '@anypoint-web-components/anypoint-dialog/anypoint-dialog-scrollable.js';
      import '@anypoint-web-components/anypoint-button/anypoint-button.js';
    </script>
  </head>
  <body>
    <anypoint-dialog>
      <h2>Dialog title</h2>
      <anypoint-dialog-scrollable>
        <p>Long content...</p>
      </anypoint-dialog-scrollable>
      <div class="buttons">
        <anypoint-button data-dialog-dismiss>Cancel</anypoint-button>
        <anypoint-button data-dialog-confirm autofocus>OK</anypoint-button>
      </div>
    </anypoint-dialog>
    <script>
    {
      document.querySelector('anypoint-dialog').addEventListener('overlay-closed', (e) => {
        console.log(e.detail.canceled); // only when outside click or ESC key press
        console.log(e.detail.confirmed); // true when "dialog-confirm" was pressed
      });
    }
    </script>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import '@anypoint-web-components/anypoint-dialog/anypoint-dialog.js';
import '@anypoint-web-components/anypoint-dialog/anypoint-dialog-scrollable.js';
import '@anypoint-web-components/anypoint-button/anypoint-button.js';

class SampleElement extends LitElement {
  render() {
    return html`
    <anypoint-dialog @overlay-closed="${this._dialogCloseHandler}">
      <h2>Dialog title</h2>
      <anypoint-dialog-scrollable>
        <p>Long content...</p>
      </anypoint-dialog-scrollable>
      <div class="buttons">
        <anypoint-button data-dialog-dismiss>Cancel</anypoint-button>
        <anypoint-button data-dialog-confirm autofocus>OK</anypoint-button>
      </div>
    </anypoint-dialog>
    `;
  }

  _dialogCloseHandler(e) {
    if (e.detail.confirmed) {
      // ...
    }
  }
}
customElements.define('sample-element', SampleElement);

Action buttons

Button with "dialog-dismiss" attribute will dismiss the dialog with "confirmed" property on a detail object of "overlay-closed" event set to false.

Button with "dialog-confirm" attribute will close the dialog with "confirmed" property on a detail object of "overlay-closed" event set to true.

Scrollable content

If the content of the dialog may exceed window size then use anypoint-dialog-scrollable as a content wrapper. It has additional logic to keep the content in place. Otherwise use regular div or paragraph.

Modal dialog

Set "modal" property to true to render the dialog over a scrim, with ESC button handler and mouse click disabled. The user can dismiss the dialog only by using dialog actions.

Development

git clone https://github.com/anypoint-web-components/anypoint-dialog
cd anypoint-dialog
npm install

Running the demo locally

npm start

Running the tests

npm test

changelog

0.1.3 (2020-06-22)

Build

  • bumping version 6bb42ba by Pawel Psztyc
  • bumping version 0f47b60 by Pawel
  • publishing stable release 89cfcee by Pawel

Update

  • [ci skip] automated merge master->stage. syncing main branches d84d365 by Ci agent
  • updating dependencies 979156d by Pawel Psztyc
  • removing dialogElement setter ac8c1ef by Pawel Psztyc

Features

  • adding @open-wc/dedupe-mixin and types definition 22be992 by Pawel
  • adding styles to style dialog without slot elements 10bb0be by Pawel

Testing

  • updated Travis configuration to connect to Sauce Labs 2ee0774 by Pawel

0.1.4 (2020-08-03)

Update

  • adding styles export 138295c by Pawel
  • removing private restriction on npm publish e19446b by Pawel
  • [ci skip] automated merge master->stage. syncing main branches 485b816 by Ci agent
  • [ci skip] automated merge master->stage. syncing main branches d84d365 by Ci agent

Features

  • adding @open-wc/dedupe-mixin and types definition 22be992 by Pawel

0.1.5 (2020-10-11)

Update

  • updating dependencies and types bc0688d by Pawel
  • [ci skip] automated merge master->stage. syncing main branches 8448150 by Ci agent
  • adding styles export 138295c by Pawel
  • removing private restriction on npm publish e19446b by Pawel
  • [ci skip] automated merge master->stage. syncing main branches 485b816 by Ci agent

0.1.6 (2020-10-12)

Update

  • [ci skip] automated merge master->stage. syncing main branches 4b4eebf by Ci agent
  • updating dependencies and types bc0688d by Pawel
  • [ci skip] automated merge master->stage. syncing main branches 8448150 by Ci agent

Features

  • adding support for data-* attributes 65cc2e3 by Pawel

0.1.8 (2021-03-22)

Update

  • updating deps 890cda6 by Pawel Psztyc
  • removing Travis badge df3ba72 by Pawel Psztyc
  • upgrading dependencies and tests and CI c8c111c by Pawel Psztyc
  • [ci skip] automated merge master->stage. syncing main branches ed0d92d by Ci agent
  • [ci skip] automated merge master->stage. syncing main branches 4b4eebf by Ci agent

Features

  • adding support for data-* attributes 65cc2e3 by Pawel

0.1.9 (2021-03-30)

Build

  • bump version a299c8c by Carolina Wright

Update

  • embed styles in component 8bb80d7 by Carolina Wright
  • [ci skip] automated merge master->stage. syncing main branches 5d014a1 by Ci agent
  • updating deps 890cda6 by Pawel Psztyc
  • removing Travis badge df3ba72 by Pawel Psztyc
  • upgrading dependencies and tests and CI c8c111c by Pawel Psztyc
  • [ci skip] automated merge master->stage. syncing main branches ed0d92d by Ci agent

Bug Fixes