-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opened-changed event detail exposes opened state
- Loading branch information
Rajkeshwar Prasad
committed
Aug 19, 2024
1 parent
95b7460
commit bc8b261
Showing
4 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters