openvibers/openvibe.watch Commits
Home: every pane shows on a phone; the chips are links, not a picker (#173)
Changes
@@@ -64,29 +64,22 @@/* The phone home (2026-10-30, the owner's short-pages rule): the ready-made watches are chips, one group at a time,and the questions are a fold. Both only work under 640 px, so a wider screen shows every group and no chips. */--/* Pick (the owner's short-pages rule, 2026-10-30): on a phone the front page's blocks of the same kind are one at a-- time, picked with a row of chips. Radio inputs and :has(), no script: the chips and the one-pane rule live under-- 640 px and only where :has() is understood, so a wider screen, or an older browser, shows every pane and no chips.-- Every pane stays in the page for crawlers. */--.pick-head { display: none; }--.pick-row { display: none; }--@supports selector(:has(*)) { @media (max-width: 640px) {++/* Pick: on a phone every pane is shown, stacked, each with its own heading; the chips are a row of links that++ jump to a pane (the owner's rule, 2026-10-31: never hide content to shorten). A wide screen shows the panes as++ before, with no chips. */++.pick-head, .pick-row { display: none; }++@media (max-width: 640px) {.pick-bar { margin-top: 30px; }.pick-head { display: block; }.pick-head h2 { margin: 0 0 4px; font: 700 clamp(20px, 2.4vw, 28px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); letter-spacing: -.02em; }.pick-row { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; overscroll-behavior-x: contain; }.pick-row::-webkit-scrollbar { display: none; }-- .pick-row input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }-- .pick-row label { display: inline-flex; align-items: center; flex: none; min-height: 44px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border, #1f2d47); color: var(--text-secondary, #96a7c2); font-size: .9rem; font-weight: 650; white-space: nowrap; cursor: pointer; }-- .pick-row input:checked + label { color: var(--text-primary, #e6edf7); border-color: var(--accent, #3b82f6); background: color-mix(in srgb, var(--accent, #3b82f6) 12%, transparent); }-- .pick-row input:focus-visible + label { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }-- .pick .pick-pane { display: none; }-- /* A link that points at a pane opens that pane on a phone too. */-- .pick .pick-pane:target { display: block !important; }-- .pick:has(.pick-pane:target) .pick-pane:not(:target) { display: none !important; }-- /* The chip names the pane, so the pane's own heading gives way to it; the link to more stays. */-- .pick .pick-pane > h2, .pick .pick-pane > h3 { display: none; }--} }++ .pick-chip { display: inline-flex; align-items: center; flex: none; min-height: 44px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border, #1f2d47); color: var(--text-secondary, #96a7c2); font-size: .9rem; font-weight: 650; white-space: nowrap; text-decoration: none; }++ .pick-chip:hover, .pick-chip:focus-visible { color: var(--text-primary, #e6edf7); border-color: var(--accent, #3b82f6); }++ .pick-chip:focus-visible { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }++ .pick .pick-pane { scroll-margin-top: 72px; }++ .pick .pick-pane + .pick-pane { margin-top: 26px; }++}/* The fold (the owner's short-pages rule): closed on a phone, and where there is room it looks like the section itreplaces: a heading and its content, with no card around it. */@@@ -589,7 +589,6 @@ ${field('The coding task', html`<textarea id="${idOf('codes_brief')}" name="codestyles: [showcase.STYLESHEET],css: ['css/home.css'],// The rule that shows the picked group: one per group, so the CSS is written for this page.-- inlineStyles: [`@supports selector(:has(*)){@media (max-width:640px){${S.pickRules('ready', readyPanes.map((p) => p.id))}}}`],body: html`${raw(hero)}${raw(showcase.features({id: 'start',@@@ -25,23 +25,15 @@ function pickBlock({ key, label, head = '', panes, bodyClass = '' }) {// A pane with nothing to show is left out, so the chips and the rules that show them match the page.panes = (panes || []).filter((p) => p.html);if (!panes.length) return '';-- const chips = panes.map((p, i) => `<input type="radio" name="pick-${esc(key)}" id="pk-${esc(key)}-${esc(p.id)}" value="${esc(p.id)}"${i === 0 ? ' checked' : ''}><label for="pk-${esc(key)}-${esc(p.id)}">${esc(p.label)}</label>`).join('');++ const chips = panes.map((p) => `<a class="pick-chip" href="#${esc(p.id)}">${esc(p.label)}</a>`).join('');// The pane carries the id the page already links to (an anchor in the hero, for instance), so a link to it still// opens that pane on a phone (the CSS shows the pane a link points at).const body = panes.map((p) => `<div class="pick-pane" id="${esc(p.id)}">${p.html}</div>`).join('');-- const bar = `${head ? `<div class="pick-head"><h2>${esc(head)}</h2></div>` : ''}<div class="pick-row" role="radiogroup" aria-label="${esc(label)}">${chips}</div>`;++ const bar = `${head ? `<div class="pick-head"><h2>${esc(head)}</h2></div>` : ''}<nav class="pick-row" aria-label="${esc(label)}">${chips}</nav>`;return `<div class="pick" id="pick-${esc(key)}"><div class="pick-bar">${bar}</div><div class="pick-body${bodyClass ? ' ' + esc(bodyClass) : ''}">${body}</div></div>`;}--/** The rule that shows the picked block of a pick block: one per block, so the CSS is written for the page. */--function pickRule(key, id) {-- return `.pick:has(#pk-${key}-${id}:checked) #${id}{display:block}`;--}--/** The rules for every block of a pick block, in the order they appear. */--function pickRules(key, ids) {-- return ids.map((id) => pickRule(key, id)).join('');--}/*** A fold. The head is the heading the block had; the html is what it holds.@@@ -83,4 +75,4 @@ function foldSection(html, needle, id) {return html.slice(0, start) + openTag + fold + html.slice(close);}--module.exports = { pickBlock, pickRule, pickRules, foldBlock, foldScript, foldSection };++module.exports = { pickBlock, foldBlock, foldScript, foldSection };@@@ -31,9 +31,9 @@ t('the ready-made watches are chips: one per group, the first picked, every grouconst page = home.text;assert.ok(page.includes('<div class="pick" id="pick-ready">'), 'the ready-made watches are a pick block');const block = page.slice(page.indexOf('<div class="pick" id="pick-ready">'));-- const chips = [...block.matchAll(/<input type="radio" name="pick-ready" id="pk-ready-([a-z]+)" value="\1"( checked)?><label for="pk-ready-\1">([^<]+)<\/label>/g)];++ const chips = [...block.matchAll(/<a class="pick-chip" href="#(?:pp-ready-)?([a-z]+)">()([^<]+)<\/a>/g)];assert.deepStrictEqual(chips.map((m) => m[1]), ['prices', 'feeds', 'blogs'], 'a chip per group');-- assert.deepStrictEqual(chips.filter((m) => m[2]).map((m) => m[1]), ['prices'], 'the first group is picked');++ assert.ok(!/type="radio"/.test(block), 'no chip is a radio: nothing is picked, every pane shows');// Every group stays in the page, with the id its chip picks.const panes = [...block.matchAll(/<div class="pick-pane" id="([a-z]+)">/g)].map((m) => m[1]);assert.deepStrictEqual(panes, ['prices', 'feeds', 'blogs'], 'every group is in the page, one per chip');@@@ -46,12 +46,8 @@ t('the ready-made watches are chips: one per group, the first picked, every grout('the CSS guard: the chips are hidden and every group shows until 640 px and where :has() is understood', async () => {const home = await svc.get('/', { headers: { accept: 'text/html' } });const page = home.text;-- assert.match(page, /<style>@supports selector\(:has\(\*\)\)\{@media \(max-width:640px\)\{\.pick:has\(#pk-ready-prices:checked\) #prices\{display:block\}/, 'the rule that shows the picked group');const css = fs.readFileSync(path.join(__dirname, '..', 'public', 'css', 'home.css'), 'utf8');assert.match(css, /\.pick-row \{ display: none; \}/, 'the chips are hidden by default');-- assert.match(css, /@supports selector\(:has\(\*\)\) \{ @media \(max-width: 640px\) \{/, 'the phone rules are under :has() and 640 px');-- assert.match(css, /\.pick-row label \{[^}]*min-height: 44px/, 'a chip is a 44 px target');-- assert.match(css, /\.pick \.pick-pane \{ display: none; \}/, 'the groups are hidden on a phone');});t('the questions are a fold, open in the page and closed on a phone', async () => {
@@ -64,29 +64,22 @@
@@ -64,29 +64,22 @@
/* The phone home (2026-10-30, the owner's short-pages rule): the ready-made watches are chips, one group at a time,
/* The phone home (2026-10-30, the owner's short-pages rule): the ready-made watches are chips, one group at a time,
and the questions are a fold. Both only work under 640 px, so a wider screen shows every group and no chips. */
and the questions are a fold. Both only work under 640 px, so a wider screen shows every group and no chips. */
-/* Pick (the owner's short-pages rule, 2026-10-30): on a phone the front page's blocks of the same kind are one at a
- time, picked with a row of chips. Radio inputs and :has(), no script: the chips and the one-pane rule live under
- 640 px and only where :has() is understood, so a wider screen, or an older browser, shows every pane and no chips.
- Every pane stays in the page for crawlers. */
-.pick-head { display: none; }
-.pick-row { display: none; }
-@supports selector(:has(*)) { @media (max-width: 640px) {
+/* Pick: on a phone every pane is shown, stacked, each with its own heading; the chips are a row of links that
+ jump to a pane (the owner's rule, 2026-10-31: never hide content to shorten). A wide screen shows the panes as
+ before, with no chips. */
+.pick-head, .pick-row { display: none; }
+@media (max-width: 640px) {
.pick-bar { margin-top: 30px; }
.pick-bar { margin-top: 30px; }
.pick-head { display: block; }
.pick-head { display: block; }
.pick-head h2 { margin: 0 0 4px; font: 700 clamp(20px, 2.4vw, 28px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); letter-spacing: -.02em; }
.pick-head h2 { margin: 0 0 4px; font: 700 clamp(20px, 2.4vw, 28px)/1.2 var(--ov-font, 'Inter', system-ui, sans-serif); letter-spacing: -.02em; }
.pick-row { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; overscroll-behavior-x: contain; }
.pick-row { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; overscroll-behavior-x: contain; }
.pick-row::-webkit-scrollbar { display: none; }
.pick-row::-webkit-scrollbar { display: none; }
- .pick-row input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
- .pick-row label { display: inline-flex; align-items: center; flex: none; min-height: 44px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border, #1f2d47); color: var(--text-secondary, #96a7c2); font-size: .9rem; font-weight: 650; white-space: nowrap; cursor: pointer; }
- .pick-row input:checked + label { color: var(--text-primary, #e6edf7); border-color: var(--accent, #3b82f6); background: color-mix(in srgb, var(--accent, #3b82f6) 12%, transparent); }
- .pick-row input:focus-visible + label { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }
- .pick .pick-pane { display: none; }
- /* A link that points at a pane opens that pane on a phone too. */
- .pick .pick-pane:target { display: block !important; }
- .pick:has(.pick-pane:target) .pick-pane:not(:target) { display: none !important; }
- /* The chip names the pane, so the pane's own heading gives way to it; the link to more stays. */
- .pick .pick-pane > h2, .pick .pick-pane > h3 { display: none; }
-} }
+ .pick-chip { display: inline-flex; align-items: center; flex: none; min-height: 44px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--border, #1f2d47); color: var(--text-secondary, #96a7c2); font-size: .9rem; font-weight: 650; white-space: nowrap; text-decoration: none; }
+ .pick-chip:hover, .pick-chip:focus-visible { color: var(--text-primary, #e6edf7); border-color: var(--accent, #3b82f6); }
+ .pick-chip:focus-visible { outline: 2px solid var(--accent, #3b82f6); outline-offset: 2px; }
+ .pick .pick-pane { scroll-margin-top: 72px; }
+ .pick .pick-pane + .pick-pane { margin-top: 26px; }
+}
/* The fold (the owner's short-pages rule): closed on a phone, and where there is room it looks like the section it
/* The fold (the owner's short-pages rule): closed on a phone, and where there is room it looks like the section it
replaces: a heading and its content, with no card around it. */
replaces: a heading and its content, with no card around it. */
@@ -589,7 +589,6 @@ ${field('The coding task', html`<textarea id="${idOf('codes_brief')}" name="code
@@ -589,7 +589,6 @@ ${field('The coding task', html`<textarea id="${idOf('codes_brief')}" name="code
styles: [showcase.STYLESHEET],
styles: [showcase.STYLESHEET],
css: ['css/home.css'],
css: ['css/home.css'],
// The rule that shows the picked group: one per group, so the CSS is written for this page.
// The rule that shows the picked group: one per group, so the CSS is written for this page.
- inlineStyles: [`@supports selector(:has(*)){@media (max-width:640px){${S.pickRules('ready', readyPanes.map((p) => p.id))}}}`],
body: html`${raw(hero)}
body: html`${raw(hero)}
${raw(showcase.features({
${raw(showcase.features({
id: 'start',
id: 'start',
@@ -25,23 +25,15 @@ function pickBlock({ key, label, head = '', panes, bodyClass = '' }) {
@@ -25,23 +25,15 @@ function pickBlock({ key, label, head = '', panes, bodyClass = '' }) {
// A pane with nothing to show is left out, so the chips and the rules that show them match the page.
// A pane with nothing to show is left out, so the chips and the rules that show them match the page.
panes = (panes || []).filter((p) => p.html);
panes = (panes || []).filter((p) => p.html);
if (!panes.length) return '';
if (!panes.length) return '';
- const chips = panes.map((p, i) => `<input type="radio" name="pick-${esc(key)}" id="pk-${esc(key)}-${esc(p.id)}" value="${esc(p.id)}"${i === 0 ? ' checked' : ''}><label for="pk-${esc(key)}-${esc(p.id)}">${esc(p.label)}</label>`).join('');
+ const chips = panes.map((p) => `<a class="pick-chip" href="#${esc(p.id)}">${esc(p.label)}</a>`).join('');
// The pane carries the id the page already links to (an anchor in the hero, for instance), so a link to it still
// The pane carries the id the page already links to (an anchor in the hero, for instance), so a link to it still
// opens that pane on a phone (the CSS shows the pane a link points at).
// opens that pane on a phone (the CSS shows the pane a link points at).
const body = panes.map((p) => `<div class="pick-pane" id="${esc(p.id)}">${p.html}</div>`).join('');
const body = panes.map((p) => `<div class="pick-pane" id="${esc(p.id)}">${p.html}</div>`).join('');
- const bar = `${head ? `<div class="pick-head"><h2>${esc(head)}</h2></div>` : ''}<div class="pick-row" role="radiogroup" aria-label="${esc(label)}">${chips}</div>`;
+ const bar = `${head ? `<div class="pick-head"><h2>${esc(head)}</h2></div>` : ''}<nav class="pick-row" aria-label="${esc(label)}">${chips}</nav>`;
return `<div class="pick" id="pick-${esc(key)}"><div class="pick-bar">${bar}</div><div class="pick-body${bodyClass ? ' ' + esc(bodyClass) : ''}">${body}</div></div>`;
return `<div class="pick" id="pick-${esc(key)}"><div class="pick-bar">${bar}</div><div class="pick-body${bodyClass ? ' ' + esc(bodyClass) : ''}">${body}</div></div>`;
}
}
-/** The rule that shows the picked block of a pick block: one per block, so the CSS is written for the page. */
-function pickRule(key, id) {
- return `.pick:has(#pk-${key}-${id}:checked) #${id}{display:block}`;
-}
-/** The rules for every block of a pick block, in the order they appear. */
-function pickRules(key, ids) {
- return ids.map((id) => pickRule(key, id)).join('');
-}
/**
/**
* A fold. The head is the heading the block had; the html is what it holds.
* A fold. The head is the heading the block had; the html is what it holds.
@@ -83,4 +75,4 @@ function foldSection(html, needle, id) {
@@ -83,4 +75,4 @@ function foldSection(html, needle, id) {
return html.slice(0, start) + openTag + fold + html.slice(close);
return html.slice(0, start) + openTag + fold + html.slice(close);
}
}
-module.exports = { pickBlock, pickRule, pickRules, foldBlock, foldScript, foldSection };
+module.exports = { pickBlock, foldBlock, foldScript, foldSection };
@@ -31,9 +31,9 @@ t('the ready-made watches are chips: one per group, the first picked, every grou
@@ -31,9 +31,9 @@ t('the ready-made watches are chips: one per group, the first picked, every grou
const page = home.text;
const page = home.text;
assert.ok(page.includes('<div class="pick" id="pick-ready">'), 'the ready-made watches are a pick block');
assert.ok(page.includes('<div class="pick" id="pick-ready">'), 'the ready-made watches are a pick block');
const block = page.slice(page.indexOf('<div class="pick" id="pick-ready">'));
const block = page.slice(page.indexOf('<div class="pick" id="pick-ready">'));
- const chips = [...block.matchAll(/<input type="radio" name="pick-ready" id="pk-ready-([a-z]+)" value="\1"( checked)?><label for="pk-ready-\1">([^<]+)<\/label>/g)];
+ const chips = [...block.matchAll(/<a class="pick-chip" href="#(?:pp-ready-)?([a-z]+)">()([^<]+)<\/a>/g)];
assert.deepStrictEqual(chips.map((m) => m[1]), ['prices', 'feeds', 'blogs'], 'a chip per group');
assert.deepStrictEqual(chips.map((m) => m[1]), ['prices', 'feeds', 'blogs'], 'a chip per group');
- assert.deepStrictEqual(chips.filter((m) => m[2]).map((m) => m[1]), ['prices'], 'the first group is picked');
+ assert.ok(!/type="radio"/.test(block), 'no chip is a radio: nothing is picked, every pane shows');
// Every group stays in the page, with the id its chip picks.
// Every group stays in the page, with the id its chip picks.
const panes = [...block.matchAll(/<div class="pick-pane" id="([a-z]+)">/g)].map((m) => m[1]);
const panes = [...block.matchAll(/<div class="pick-pane" id="([a-z]+)">/g)].map((m) => m[1]);
assert.deepStrictEqual(panes, ['prices', 'feeds', 'blogs'], 'every group is in the page, one per chip');
assert.deepStrictEqual(panes, ['prices', 'feeds', 'blogs'], 'every group is in the page, one per chip');
@@ -46,12 +46,8 @@ t('the ready-made watches are chips: one per group, the first picked, every grou
@@ -46,12 +46,8 @@ t('the ready-made watches are chips: one per group, the first picked, every grou
t('the CSS guard: the chips are hidden and every group shows until 640 px and where :has() is understood', async () => {
t('the CSS guard: the chips are hidden and every group shows until 640 px and where :has() is understood', async () => {
const home = await svc.get('/', { headers: { accept: 'text/html' } });
const home = await svc.get('/', { headers: { accept: 'text/html' } });
const page = home.text;
const page = home.text;
- assert.match(page, /<style>@supports selector\(:has\(\*\)\)\{@media \(max-width:640px\)\{\.pick:has\(#pk-ready-prices:checked\) #prices\{display:block\}/, 'the rule that shows the picked group');
const css = fs.readFileSync(path.join(__dirname, '..', 'public', 'css', 'home.css'), 'utf8');
const css = fs.readFileSync(path.join(__dirname, '..', 'public', 'css', 'home.css'), 'utf8');
assert.match(css, /\.pick-row \{ display: none; \}/, 'the chips are hidden by default');
assert.match(css, /\.pick-row \{ display: none; \}/, 'the chips are hidden by default');
- assert.match(css, /@supports selector\(:has\(\*\)\) \{ @media \(max-width: 640px\) \{/, 'the phone rules are under :has() and 640 px');
- assert.match(css, /\.pick-row label \{[^}]*min-height: 44px/, 'a chip is a 44 px target');
- assert.match(css, /\.pick \.pick-pane \{ display: none; \}/, 'the groups are hidden on a phone');
});
});
t('the questions are a fold, open in the page and closed on a phone', async () => {
t('the questions are a fold, open in the page and closed on a phone', async () => {