Skip to content

Commit 5e2b739

Browse files
committed
docs(site): a click locks a cartridge in SELECT YOUR ENVIRONMENT, so the pointer can cross the shelf to NOW PLAYING or the sidebar (round 43, DR-143)
The maintainer: "The "SELECT YOUR ENVIRONMENT" (everywhere, not just in docfx) needs to change on hover like it does now but if user select an envrionment (and can deselect by clicking again) then stop showing other environments on hover. this way i can select in middle of screen and bring my mouse out to the side menu or the NOW PLAYING without it accidentally touching." The gallery is one include and one script on both pages that carry it, the landing page and the Environments page, so both change. Asked how a locked cartridge should look, with three working prototypes (the gallery's own styles and pixel font): "The cursor settles". - docs/website-src/templates/gymnet/public/main.js, installArcade: a hover previews a cartridge, as before, unless one is locked; a click locks it (showing it first, which ends attract mode as any reader choice does); while locked, the pointer crossing the other cartridges changes nothing; a click on the locked cartridge, or Esc while focus is in the gallery, releases it; a click on another moves the lock; the arrow keys, Home and End carry it along. Esc is taken only when there is a lock to release. On a touch screen a tap fires mouseenter before its click, so a tap on an unlocked shelf previews, then locks; a tap on the locked cartridge releases it. - main.css: `.gn-cart.gn-locked[aria-selected="true"]`: the frame stops blinking and stays gold (#f8b800), and the arrow turns gold. A hover preview keeps the blinking frame and the white arrow, so the two read apart at a glance. - docs/website-src/includes/arcade.md: the links line under READ THE MANUAL ends with the hint, " · click a cartridge to keep it", which reads " · click it again or Esc to let go" while one is locked. Checked in throw-away headless Chrome with real pointer and key events, on both pages (scratch arcade/lock-test.mjs), 20 of 20: before any choice nothing is locked and the hint says how to lock; a hover previews, blinking; a click locks (no animation, gold frame, gold arrow, the let-go hint); hovering five other cartridges leaves it on the screen; a click on another moves the lock; ArrowRight carries it; Esc releases it and the cursor blinks again; a hover previews again; a click on the locked cartridge releases it; a hover previews once more. The same test on the live site, which has no lock, fails 12 of 20, the hover-while-locked check among them. The headless sweep at both views (the gallery's 24 cartridges each still open their page), the guides' and landing page's checks 11 of 11, and the sidebar's 10 of 10 all pass; docfx 20 warnings (the baseline), 0 errors. On the way, a false alarm worth knowing: the site scrolls smoothly (scroll-behavior: smooth), so a test that scrolls a cartridge into view and moves the pointer at once can catch it mid-scroll and end over another cartridge; the test scrolls instantly. The page itself never scrolls on hover.
1 parent 7e9ddb7 commit 5e2b739

3 files changed

Lines changed: 79 additions & 7 deletions

File tree

‎docs/website-src/includes/arcade.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Keep it one HTML block with no blank line inside, or markdown would end the bloc
2222
</dl>
2323
</div>
2424
<a class="gn-manual-button" hidden><canvas class="gn-pixel" data-text="&gt; READ THE MANUAL" data-scale="3" data-color="#000"></canvas></a>
25-
<p class="gn-links">Or open <a data-link="example" target="_blank" rel="noopener">its example</a> · <a data-link="gymnasium" target="_blank" rel="noopener">Gymnasium's page</a> · <a data-link="api">the API</a><span class="gn-enter" hidden> · Enter opens the manual</span></p>
25+
<p class="gn-links">Or open <a data-link="example" target="_blank" rel="noopener">its example</a> · <a data-link="gymnasium" target="_blank" rel="noopener">Gymnasium's page</a> · <a data-link="api">the API</a><span class="gn-enter" hidden> · Enter opens the manual</span><span class="gn-lock-hint"> · click a cartridge to keep it</span></p>
2626
</div>
2727
</div>
2828
<canvas class="gn-pixel gn-press-start" data-text="PRESS START" data-scale="2" data-color="#f8b800"></canvas>

‎docs/website-src/templates/gymnet/public/main.css‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,18 @@
253253
border-left: 12px solid #fcfcfc;
254254
}
255255

