import { Component, For } from "solid-js" import { formatShortcut, isMac } from "../lib/keyboard-utils" import type { KeyboardShortcut } from "../lib/keyboard-registry" import Kbd from "./kbd" import HintRow from "./hint-row" const KeyboardHint: Component<{ shortcuts: KeyboardShortcut[] separator?: string showDescription?: boolean }> = (props) => { function buildShortcutString(shortcut: KeyboardShortcut): string { const parts: string[] = [] if (shortcut.modifiers.ctrl || shortcut.modifiers.meta) { parts.push("cmd") } if (shortcut.modifiers.shift) { parts.push("shift") } if (shortcut.modifiers.alt) { parts.push("alt") } parts.push(shortcut.key) return parts.join("+") } return ( {(shortcut, i) => ( <> {i() > 0 && {props.separator || "•"}} {props.showDescription !== false && {shortcut.description}} )} ) } export default KeyboardHint