Collapse export reference by default on mobile
This commit is contained in:
parent
e1fbc4166e
commit
6b5965b670
5 changed files with 132 additions and 2 deletions
|
|
@ -361,7 +361,14 @@ async function assertExportHelp(language = "en", colorBlind = false) {
|
|||
},
|
||||
]),
|
||||
);
|
||||
const toggle = page.locator(".market-info [data-export-help]");
|
||||
if (await toggle.isVisible()) {
|
||||
if ((await toggle.getAttribute("aria-expanded")) === "false")
|
||||
await toggle.click();
|
||||
assert.equal(await toggle.getAttribute("aria-expanded"), "true");
|
||||
}
|
||||
const reference = page.locator(".trade-info > .export-reference");
|
||||
assert.ok(await reference.isVisible());
|
||||
assert.equal(await reference.count(), 1);
|
||||
assert.equal(await reference.getAttribute("role"), "group");
|
||||
assert.equal(
|
||||
|
|
|
|||
|
|
@ -48,6 +48,62 @@ try {
|
|||
);
|
||||
await page.goto(`${base}/?new&hotseat&players=${count}&locale=fr`);
|
||||
await page.waitForFunction(() => window.vanuatuDemo);
|
||||
const toggle = page.locator(".market-info [data-export-help]");
|
||||
const reference = page.locator(".trade-info > .export-reference");
|
||||
const dashboard = page.locator(".sea-dashboard");
|
||||
async function assertExpanded(open) {
|
||||
assert.equal(await toggle.getAttribute("aria-expanded"), String(open));
|
||||
assert.equal(
|
||||
await page
|
||||
.locator(".sea-board")
|
||||
.getAttribute("data-export-help-open"),
|
||||
String(open),
|
||||
);
|
||||
assert.equal(await reference.isVisible(), open);
|
||||
assert.equal(
|
||||
await page
|
||||
.locator(".map-scroll")
|
||||
.evaluate((el) => getComputedStyle(el).paddingTop),
|
||||
open ? "108px" : "80px",
|
||||
);
|
||||
}
|
||||
await assertExpanded(false);
|
||||
// The localized accessible name identifies the same visible button.
|
||||
assert.equal(
|
||||
await page
|
||||
.getByRole("button", {
|
||||
name: "Exporter des marchandises",
|
||||
exact: true,
|
||||
})
|
||||
.count(),
|
||||
1,
|
||||
);
|
||||
assert.ok(await toggle.isVisible());
|
||||
const closedHeight = await dashboard.evaluate(
|
||||
(el) => el.getBoundingClientRect().height,
|
||||
);
|
||||
assert.ok(
|
||||
closedHeight <= 70,
|
||||
`${width}px/${count} players: collapsed dashboard stays at most 70px tall`,
|
||||
);
|
||||
assert.ok(
|
||||
await dashboard.evaluate((el) => {
|
||||
const market = el
|
||||
.querySelector(".market-info")
|
||||
.getBoundingClientRect();
|
||||
const ships = el
|
||||
.querySelector(".demand-ships")
|
||||
.getBoundingClientRect();
|
||||
return ships.top >= market.bottom && ships.height > 0;
|
||||
}),
|
||||
"market and demand ships occupy two visible rows",
|
||||
);
|
||||
await toggle.click();
|
||||
await assertExpanded(true);
|
||||
assert.ok(
|
||||
(await dashboard.evaluate((el) => el.getBoundingClientRect().height)) >
|
||||
closedHeight,
|
||||
);
|
||||
await page.evaluate(() => {
|
||||
let s = vanuatuDemo.state;
|
||||
while (s.phase === "character")
|
||||
|
|
@ -71,9 +127,11 @@ try {
|
|||
vanuatuDemo.setState(s);
|
||||
vanuatuDemo.ui.setPreferences({ language: "fr", colorBlind: true });
|
||||
});
|
||||
await assertExpanded(true); // State and preference updates preserve expansion.
|
||||
// Even five players' stacks plus a draft marker fit in the same band.
|
||||
await page.locator('[data-action="rest"]').click();
|
||||
assert.equal(await page.locator(".draft-marker").textContent(), "+1");
|
||||
await assertExpanded(true); // Draft redraws preserve expansion too.
|
||||
await page.locator(".trade-info").scrollIntoViewIfNeeded();
|
||||
// Measure settled geometry, not the marker-drop animation's temporary scale.
|
||||
await page.evaluate(() => window.vanuatuDemo.ui.whenIdle());
|
||||
|
|
@ -201,6 +259,16 @@ try {
|
|||
},
|
||||
`${width}px/${count} players: French/color-blind export helper fits without clipping or covering other overlays; tooltips receive pointer hits`,
|
||||
);
|
||||
await toggle.click();
|
||||
await assertExpanded(false);
|
||||
assert.ok(
|
||||
Math.abs(
|
||||
(await dashboard.evaluate(
|
||||
(el) => el.getBoundingClientRect().height,
|
||||
)) - closedHeight,
|
||||
) <= 1,
|
||||
"closing restores the compact dashboard height after state, preferences and draft updates",
|
||||
);
|
||||
assert.equal(layout.actions, 9);
|
||||
assert.equal(
|
||||
layout.dockScroll,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,17 @@ try {
|
|||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.goto(base + "/qa/hosted.html");
|
||||
await page.locator(".map-3d canvas").waitFor();
|
||||
async function openExportHelp() {
|
||||
const toggle = page.locator(".market-info [data-export-help]");
|
||||
assert.equal(await toggle.isVisible(), width <= 700);
|
||||
if (width <= 700) {
|
||||
assert.equal(await toggle.getAttribute("aria-expanded"), "false");
|
||||
await toggle.click();
|
||||
assert.equal(await toggle.getAttribute("aria-expanded"), "true");
|
||||
}
|
||||
assert.ok(await page.locator(".export-reference").isVisible());
|
||||
}
|
||||
await openExportHelp();
|
||||
const state = () => page.locator("#status").textContent().then(JSON.parse);
|
||||
assert.equal(
|
||||
(await state()).updates.length,
|
||||
|
|
@ -20,6 +31,14 @@ try {
|
|||
for (const enabled of [true, false, true]) {
|
||||
await page.locator("[data-color-blind]").click();
|
||||
assert.equal((await state()).preferences.colorBlind, enabled);
|
||||
assert.ok(await page.locator(".export-reference").isVisible());
|
||||
if (width <= 700)
|
||||
assert.equal(
|
||||
await page
|
||||
.locator("[data-export-help]")
|
||||
.getAttribute("aria-expanded"),
|
||||
"true",
|
||||
);
|
||||
assert.equal(
|
||||
await page.locator(".export-reference .resource-symbol").count(),
|
||||
enabled ? 3 : 0,
|
||||
|
|
@ -61,6 +80,7 @@ try {
|
|||
await page.goto(base + "/qa/hosted.html?saved");
|
||||
assert.equal((await state()).preferences.mapView, "3d");
|
||||
await page.locator(".map-3d canvas").waitFor();
|
||||
await openExportHelp();
|
||||
const reference = page.locator(".trade-info > .export-reference");
|
||||
assert.deepEqual(
|
||||
await reference
|
||||
|
|
|
|||
|
|
@ -528,6 +528,9 @@
|
|||
align-items: center;
|
||||
gap: 3px;
|
||||
}
|
||||
.vanuatu .export-help-toggle {
|
||||
display: none;
|
||||
}
|
||||
.vanuatu .trade-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
@ -1478,7 +1481,7 @@ body:has(.vanuatu) {
|
|||
.vanuatu .map-scroll {
|
||||
height: 57vh;
|
||||
min-height: 430px;
|
||||
padding: 108px 0 104px;
|
||||
padding: 80px 0 104px;
|
||||
}
|
||||
.vanuatu .sea-dashboard {
|
||||
top: 8px;
|
||||
|
|
@ -1499,9 +1502,35 @@ body:has(.vanuatu) {
|
|||
.vanuatu .trade-info {
|
||||
align-items: center;
|
||||
}
|
||||
.vanuatu .export-help-toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 28px;
|
||||
min-width: 32px;
|
||||
min-height: 28px;
|
||||
padding: 2px 5px;
|
||||
margin: -3px -9px -3px 0;
|
||||
border-radius: 0 8px 8px 0;
|
||||
border: 0;
|
||||
border-left: 1px solid #b7975c44;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
}
|
||||
.vanuatu .export-help-toggle[aria-expanded="true"] {
|
||||
background: #f5d99f;
|
||||
}
|
||||
.vanuatu .export-reference {
|
||||
display: none;
|
||||
font-size: 10px;
|
||||
}
|
||||
.vanuatu [data-export-help-open="true"] .export-reference {
|
||||
display: flex;
|
||||
}
|
||||
.vanuatu [data-export-help-open="true"] .map-scroll {
|
||||
padding-top: 108px;
|
||||
}
|
||||
.vanuatu .export-rate,
|
||||
.vanuatu .export-completion {
|
||||
gap: 1px;
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ export function mountGame(target, options = {}) {
|
|||
draft = [],
|
||||
tile = null,
|
||||
bonus = true,
|
||||
exportHelpOpen = false,
|
||||
lang = resolveLocale(options.language ?? "en"),
|
||||
hostedLocale = false,
|
||||
colorBlind = false,
|
||||
|
|
@ -650,7 +651,7 @@ export function mountGame(target, options = {}) {
|
|||
.map((m) => m.cell)
|
||||
: actualTargets();
|
||||
const html = `<header class="game-header"><div class="brand">${btn("🏝️ Vanuatu", "data-boardgame", "wordmark")}<div class="game-credits"><span>Designed by Alain Epron</span><span>Published by Quined Games</span></div></div><div class="round-track" aria-label="${t("round")} ${s.round}/8">${Array.from({ length: 8 }, (_, i) => `<span title="${t("round")} ${i + 1}/8" class="${i + 1 === s.round ? "current" : i + 1 < s.round ? "past" : ""}">${i + 1}</span>`).join("")}</div><nav class="header-tools">${undoAvailable && enabled && !analysis ? titled(t("undoMove"), icon("undo"), "data-undo-move", "icon-button") : ""}${analysis || !options.chat ? "" : titled(t("chat"), `${icon("chat")}<span class="unread-badge" hidden></span>`, 'data-activity="chat"', "icon-button")}${titled(t("journal"), icon("journal"), 'data-activity="journal"', "icon-button")}${titled(t("colorBlind"), icon("colorBlind"), `data-color-blind aria-pressed="${colorBlind}"`, "icon-button")}${titled(t("help"), icon("help"), "data-help", "icon-button")}${titled(t("full"), icon("fullscreen"), "data-fullscreen", "icon-button")}</nav></header>
|
||||
<div class="table">${dock()}<section class="sea-board"><div class="sea-dashboard"><div class="market-info"><span class="fish-price" title="${esc(marketHelp)}">${icon("fish", marketHelp)} = ${token("coin", s.market, marketHelp)}</span><span title="${t("tourist")}">${token("tourist", s.tourists, `${"Tourists available this round"}: ${s.tourists}`)}</span>${s.waterCountdown !== null ? `<span title="${t("waterLeft")}">${token("water", s.waterCountdown, `${t("waterLeft")}: ${s.waterCountdown}`)}</span>` : ""}</div><div class="trade-info">${tradeShips()}${exportReference(colorBlind)}</div></div><div class="map-scroll"><div class="map-canvas">${renderBoard(targets)}</div></div><div class="map-3d"></div><div class="map-tools"><span class="map-view-switch">${btn("2D", `data-map-view="2d" aria-pressed="${mapView === "2d"}"`)}${btn("3D", `data-map-view="3d" aria-pressed="${mapView === "3d"}" ${threeUnavailable ? "disabled" : ""}`)}</span><span class="three-tools">${titled(translateText("Overview", lang), icon("overview"), "data-three-home", "icon-button")}${titled("Zoom out", icon("zoomOut"), "data-three-out", "icon-button")}${titled("Zoom in", icon("zoom"), "data-three-in", "icon-button")}</span>${titled("Zoom out", icon("zoomOut"), "data-zoom-out", "icon-button")}${titled("Zoom in", icon("zoom"), "data-zoom-in", "icon-button")}</div>${s.upcoming.length && s.phase !== "expand" ? titled(t("next"), `${s.upcoming.map((id) => tilePreviewSvg(id, { t, colorBlind, language: lang, prefix: "upcoming-" + id })).join("")}${icon("zoom", t("next"))}`, "data-upcoming", "upcoming") : ""}${trayHtml}</section></div><section class="players">${s.players.map(playerCard).join("")}</section><footer class="play-footer"><span title="${"Automatic conversion"}">${token("coin", 10)} → ${token("point", 5)}</span>${btn(t("help"), "data-help", "text-button")}</footer>`;
|
||||
<div class="table">${dock()}<section class="sea-board" data-export-help-open="${exportHelpOpen}"><div class="sea-dashboard"><div class="market-info"><span class="fish-price" title="${esc(marketHelp)}">${icon("fish", marketHelp)} = ${token("coin", s.market, marketHelp)}</span><span title="${t("tourist")}">${token("tourist", s.tourists, `${"Tourists available this round"}: ${s.tourists}`)}</span>${s.waterCountdown !== null ? `<span title="${t("waterLeft")}">${token("water", s.waterCountdown, `${t("waterLeft")}: ${s.waterCountdown}`)}</span>` : ""}${titled("Export goods", icon("buy"), `data-export-help aria-expanded="${exportHelpOpen}"`, "export-help-toggle icon-button")}</div><div class="trade-info">${tradeShips()}${exportReference(colorBlind)}</div></div><div class="map-scroll"><div class="map-canvas">${renderBoard(targets)}</div></div><div class="map-3d"></div><div class="map-tools"><span class="map-view-switch">${btn("2D", `data-map-view="2d" aria-pressed="${mapView === "2d"}"`)}${btn("3D", `data-map-view="3d" aria-pressed="${mapView === "3d"}" ${threeUnavailable ? "disabled" : ""}`)}</span><span class="three-tools">${titled(translateText("Overview", lang), icon("overview"), "data-three-home", "icon-button")}${titled("Zoom out", icon("zoomOut"), "data-three-out", "icon-button")}${titled("Zoom in", icon("zoom"), "data-three-in", "icon-button")}</span>${titled("Zoom out", icon("zoomOut"), "data-zoom-out", "icon-button")}${titled("Zoom in", icon("zoom"), "data-zoom-in", "icon-button")}</div>${s.upcoming.length && s.phase !== "expand" ? titled(t("next"), `${s.upcoming.map((id) => tilePreviewSvg(id, { t, colorBlind, language: lang, prefix: "upcoming-" + id })).join("")}${icon("zoom", t("next"))}`, "data-upcoming", "upcoming") : ""}${trayHtml}</section></div><section class="players">${s.players.map(playerCard).join("")}</section><footer class="play-footer"><span title="${"Automatic conversion"}">${token("coin", 10)} → ${token("point", 5)}</span>${btn(t("help"), "data-help", "text-button")}</footer>`;
|
||||
// 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);
|
||||
|
|
@ -858,6 +859,11 @@ export function mountGame(target, options = {}) {
|
|||
);
|
||||
return;
|
||||
}
|
||||
if ("exportHelp" in d) {
|
||||
exportHelpOpen = !exportHelpOpen;
|
||||
render();
|
||||
return;
|
||||
}
|
||||
if ("firstHelp" in d) {
|
||||
showDialog(
|
||||
`<h2>${t("first")}</h2><p>${esc(translateText(FIRST_HELP, lang))}</p>`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue