(root: HTMLElement)
| 41 | } |
| 42 | |
| 43 | function mount(root: HTMLElement) { |
| 44 | let platform: Platform = getStoredPlatform() |
| 45 | |
| 46 | root.innerHTML = ` |
| 47 | <h1>formatForDisplay</h1> |
| 48 | <p class="lead"> |
| 49 | Mock the viewer's OS to see how the same chord string is shown in the UI. |
| 50 | Two columns both use <code>formatForDisplay</code> with |
| 51 | <code>useSymbols: true</code> vs <code>useSymbols: false</code>. |
| 52 | Uses <code>@tanstack/hotkeys</code> only (no framework). |
| 53 | </p> |
| 54 | <fieldset> |
| 55 | <legend>Display platform</legend> |
| 56 | <div class="platform-options" id="platform-radios"></div> |
| 57 | </fieldset> |
| 58 | <table> |
| 59 | <thead> |
| 60 | <tr> |
| 61 | <th>Raw</th> |
| 62 | <th><code>formatForDisplay</code> (<code>useSymbols: true</code>)</th> |
| 63 | <th><code>formatForDisplay</code> (<code>useSymbols: false</code>)</th> |
| 64 | </tr> |
| 65 | </thead> |
| 66 | <tbody id="shortcut-rows"></tbody> |
| 67 | </table> |
| 68 | ` |
| 69 | |
| 70 | const radiosHost = root.querySelector('#platform-radios')! |
| 71 | const tbody = root.querySelector('#shortcut-rows')! |
| 72 | |
| 73 | const platforms: Array<{ value: Platform; label: string }> = [ |
| 74 | { value: 'mac', label: 'macOS' }, |
| 75 | { value: 'windows', label: 'Windows' }, |
| 76 | { value: 'linux', label: 'Linux' }, |
| 77 | ] |
| 78 | |
| 79 | for (const { value, label } of platforms) { |
| 80 | const id = `platform-${value}` |
| 81 | const wrap = document.createElement('label') |
| 82 | wrap.innerHTML = ` |
| 83 | <input type="radio" name="platform" id="${id}" value="${value}" ${ |
| 84 | platform === value ? 'checked' : '' |
| 85 | } /> |
| 86 | <span>${label}</span> |
| 87 | ` |
| 88 | radiosHost.appendChild(wrap) |
| 89 | } |
| 90 | |
| 91 | function renderRows() { |
| 92 | tbody.replaceChildren() |
| 93 | for (const hotkey of SHORTCUTS) { |
| 94 | const tr = document.createElement('tr') |
| 95 | const withSymbols = formatForDisplay(hotkey, { |
| 96 | platform, |
| 97 | useSymbols: true, |
| 98 | }) |
| 99 | const withLabels = formatForDisplay(hotkey, { |
| 100 | platform, |
no test coverage detected
searching dependent graphs…