.nav__brand is display:none below 1024px, so "tap the wordmark" was desktop-only. Add a shared onTapCode() helper (src/lib/tap-code.js) and put the 7-tap shortcut on the dex feed's game-title (.feed-head__id), which is visible on every screen size. Keeps the wordmark tap for desktop. 3 tests for onTapCode (count, window reset, unbind). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Ve7HLspzeG2xDPtJQ8vmu
24 lines
599 B
JavaScript
24 lines
599 B
JavaScript
/**
|
|
* Fire `fn` after `count` taps/clicks land on `node` within `windowMs` of
|
|
* each other — a quiet way to hide a shortcut behind a bit of fidgeting.
|
|
* Returns an unbind.
|
|
*/
|
|
export function onTapCode(node, fn, { count = 7, windowMs = 1500 } = {}) {
|
|
let n = 0;
|
|
let timer = null;
|
|
const onClick = () => {
|
|
n += 1;
|
|
clearTimeout(timer);
|
|
timer = setTimeout(() => (n = 0), windowMs);
|
|
if (n >= count) {
|
|
n = 0;
|
|
fn();
|
|
}
|
|
};
|
|
node.addEventListener('click', onClick);
|
|
return () => {
|
|
clearTimeout(timer);
|
|
node.removeEventListener('click', onClick);
|
|
};
|
|
}
|