Add help dialog with keybindings reference

This commit is contained in:
Simon Ser 2021-03-08 17:05:48 +01:00
parent 30157383e8
commit 17a2d48b2e
4 changed files with 66 additions and 0 deletions

36
components/help.js Normal file
View file

@ -0,0 +1,36 @@
import { html, Component } from "../lib/index.js";
import { keybindings } from "../keybindings.js";
function KeyBindingsHelp() {
var l = keybindings.map((binding) => {
var keys = [];
if (binding.ctrlKey) {
keys.psuh("Ctrl");
}
if (binding.altKey) {
keys.push("Alt");
}
keys.push(binding.key);
keys = keys.map((name, i) => {
return html`
${i > 0 ? "+" : null}
<kbd>${name}</kbd>
`;
});
return html`
<dt>${keys}</dt>
<dd>${binding.description}</dd>
`;
});
return html`<dl>${l}</dl>`;
}
export default function Help() {
return html`
<h3>Key bindings</h3>
<${KeyBindingsHelp}/>
`;
}