Show the current choice, keyboard focus, and states apart
Phase 5-5. - The current radio row shows a check mark in the icon column and no fill (UI-051, replaces the radio rule of UI-003). The list of all tabs names pinned tabs in text. - Keyboard focus adds a 2-pixel ring inside menu rows. The global focus ring is 2 pixels with a 1-pixel offset. - Active toggles get the accent color, the selection fill, and a 2-pixel accent bar. Hover gets only a neutral fill. Enabled icon buttons use --rs-text. - Disabled controls use --rs-text-dim at full opacity, not opacity. - The file tree has one Tab stop. Up and Down move, Shift extends the selection, Right opens or enters a folder, Left closes it or goes to its parent, Home and End go to the ends, and typed letters find a row. - The three workbench splitters take focus. The arrow keys move them by 16 pixels, and Home and End go to their limits. - Help names Esc, then Tab, to leave the text. - 5 new catalog rows in French, Japanese, and Simplified Chinese. - Docs: UI-051, ui-design.md, and the user guide. Tests: the new layout/keyboardFocus. backgroundImages now expects the check mark on the current radio row.
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import { actionIcon, type ActionIcon } from "./actionIcons.ts";
|
||||
|
||||
/** The check mark of the current radio row. It sits in the icon column and replaces the icon of the row. */
|
||||
function checkMark() {
|
||||
const svg = actionIcon("task");
|
||||
svg.innerHTML = '<path d="M5 12.5 9.5 17 19 7"/>';
|
||||
return svg;
|
||||
}
|
||||
|
||||
export type ActionMenuItem = { label: string; icon?: ActionIcon; shortcut?: string; run?: () => void; children?: ActionMenuItem[]; disabled?: boolean; checked?: boolean; radio?: boolean; title?: string } | { separator: true };
|
||||
|
||||
export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClose: () => void, label = "Table actions", parent: HTMLElement = document.body) {
|
||||
@@ -32,7 +39,7 @@ export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClos
|
||||
if (focus) focusRow(panel.querySelector<HTMLButtonElement>("button:not(:disabled)") ?? undefined);
|
||||
}
|
||||
function populate(panel: HTMLElement, entries: ActionMenuItem[]) {
|
||||
const hasIcons = entries.some(item => !("separator" in item) && (!!item.icon || (item.checked !== undefined && !item.radio)));
|
||||
const hasIcons = entries.some(item => !("separator" in item) && (!!item.icon || item.checked !== undefined));
|
||||
panel.classList.toggle("rs-menu-text", !hasIcons);
|
||||
for (const item of entries) {
|
||||
if ("separator" in item) { const hr = document.createElement("hr"); hr.setAttribute("role", "separator"); panel.append(hr); continue; }
|
||||
@@ -40,7 +47,8 @@ export function actionMenu(x: number, y: number, items: ActionMenuItem[], onClos
|
||||
if (item.checked !== undefined) { button.setAttribute("role", item.radio ? "menuitemradio" : "menuitemcheckbox"); button.setAttribute("aria-checked", String(item.checked)); }
|
||||
if (item.title) button.title = item.title;
|
||||
const label = document.createElement("span"); label.className = "action-label"; label.textContent = item.label;
|
||||
const icon = item.checked && !item.radio ? actionIcon("task") : item.icon ? actionIcon(item.icon) : document.createElement("span");
|
||||
const icon = item.radio ? (item.checked ? checkMark() : document.createElement("span"))
|
||||
: item.checked ? actionIcon("task") : item.icon ? actionIcon(item.icon) : document.createElement("span");
|
||||
icon.classList.add("action-icon"); icon.setAttribute("aria-hidden", "true");
|
||||
button.append(icon, label); panel.append(button);
|
||||
if (item.shortcut) { const shortcut = document.createElement("span"); shortcut.textContent = item.shortcut; shortcut.style.cssText = "margin-left:auto;color:var(--rs-text-dim);font-size:12px;white-space:nowrap"; button.append(shortcut); }
|
||||
|
||||
Reference in New Issue
Block a user