diff --git a/viewer/style.css b/viewer/style.css index 7c6b29f..3b07501 100644 --- a/viewer/style.css +++ b/viewer/style.css @@ -54,6 +54,11 @@ outline: 3px solid #bb773c; outline-offset: 3px; } +/* SVG groups otherwise receive a rectangular outline around their bounds. + Their keyboard focus uses the tile-shaped overlay instead. */ +.vanuatu .map-cell:focus { + outline: none; +} .vanuatu .action-dock button { background-image: linear-gradient(#ffffff38, #b9955720); box-shadow: @@ -448,6 +453,7 @@ stroke-dasharray: 8 5; } .vanuatu .cell-highlight.legal.hovered, +.vanuatu .cell-highlight.focused, .vanuatu .cell-highlight.selected { stroke: #9c692c; stroke-width: 5; diff --git a/viewer/ui.js b/viewer/ui.js index db57d8f..8dafbbb 100644 --- a/viewer/ui.js +++ b/viewer/ui.js @@ -460,6 +460,7 @@ export function mountGame(target, options = {}) { cell.removeAttribute(attribute); } } + updateMapFocus(); if (focus) play .querySelector(`[data-action="${focus}"]`) @@ -517,6 +518,7 @@ export function mountGame(target, options = {}) { // Patch in place so cached SVG tile images and focused controls survive // preference changes and incoming state updates. patch(play, `
${html}
`, true); + updateMapFocus(); observeTray(); mapZoom.update(mapAnchor); if (focus) @@ -647,6 +649,18 @@ export function mountGame(target, options = {}) { if (s.phase === "expand") render(); else renderControls(); } + function updateMapFocus() { + const cell = play.querySelector('.map-cell[role="button"]:focus-visible'); + const highlight = + cell && + play.querySelector(`[data-highlight-cell="${cell.dataset.cell}"]`); + for (const previous of play.querySelectorAll(".cell-highlight.focused")) + if (previous !== highlight) previous.classList.remove("focused"); + if (highlight && !highlight.classList.contains("focused")) + highlight.classList.add("focused"); + } + for (const event of ["focusin", "focusout"]) + root.addEventListener(event, updateMapFocus, listener); for (const event of ["pointerover", "pointerout"]) root.addEventListener( event,