<button data-veylo-modal="#dlg">Open</button>
<dialog class="veylo-dialog" id="dlg">
<h1 class="veylo-title"><span>Confirm</span></h1>
<div class="veylo-body">
<div class="msg"><span class="ico no">!</span><span>Delete 3 files?</span></div>
<div class="btns">
<button class="danger def" data-veylo-close>Delete</button>
<button data-veylo-close>Cancel</button>
</div>
</div>
</dialog>Uses the native dialog element. data-veylo-modal="#id" opens it as a modal. data-veylo-close on any button inside closes it. Behaviour added by veylo.js:
data-veylo-static..def button.Layout parts: .msg is an icon and message row (.ico with no, ok, err or none), .btns is the right-aligned button row. A dialog without script can be opened with el.showModal().
<ul class="veylo-popup">
<li data-k="Ctrl+X">Cu<u>t</u></li>
<li class="dis" data-k="Del">Delete</li>
<li class="sep"></li>
<li class="chk">Word wrap</li>
<li class="sub">Encoding</li>
</ul>| Item | Meaning |
|---|---|
data-k | Shortcut label, right-aligned |
<u>x</u> | Access key: pressing that letter picks the item |
sep | Separator line |
dis | Disabled, skipped by keys |
chk | Checked item (tick drawn in CSS); toggle it in your script |
sub | Has a submenu (arrow drawn in CSS) |
hot | Highlighted item |
Menu keys: Up and Down move, Home and End jump, Enter picks, Esc closes. A pick fires veylo-pick on the menu with detail.item.
<details class="veylo-dd btn">
<summary>File</summary>
<ul class="veylo-popup"><li>New</li><li>Open...</li></ul>
</details>Built on details, so it opens without script. veylo.js adds click-away and Esc closing, closing when you pick an item, closing when another dropdown opens, and arrow-key navigation. Add btn to draw the summary as a button.
<div data-veylo-context="#ctx" tabindex="0">Right-click me</div>
<ul class="veylo-popup" id="ctx"><li>Cut</li><li>Copy</li></ul>
<script>
document.getElementById('ctx').addEventListener('veylo-pick', function (e) {
console.log(e.detail.item.textContent);
});
</script>The menu opens at the pointer and stays on screen. Click away, Esc, scrolling or resizing closes it. The right-click menu key and Shift+F10 also work.
Use data-tip (see Feedback).