256+
/* A locked cartridge (DR-143): a click keeps it on the screen while the pointer crosses the others, and its cursor
257+
settles: the frame stops blinking and stays gold, and the arrow turns gold. A hover preview keeps blinking, so the
258+
two read apart at a glance. */
259+
.gn-cart.gn-locked[aria-selected="true"] {
260+
animation: none;
261+
border-color: #f8b800;
262+
}
263+
264+
.gn-cart.gn-locked[aria-selected="true"]::after {
265+
border-left-color: #f8b800;
266+
}
267+
256268
.gn-cart-art {
257269
display: flex;
258270
align-items: center;

‎docs/website-src/templates/gymnet/public/main.js‎

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// 2. the 8-bit "select your environment" gallery (on the landing page and the Environments page, one shared include,
77
// website-src/includes/arcade.md), filled from images/envs/envs.json, which the showreel tool (tools/showreel)
88
// writes together with the looping clips (the cartridges' 8-bit WebPs and the "now playing" screen's full-size
9-
// MP4s), with each cartridge's game manual (DR-102);
9+
// MP4s), with each cartridge's game manual (DR-102); a hover previews a cartridge, a click locks it (DR-143);
1010
// 3. links docfx could not resolve (repository files outside the site, such as CLAUDE.md or LICENSE) are pointed at
1111
// GitHub, so pages copied from docs/ keep working links on the site;
1212
// 4. the env pages' episode anatomy (DR-115): a chart of the recorded episode, drawn from its step trace, with a
@@ -230,8 +230,11 @@ async function writtenPages(root) {
230230
* "now playing" panel with the chosen env's family, its full-size loop, a HUD with the showreel episode's seed, steps
231231
* and return, its game manual (DR-102: HOW TO PLAY in game words, READ THE MANUAL opening the env's page, links to its
232232
* example, Gymnasium's page and the API). It runs in attract mode (the cursor moves on by itself every few seconds)
233-
* until the reader hovers, clicks or uses the arrow keys; Enter opens the selected env's page. Does nothing on pages
234-
* without the gallery, or when the manifest cannot be fetched.
233+
* until the reader hovers, clicks or uses the arrow keys; Enter opens the selected env's page. Hovering a cartridge
234+
* shows it; a click locks it (DR-143): while locked, hovering the others leaves NOW PLAYING alone, so a reader can pick a
235+
* cartridge mid-shelf and cross the rest to the panel or the sidebar. A click on the locked cartridge, or Esc, releases
236+
* it; a click on another moves the lock; the arrow keys, Home and End carry it along. Does nothing on pages without the
237+
* gallery, or when the manifest cannot be fetched.
235238
* @returns {Promise<void>} Settles when the gallery is built (or skipped).
236239
*/
237240
async function installArcade() {
@@ -268,6 +271,8 @@ async function installArcade() {
268271
const linksLine = arcade.querySelector('.gn-links')
269272
const links = linksLine.querySelectorAll('a[data-link]')
270273
const enterHint = arcade.querySelector('.gn-enter')
274+
// The lock's hint at the end of the links line (DR-143); an include older than the lock has none.
275+
const lockHint = arcade.querySelector('.gn-lock-hint')
271276

272277
/**
273278
* The address READ THE MANUAL opens for an env: its page (with the variant's section) when the site has that page,
@@ -304,14 +309,57 @@ async function installArcade() {
304309
// The text painted now; fitLabels compares against it, so a label that fits is not painted twice.
305310
name.dataset.label = env.id
306311
button.append(art, name)
307-
button.addEventListener('click', () => select(i, true))
308-
button.addEventListener('mouseenter', () => select(i, true))
312+
button.addEventListener('click', () => toggleLock(i))
313+
// A hover only previews: while a cartridge is locked, the pointer crossing the others changes nothing (DR-143).
314+
// On a touch screen a tap fires this before its click, so a tap on an unlocked shelf previews, then locks.
315+
button.addEventListener('mouseenter', () => {
316+
if (locked < 0) {
317+
select(i, true)
318+
}
319+
})
309320
carts.appendChild(button)
310321
return button
311322
})
312323

313324
let current = -1
314325

326+
/**
327+
* The cartridge the reader locked with a click (DR-143), or -1 while none is: a locked cartridge stays on NOW PLAYING
328+
* whatever the pointer crosses, until a click on it or Esc releases it.
329+
* @type {number}
330+
*/
331+
let locked = -1
332+
333+
/**
334+
* A click on a cartridge: it locks that env on the screen (showing it first, which ends attract mode as any reader
335+
* choice does), moves the lock there from another cartridge, or, on the locked cartridge itself, releases the lock.
336+
* @param {number} i The clicked cartridge's index in the manifest.
337+
* @returns {void}
338+
*/
339+
function toggleLock(i) {
340+
if (locked === i) {
341+
setLock(-1)
342+
return
343+
}
344+
select(i, true)
345+
setLock(i)
346+
}
347+
348+
/**
349+
* Sets the lock and its marks: the locked cartridge's settled cursor (`.gn-locked`: its frame stops blinking and
350+
* stays gold, its arrow turns gold, main.css) and the hint at the end of the links line, which says how to lock, or
351+
* how to let go.
352+
* @param {number} i The env to lock (always the selected one), or -1 to release the lock.
353+
* @returns {void}
354+
*/
355+
function setLock(i) {
356+
locked = i
357+
buttons.forEach((b, n) => b.classList.toggle('gn-locked', n === i))
358+
if (lockHint) {
359+
lockHint.textContent = i < 0 ? ' · click a cartridge to keep it' : ' · click it again or Esc to let go'
360+
}
361+
}
362+
315363
/**
316364
* Repaints each cartridge's label for the width its cartridge now has (cartLabel), and the NOW PLAYING label for the
317365
* panel's width (nowPlayingText): one line where the text fits, two where it would be squeezed. Painting only on a
@@ -467,8 +515,16 @@ async function installArcade() {
467515
}
468516

469517
// Arrow keys move the cursor through the grid while focus is inside the gallery; Home and End jump to the ends;
470-
// Enter opens the selected env's page.
518+
// Enter opens the selected env's page; Esc releases a lock.
471519
arcade.addEventListener('keydown', (e) => {
520+
if (e.key === 'Escape') {
521+
// Only a lock to release takes the key; otherwise Esc stays the page's (a dialog's, the search box's).
522+
if (locked >= 0) {
523+
e.preventDefault()
524+
setLock(-1)
525+
}
526+
return
527+
}
472528
if (e.key === 'Enter') {
473529
// A focused link (the example, Gymnasium's page, the API, READ THE MANUAL itself) follows its own address.
474530
if (e.target instanceof Element && e.target.closest('a')) {
@@ -496,6 +552,10 @@ async function installArcade() {
496552
}
497553
e.preventDefault()
498554
select(next, true)
555+
// A key is as deliberate as a click: a lock moves along with the cursor instead of being left behind.
556+
if (locked >= 0) {
557+
setLock(next)
558+
}
499559
buttons[next].focus()
500560
})
501561

0 commit comments

Comments
 (0)