Package Exports
- @lion/overlays
- @lion/overlays/src/utils/key-codes.js
- @lion/overlays/test-suites/OverlayMixin.suite.js
- @lion/overlays/translations/bg-BG.js
- @lion/overlays/translations/bg.js
- @lion/overlays/translations/cs-CZ.js
- @lion/overlays/translations/cs.js
- @lion/overlays/translations/de-DE.js
- @lion/overlays/translations/de.js
- @lion/overlays/translations/en-AU.js
- @lion/overlays/translations/en-GB.js
- @lion/overlays/translations/en-US.js
- @lion/overlays/translations/en.js
- @lion/overlays/translations/es-ES.js
- @lion/overlays/translations/es.js
- @lion/overlays/translations/fr-BE.js
- @lion/overlays/translations/fr-FR.js
- @lion/overlays/translations/fr.js
- @lion/overlays/translations/hu-HU.js
- @lion/overlays/translations/hu.js
- @lion/overlays/translations/it-IT.js
- @lion/overlays/translations/it.js
- @lion/overlays/translations/nl-BE.js
- @lion/overlays/translations/nl-NL.js
- @lion/overlays/translations/nl.js
- @lion/overlays/translations/pl-PL.js
- @lion/overlays/translations/pl.js
- @lion/overlays/translations/ro-RO.js
- @lion/overlays/translations/ro.js
- @lion/overlays/translations/ru-RU.js
- @lion/overlays/translations/ru.js
- @lion/overlays/translations/sk-SK.js
- @lion/overlays/translations/sk.js
- @lion/overlays/translations/uk-UA.js
- @lion/overlays/translations/uk.js
- @lion/overlays/translations/zh.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lion/overlays) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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="_overlay-shadow-outlet"></slot>
<div id="overlay-content-node-wrapper">
<slot name="content"></slot>
</div>
`;
}
}
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 don’t expect a dialog to open (at this moment in time) but expect a sub-menu. Until support for the dialog value has better implementation, it’s probably best to not use aria-haspopup on the element that opens the modal dialog.