Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tools/build_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,17 @@ def flasher_html(page: Page) -> str:
f'<a href="{SITE_URL}install-firmware/">Open the official installer</a>.</p></div>'
'</esp-web-install-button>'
'<p class="flasher-help">Already installed? Use <strong>System → Firmware</strong> '
'on your gateway to update without a USB cable.</p></section>')
'on your gateway to update without a USB cable.</p>'
# Shown by site.js once the installer dialog closes after a finished install.
'<div class="flasher-done" id="flasher-done" role="status" hidden>'
'<button class="flasher-done-close" type="button" aria-label="Close">✕</button>'
'<strong>Installed. Welcome to RecoveryGateway!</strong>'
'<p>Next: join the board\'s <code>RecoveryGateway-Setup-XXXX</code> Wi-Fi and follow '
f'<a href="{setup}">the first-boot setup</a>.</p>'
'<div class="flasher-tip"><p>If it turns out useful to you, a small tip helps keep it going. '
'Entirely optional: everything stays free.</p>'
'<a class="btn tip-btn" href="https://ko-fi.com/mattboxx" data-support-open aria-haspopup="dialog" '
'aria-controls="support-dialog"><span aria-hidden="true">❤</span> Leave a tip</a></div></div></section>')


def release_note(page: Page) -> str:
Expand Down
44 changes: 44 additions & 0 deletions tools/test_site_browser.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ pages.unshift('');
await page.click('.menu');
if (!(await page.isVisible('#site-nav'))) failures.push(`${width}: mobile menu does not open`);
if (shots) await page.screenshot({ path: path.join(shots, `site-${width}-menu.png`) });
// The bar stays on top while scrolling; the open menu fits the screen
// and closes on page scroll, a tap outside or Escape.
const fits = await page.evaluate(() => document.getElementById('site-nav').getBoundingClientRect().bottom <= innerHeight + 1);
if (!fits) failures.push(`${width}: open menu taller than the screen`);
await page.evaluate(() => scrollTo(0, 600)); await page.waitForTimeout(250);
if (await page.isVisible('#site-nav')) failures.push(`${width}: menu stays open while the page scrolls`);
if (await page.evaluate(() => Math.round(document.querySelector('.top').getBoundingClientRect().top)) !== 0)
failures.push(`${width}: header does not follow the scroll`);
await page.click('.menu'); await page.click('main h2, main p');
if (await page.isVisible('#site-nav')) failures.push(`${width}: menu stays open after a tap outside`);
await page.click('.menu'); await page.keyboard.press('Escape');
if (await page.isVisible('#site-nav')) failures.push(`${width}: menu stays open after Escape`);
}
await page.goto(base, { waitUntil: 'load' });
if (width > 760 && await page.isVisible('.menu')) failures.push(`${width}: mobile menu button visible on a wide screen`);
Expand Down Expand Up @@ -154,6 +166,38 @@ pages.unshift('');
if (dimensions.w !== dimensions.expectedW || dimensions.h !== dimensions.expectedH)
failures.push(`${width}: screenshot dimensions mismatch ${await img.getAttribute('src')}`);
}
// Web installer: the next step and one quiet tip line appear only after a
// finished install, once the installer dialog closes; the tip line at
// most once a month per browser. The dialog is a local stand-in for
// ESP Web Tools' element (no USB device in the test).
await page.goto(base + 'install-firmware/', { waitUntil: 'load' });
if (await page.locator('#flasher-done').count()) {
await page.evaluate(() => localStorage.removeItem('rg-tip-shown'));
const fakeInstall = finished => page.evaluate(async finished => {
const d = document.createElement('ewt-install-dialog');
document.body.appendChild(d);
await new Promise(r => setTimeout(r, 50));
d._installState = { state: finished ? 'finished' : 'writing' };
await new Promise(r => setTimeout(r, 700));
d.dispatchEvent(new CustomEvent('closed')); d.remove();
}, finished);
await fakeInstall(false);
if (await page.isVisible('#flasher-done')) failures.push(`${width}: install note shown without a finished install`);
await fakeInstall(true);
if (!(await page.isVisible('#flasher-done')) || !(await page.isVisible('#flasher-done .flasher-tip')))
failures.push(`${width}: install note or tip line missing after a finished install`);
await page.locator('#flasher-done [data-support-open]').click();
await dialog.waitFor({ state: 'visible' });
await page.keyboard.press('Escape');
await dialog.waitFor({ state: 'hidden' });
await page.locator('.flasher-done-close').click();
if (await page.isVisible('#flasher-done')) failures.push(`${width}: install note does not close`);
await fakeInstall(true);
if (!(await page.isVisible('#flasher-done')) || await page.isVisible('#flasher-done .flasher-tip'))
failures.push(`${width}: tip line repeated within a month`);
if (await page.evaluate(() => document.documentElement.scrollWidth > innerWidth))
failures.push(`${width}: install note overflows horizontally`);
}
if (errors.length) failures.push(`${width}: console/page errors ${[...new Set(errors)].slice(0, 3).join(' | ')}`);
await context.close();
}
Expand Down
22 changes: 19 additions & 3 deletions website/assets/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,17 @@ main:focus { outline: none; }
.flasher-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.flasher .btn, .install-alternative .btn { max-width: 100%; white-space: normal; text-align: center; justify-content: center; font: inherit; font-weight: 600; }
.flasher .flasher-help { margin: 16px 0 0; font-size: 14px; }
/* After a finished install: next step, and one quiet, optional tip line. */
.flasher-done { position: relative; margin: 16px 0 0; padding: 14px 44px 14px 16px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; background: var(--card); }
.flasher-done[hidden], .flasher-done .flasher-tip[hidden] { display: none; }
.flasher-done strong { display: block; margin-bottom: 6px; }
.flasher-done p { margin: 0 0 8px; }
.flasher-done .flasher-tip { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.flasher-done .flasher-tip p { margin: 0 0 10px; }
.flasher-done .tip-btn { color: #0A0F0C; background: #FF5E5B; border-color: #FF5E5B; font-weight: 600; gap: 6px; }
.flasher-done .tip-btn:hover, .flasher-done .tip-btn:focus-visible { background: #FF7D7A; border-color: #FF7D7A; }
.flasher-done-close { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: 16px var(--font); cursor: pointer; }
.flasher-done-close:hover, .flasher-done-close:focus-visible { color: var(--text); background: var(--surface); }
.install-alternative { margin: 20px 0; }
.install-alternative h2 { margin-top: 0; font-size: 22px; }
@media (max-width: 480px) {
Expand Down Expand Up @@ -185,9 +196,14 @@ summary { cursor: pointer; font-weight: 600; }
.hero { grid-template-columns: 1fr; padding-top: 32px; }
}
@media (max-width: 760px) {
/* Phones: the header scrolls with the page. Sticky, it stayed on screen with
* the menu open (over half the viewport) and could hide the page heading. */
.top { position: relative; backdrop-filter: none; background: var(--bg); }
/* Phones: the header stays on top while scrolling, opaque (a blurred
* translucent bar can freeze while scrolling on mobile browsers). The open
* menu never grows past the screen: it scrolls inside, and site.js closes
* it when the page scrolls, on a tap outside or with Escape, so it cannot
* stay over the page heading. Anchored headings stop below the bar. */
.top { backdrop-filter: none; background: var(--bg); }
.site-nav.open { max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px); overflow-y: auto; overscroll-behavior: contain; }
main [id] { scroll-margin-top: 80px; }
.tools .menu { display: inline-flex; }
.tools .theme { display: none; } /* phones: the board icon takes its place; the theme follows the phone */
.top-inner { flex-wrap: wrap; gap: 8px; }
Expand Down
54 changes: 50 additions & 4 deletions website/assets/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,57 @@
});
}

