Use tile contours for map focus indicators
This commit is contained in:
parent
beff51dbb9
commit
c58bf7ec31
2 changed files with 20 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
14
viewer/ui.js
14
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, `<div class="play">${html}</div>`, 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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue