mwc-app-dialog
Unofficial material web component wrapper to manage a mwc-dialog in your application.
Usages
First import the element in your project
Then in your HTML
and now using JavaScript
const dialog = ...// see below to see the features
Notice
dialog
or blocking
await dialogconsole
Confirm
try await dialog // or (with a title) // await dialog.confirm('Please confirm', 'Are you sure ?') // or (just the title (bolder)) // await dialog.confirm('Are you sure ?') catch e // cancelled return // accepted, continue the procedure
Choices
let fruittry fruit = await dialog catch e // cancelled return
Custom
await dialog
If you want to prevent the dialog from closing (e.g. when you need to validate a form but it has an error the user needa fix) returns -1
from the onAccept
function.
await dialog
If you want a custom content without an accept button, just pass undefined
instead of a function for the third argument :
await dialog // only cancellable
Other features
catch dom
You can also catch the dom (rendered content of the dialog) to make post-manipulation :
const dom = await dialogdommyparagraphstylecolor = 'red'
dialogAction
)
make your own selection dialog (await dialog
Installation
npm i mwc-app-dialog
Demo
If you want to see a live demo :
- clone this repository
- install dependencies :
npm install
- type
npm run demo
. This will open the demo in the browser
Contact
vdegenne (at) gmail (dot) com