From 747861351a14c9dd9bee0c6118c92e76a53a1af3 Mon Sep 17 00:00:00 2001
From: Ekremzhan
${esc(claim.head)}${claim.sub ? `${esc(claim.sub)}` : ''}
${facts.join('')}
${acts} @@ -2943,16 +2948,18 @@ function showPane(name) { // no rounded top, no border and no grip there. index.html hangs those off the // body rather than the pane, because the sheet is what has to lose them. document.body.classList.toggle('carding', name === 'card'); + document.body.classList.toggle('rooming', name === 'room'); document.body.classList.remove('waying'); for (const id of PANES) $(id).hidden = id !== name; $('find').hidden = name !== 'pick'; $('origin').hidden = !originBarOn(name); $('ask').hidden = true; $('sheet').hidden = false; - // One corner, two controls, never both. The card is a photograph and gets the - // menu; everything else is a panel or a map and keeps the arrow. + // The card and desktop room screen keep the menu over the map. The room's + // back arrow lives in its panel on desktop; CSS keeps this global arrow on + // mobile, where the room still fills the sheet. $('back').hidden = name === 'card'; - $('menu').hidden = name !== 'card'; + $('menu').hidden = name !== 'card' && name !== 'room'; closeMenu(); document.body.classList.remove('asking'); const arrived = state.screen !== name; @@ -2978,7 +2985,7 @@ function showAsk() { $('way').hidden = true; $('ask').hidden = false; document.body.classList.add('asking'); - document.body.classList.remove('carding', 'waying'); + document.body.classList.remove('carding', 'rooming', 'waying'); $('sheet').hidden = true; $('back').hidden = true; $('menu').hidden = true; @@ -3084,6 +3091,8 @@ function showAbout() { // heading and re-snaps the sheet to rest, and a sheet that jumps back to rest // under a reader is worse than a stale number. function wireRoom(id) { + $('room-back').setAttribute('aria-label', roomBackLabel()); + $('room-back').onclick = () => history.back(); attachBearing(id); // A week either way, and no clamp. Past the term's own bounds the grid comes // back empty and the sentence over it says the schedule does not reach there. @@ -3164,16 +3173,7 @@ function showRoom(id, { keepDay = false } = {}) { // Back pops to the entry underneath this one, and openRoom wrote down which // screen that is. Outside scheduled hours the room screen opens over the // buildings screen, and the label promised a room list that is not there. - $('back').setAttribute( - 'aria-label', - history.state?.from === 'near' - ? 'Back to the nearest buildings' - : history.state?.from === 'browse' - ? 'Back to browse buildings' - : history.state?.from === 'way' - ? 'Back to the way' - : 'Back to the room list', - ); + $('back').setAttribute('aria-label', roomBackLabel()); // frame() below runs only when the room is one of the ranked rows. Opened // from a link or out of hours it is not, and the footprint still has to light. @@ -3192,6 +3192,16 @@ function showRoom(id, { keepDay = false } = {}) { } } +function roomBackLabel() { + return history.state?.from === 'near' + ? 'Back to the nearest buildings' + : history.state?.from === 'browse' + ? 'Back to browse buildings' + : history.state?.from === 'way' + ? 'Back to the way' + : 'Back to the room list'; +} + // Where the room is: the map with the footprint lit, an arrow to it, one plate // naming it, and the ranking peeked underneath with that room's row lit. // @@ -3233,7 +3243,7 @@ function showWay(id, view = null) { $('menu').hidden = false; $('way').hidden = false; closeMenu(); - document.body.classList.remove('asking', 'carding'); + document.body.classList.remove('asking', 'carding', 'rooming'); // The menu is this screen's only chrome, and it is the same button it was on // the card a tap ago, so it is drawn the same: no disc, 40px in a 60px target. document.body.classList.add('waying'); diff --git a/scripts/test/screens.test.mjs b/scripts/test/screens.test.mjs index f080df0..a922368 100644 --- a/scripts/test/screens.test.mjs +++ b/scripts/test/screens.test.mjs @@ -1283,9 +1283,11 @@ test('the back button on the room screen names the pane back lands on', () => { // so separate matches all hold with the arms swapped, which is the reported // defect back again. Three arms now: the way opens rooms too, and it is not // the room list. - const show = bodyOf('showRoom'); - assert.match(show, /from === 'near'\s*\?\s*'Back to the nearest buildings'/); - assert.match(show, /from === 'way'\s*\?\s*'Back to the way'\s*:\s*'Back to the room list'/); + const label = bodyOf('roomBackLabel'); + assert.match(label, /from === 'near'\s*\?\s*'Back to the nearest buildings'/); + assert.match(label, /from === 'way'\s*\?\s*'Back to the way'\s*:\s*'Back to the room list'/); + assert.match(bodyOf('roomHtml'), /id="room-back"/); + assert.match(bodyOf('wireRoom'), /\$\('room-back'\)\.onclick = \(\) => history\.back\(\)/); }); // ---- the duration, and where the list says it @@ -1512,7 +1514,7 @@ test('neither screen without a back arrow is a dead end', () => { // the arrow left. const pane = bodyOf('showPane'); assert.match(pane, /\$\('back'\)\.hidden = name === 'card'/); - assert.match(pane, /\$\('menu'\)\.hidden = name !== 'card'/); + assert.match(pane, /\$\('menu'\)\.hidden = name !== 'card' && name !== 'room'/); const way = bodyOf('showWay'); assert.match(way, /\$\('back'\)\.hidden = true/); assert.match(way, /\$\('menu'\)\.hidden = false/); @@ -1526,6 +1528,10 @@ test('neither screen without a back arrow is a dead end', () => { // A disclosure, not a menu: role="menu" promises arrow keys move between the // items, and the app does not implement that. const css = readFileSync(join(ROOT, 'index.html'), 'utf8'); + // The desktop hamburger has a 60px target and Back has a 44px target. Back + // needs half that 16px difference on both axes for the two glyph centres to + // occupy the same corner when one screen replaces the other. + assert.match(css, /#back \{\s*left:\s*calc\(1\.5rem \+ 8px\);\s*top:\s*calc\(var\(--safe-t\) \+ 1\.1rem \+ 8px\);\s*\}/); assert.match(css, /