lion/packages/overlays
CircleCI bc768670ea chore: release new versions
- @lion/dialog@0.4.11
 - @lion/form-system@0.6.8
 - @lion/input-datepicker@0.10.3
 - @lion/overlays@0.12.6
 - @lion/select-rich@0.12.4
 - @lion/tooltip@0.8.6
2020-03-20 15:35:39 +00:00
..
docs feat: improved storybook demos 2020-01-13 13:58:03 +01:00
src fix(overlays): support backdrop with local overlay 2020-03-20 16:32:19 +01:00
stories fix(overlays): support backdrop with local overlay 2020-03-20 16:32:19 +01:00
test fix(overlays): support backdrop with local overlay 2020-03-20 16:32:19 +01:00
test-helpers feat(overlays): release new overlay system 2019-10-10 17:14:24 +02:00
test-suites feat(overlays): close/hide events on dom (OverlayMixin) level 2019-12-11 15:51:06 +01:00
translations fix: support Chinese language 2019-07-17 10:11:32 +02:00
CHANGELOG.md chore: release new versions 2020-03-20 15:35:39 +00:00
index.js chore: refactor OverlayMixin, remove redundant lion-popup 2019-11-29 17:34:19 +01:00
package.json chore: release new versions 2020-03-20 15:35:39 +00:00
README.md chore(overlays): fix demos 2020-02-13 11:44:20 +01:00

Overlay System

Supports different types of overlays like dialogs, toasts, tooltips, dropdown, etc.

Manages their position on the screen relative to other elements, including other overlays.

Its purpose is to make it easy to use our Overlay System declaratively. It can be easily extended where needed, to override event listeners and more.

See lion-dialog and lion-tooltip for example Web Component implementations using the Overlay System.

Features

  • lion-overlay web component:

    • Show content when clicking the invoker
    • Have a .config object to set or update the OverlayController's configuration
  • OverlaysManager, a global repository keeping track of all different types of overlays

  • OverlayController, a single controller class for handling overlays

  • OverlayMixin, a mixin that can be used to create webcomponents that use the OverlayController under the hood

How to use

Usually you will use lion-dialog (or lion-tooltip if this makes more sense).

Installation

npm i --save @lion/dialog

Example

import '@lion/dialog/lion-dialog.js';

html`
  <lion-dialog .config=${{
    placementMode: 'global',
    viewportConfig: { placement: 'bottom-right' },
  }}>
    <div slot="content">
      This is an overlay
      <button
        @click=${e => e.target.dispatchEvent(new Event('overlay-close', { bubbles: true }))}
      >x</button>
    <div>
    <button slot="invoker">
      Click me
    </button>
  </lion-dialog>
`;

Or by creating a controller yourself

npm i --save @lion/overlays
import { OverlayController } from '@lion/overlays';

const ctrl = new OverlayController({
  ...withModalDialogConfig(),
  invokerNode,
  contentNode,
});

Or creating your own Web Component which uses the Overlay System

import { LitElement } from '@lion/core';
import { OverlayMixin, withModalDialogConfig } from '@lion/overlays';

class MyOverlayComponent extends LitElement {
  _defineOverlayConfig() {
    return {
      ...withModalDialogConfig,
    };
  }

  _setupOpenCloseListeners() {
    super._setupOpenCloseListeners();
    this.__toggle = () => {
      this.opened = !this.opened;
    };

    if (this._overlayInvokerNode) {
      this._overlayInvokerNode.addEventListener('click', this.__toggle);
    }
  }

  _teardownOpenCloseListeners() {
    super._teardownOpenCloseListeners();

    if (this._overlayInvokerNode) {
      this._overlayInvokerNode.removeEventListener('click', this.__toggle);
    }
  }

  render() {
    return html`
      <slot name="invoker"></slot>
      <slot name="content"></slot>
      <slot name="_overlay-shadow-outlet"></slot>
    `;
  }
}

Rationales

For rationales, please check the docs folder, where we go more in-depth. Or check out the Storybook demos which also contains more info.

Aria roles

  • No aria-controls as support for it is not quite there yet
  • No aria-haspopup. People knowing the haspop up and hear about it dont expect a dialog to open (at this moment in time) but expect a sub-menu. Until support for the dialog value has better implementation, its probably best to not use aria-haspopup on the element that opens the modal dialog.