lion/docs/components/dialog/src/external-dialog.js
Rajkeshwar Prasad e0ef676a36
opened-changed event detail exposes opened state (#2334)
* opened-changed event detail exposes opened state

* Fixed lint issue

* Generated changeset

---------

Co-authored-by: Rajkeshwar Prasad <rajkeshwarp@azuga.com>
Co-authored-by: Rajkeshwar Prasad <--global>
2024-08-22 13:12:50 +02:00

32 lines
839 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { LitElement, html } from 'lit';
class DialogTriggerDemo extends LitElement {
static get properties() {
return {
_isOpen: { state: true },
};
}
toggleDialog(open) {
// eslint-disable-next-line no-return-assign
return () => (this._isOpen = open);
}
handleDialog(e) {
this._isOpen = e.detail.opened;
}
render() {
return html`
<button @click=${this.toggleDialog(true)}>Open dialog</button>
<lion-dialog ?opened=${this._isOpen} @opened-changed=${this.handleDialog}>
<div slot="content" class="dialog demo-box">
Hello! You can close this notification here:
<button class="close-button" @click=${this.toggleDialog(false)}></button>
</div>
</lion-dialog>
`;
}
}
customElements.define('dialog-trigger-demo', DialogTriggerDemo);