// Web installer: after a finished install, once its dialog closes, show the
// next step and a quiet tip line (the line at most once a month per browser).
// ESP Web Tools 10.4.0 has no completion event; its dialog element keeps the
// install progress in _installState, read here without changing it.
var done = document.getElementById('flasher-done');
if (done && 'MutationObserver' in window) {
var showDone = function () {
var tip = done.querySelector('.flasher-tip'), now = Date.now(), last = 0;
try { last = Number(localStorage.getItem('rg-tip-shown')) || 0; } catch (e) { last = 0; }
if (tip) tip.hidden = now - last < 30 * 24 * 3600 * 1000;
if (tip && !tip.hidden) { try { localStorage.setItem('rg-tip-shown', String(now)); } catch (e) { /* private mode */ } }
done.hidden = false;
done.scrollIntoView({ block: 'nearest' });
};
done.querySelector('.flasher-done-close').addEventListener('click', function () { done.hidden = true; });
var watchDialog = function (dialog) {
var finished = false;
var timer = setInterval(function () {
var state = dialog._installState;
if (state && state.state === 'finished') finished = true;
}, 500);
dialog.addEventListener('closed', function () { clearInterval(timer); if (finished) showDone(); }, { once: true });
};
new MutationObserver(function (changes) {
changes.forEach(function (change) {
change.addedNodes.forEach(function (node) { if (node.nodeName === 'EWT-INSTALL-DIALOG') watchDialog(node); });
});
}).observe(document.body, { childList: true });
}

var menu = document.querySelector('.menu'), nav = document.getElementById('site-nav');
if (menu && nav) menu.addEventListener('click', function () {
var open = nav.classList.toggle('open');
menu.setAttribute('aria-expanded', open ? 'true' : 'false');
});
if (menu && nav) {
var openedAt = 0;
var setMenu = function (open) {
nav.classList.toggle('open', open);
menu.setAttribute('aria-expanded', open ? 'true' : 'false');
openedAt = window.scrollY;
};
menu.addEventListener('click', function () { setMenu(!nav.classList.contains('open')); });
// The open menu must not stay over the page: close it when the page
// scrolls, on a tap outside the header or with Escape.
window.addEventListener('scroll', function () {
if (nav.classList.contains('open') && Math.abs(window.scrollY - openedAt) > 40) setMenu(false);
}, { passive: true });
document.addEventListener('click', function (e) {
if (nav.classList.contains('open') && !e.target.closest('.top')) setMenu(false);
});
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && nav.classList.contains('open')) { setMenu(false); menu.focus(); }
});
}

var theme = document.querySelector('.theme');
if (theme) theme.addEventListener('click', function () {
Expand Down
Loading