зеркало из
1
0
Форкнуть 0
A modal dialog that's opened with
.
Перейти к файлу
Kristján Oddsson 87b8ad820d
use babel-preset-github
2019-02-25 12:26:51 +00:00
test Test focus management 2018-12-18 15:39:10 -05:00
.babelrc use babel-preset-github 2019-02-25 12:26:51 +00:00
.eslintrc.json Set up Flow 2018-08-09 20:20:03 -04:00
.flowconfig Set up Flow 2018-08-09 20:20:03 -04:00
.gitignore Treat dist as build output directory 2018-04-03 12:28:22 -06:00
.travis.yml Fix Travis headless Chrome runner 2018-04-04 17:54:52 -06:00
LICENSE Add example usage 2018-03-29 15:26:32 -06:00
README.md outside the dialog -> <summary> 2018-09-13 11:35:10 -07:00
index.css Add max width set to 90vw 2018-07-20 10:29:11 -07:00
index.html Pull built file for pages demo and comment out local built file 2018-08-17 08:47:06 -04:00
index.js Prevent error when nothing is focusable 2018-12-18 15:52:25 -05:00
index.js.flow Set up Flow 2018-08-09 20:20:03 -04:00
package-lock.json use babel-preset-github 2019-02-25 12:26:51 +00:00
package.json use babel-preset-github 2019-02-25 12:26:51 +00:00
prettier.config.js Initial commit 2017-11-24 15:47:45 +08:00

README.md

<details-dialog> element

A modal dialog that's opened with a <details> button.

Installation

$ npm install --save details-dialog-element

Usage

import 'details-dialog-element'
<details>
  <summary>Open dialog</summary>
  <details-dialog>
    Modal content
    <button type="button" data-close-dialog>Close</button>
  </details-dialog>
</details>

Events

details-dialog:will-close

A details-dialog:will-close event is fired when a request to close the dialog is made either by pressing escape, clicking a data-close-dialog element, clicking on the <summary> element, or when .toggle(false) is called on an open dialog.

This event can be cancelled to keep the dialog open.

document.addEventListener('details-dialog:will-close', function(event) {
  if (!confirm('Are you sure?')) {
    event.preventDefault()
  }
})

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer 11
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.