openvibers/openvibe.tips Commits

Home: every pane shows on a phone; the chips are links, not a picker (#161)

OP OpenVibers committed 11 days ago · d4348bf910 · 5 files, +19 −39

Changes

ddiff --git a/public/css/tips.css b/public/css/tips.css
iindex 120965e..e762900 100644
---- a/public/css/tips.css
++++ b/public/css/tips.css
@@@ -128,30 +128,22 @@ ul.mod-list, ul.plain { list-style: none; padding: 0; }
.tp-more::after { content: ''; position: absolute; left: 0; right: 0; top: -11px; bottom: -11px; }
}
--/* Pick (the owner's short-pages rule, 2026-10-30): on a phone the front page's five parts are one at a time, picked
-- with a row of chips. Radio inputs and :has(), no script: the chips and the one-part rule live under 640 px and only
-- where :has() is understood, so a wider screen, or an older browser, shows every part and no chips. Every part 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 part opens that part 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 part, so the part's own heading gives way to it. */
-- .pick .pick-pane .tp-head h2, .pick .pick-pane .sc-sec > h2 { display: none; }
-- .pick .pick-pane .tp-head { justify-content: flex-end; }
--} }
++ .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
replaces: a heading and its content, with no card around it. */
ddiff --git a/server/render/short.js b/server/render/short.js
iindex 89c630c..2fbfb99 100644
---- a/server/render/short.js
++++ b/server/render/short.js
@@@ -24,22 +24,14 @@ function pickBlock({ key, label, head = '', panes }) {
// 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('');
-- return `<div class="pick" id="pick-${esc(key)}"><div class="pick-bar"><div class="pick-head"><h2>${esc(head || label)}</h2></div><div class="pick-row" role="radiogroup" aria-label="${esc(label)}">${chips}</div></div><div class="pick-body">${body}</div></div>`;
++ return `<div class="pick" id="pick-${esc(key)}"><div class="pick-bar"><div class="pick-head"><h2>${esc(head || label)}</h2></div><nav class="pick-row" aria-label="${esc(label)}">${chips}</nav></div><div class="pick-body">${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.
@@@ -55,4 +47,4 @@ function foldScript(id) {
return `<script>(function(){var d=document.getElementById(${JSON.stringify(id)});if(!d)return;var k='ov_fold_'+${JSON.stringify(id)};var s=null;try{s=localStorage.getItem(k)}catch(e){}if(s==='open'){d.open=true;return}if(s==='closed'){d.open=false;return}var t=0;if(window.matchMedia&&window.matchMedia('(max-width:640px)').matches){t=Date.now();d.open=false}d.addEventListener('toggle',function(){if(Date.now()-t<300)return;try{localStorage.setItem(k,d.open?'open':'closed')}catch(e){}})})();</script>`;
}
--module.exports = { pickBlock, pickRule, pickRules, foldBlock, foldScript };
++module.exports = { pickBlock, foldBlock, foldScript };
ddiff --git a/server/web/pages.js b/server/web/pages.js
iindex 2b27edc..9b3d8be 100644
---- a/server/web/pages.js
++++ b/server/web/pages.js
@@@ -9,7 +9,7 @@ const showcase = require('openvibe-shared/showcase');
const { esc } = require('./layout');
const { VOICES } = require('../domain/profiles');
const supportLinks = require('../domain/support-links');
--const { pickBlock, pickRules, foldBlock } = require('../render/short');
++const { pickBlock, foldBlock } = require('../render/short');
const n = (v) => Number(v || 0).toLocaleString('en-US');
const when = (s) => (s ? esc(String(s).replace('T', ' ').slice(0, 16)) + ' UTC' : '');
ddiff --git a/server/web/routes.js b/server/web/routes.js
iindex 9c37ac0..c7046ea 100644
---- a/server/web/routes.js
++++ b/server/web/routes.js
@@@ -99,7 +99,7 @@ function createWebRoutes({ domain, config, layout, userAuth, liveNow = { list: a
// Who is live comes from Live once a minute, so the page may be cached as long.
html(res, pageFor(req, { active: 'home', canonicalPath: '/', title: 'Tips, paid messages and stream alerts', description: HOME_DESCRIPTION, styles: [require('openvibe-shared/showcase').STYLESHEET], wide: true, body: pages.home({ creators, live }),
// The rule that shows the picked part of the home's pick block: one per part, written for this page.
-- inlineStyles: [`@supports selector(:has(*)){@media (max-width:640px){${require('../render/short').pickRules('parts', pages.HOME_PANE_IDS)}}}`], jsonLd }));
++ jsonLd }));
});
// What shipped on OpenVibe.Tips: the shared update log every OpenVibe site has.
r.get('/updates', withViewer, (req, res) => html(res, pageFor(req, { canonicalPath: '/updates', title: 'What shipped on OpenVibe.Tips', body: frame.updatesBody({ service: 'tips', siteName: 'OpenVibe.Tips' }) + `<script src="${ovServe.url('shipped.js')}" defer></script>` })));
ddiff --git a/test/home-short.test.js b/test/home-short.test.js
iindex 6f9665c..eb1d95d 100644
---- a/test/home-short.test.js
++++ b/test/home-short.test.js
@@@ -18,10 +18,10 @@ const { boot, check, done } = require('./helpers/app');
const page = r.text;
const block = page.slice(page.indexOf('<div class="pick" id="pick-parts">'), page.indexOf('<div class="pick" id="pick-parts">') + 60000);
assert.ok(block.startsWith('<div class="pick" id="pick-parts">'), 'the pick block is on the home');
-- assert.match(block, /<div class="pick-row" role="radiogroup" aria-label="What Tips does">/);
-- const chips = [...block.matchAll(/<input type="radio" name="pick-parts" id="pk-parts-([a-z-]+)" value="\1"( checked)?><label for="pk-parts-\1">([^<]+)<\/label>/g)];
++ assert.match(block, /<nav class="pick-row" aria-label="What Tips does">/);
++ const chips = [...block.matchAll(/<a class="pick-chip" href="#(?:pp-parts-)?([a-z-]+)">()([^<]+)<\/a>/g)];
assert.ok(chips.length >= 5, `a chip per part (${chips.length})`);
-- assert.deepStrictEqual(chips.filter((m) => m[2]).map((m) => m[1]), [chips[0][1]], 'the first part is picked');
++ assert.ok(!/type="radio"/.test(block), 'no chip is a radio: nothing is picked, every pane shows');
// Every part 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, chips.map((m) => m[1]), 'every part is in the page, one per chip');
@@@ -34,12 +34,8 @@ const { boot, check, done } = require('./helpers/app');
await check('the CSS guard: the chips are hidden and the parts all show until 640 px and where :has() is understood', async () => {
const r = await t.call('GET', '/', { token: null });
const page = r.text;
-- assert.match(page, /<style>@supports selector\(:has\(\*\)\)\{@media \(max-width:640px\)\{\.pick:has\(#pk-parts-send:checked\) #send\{display:block\}/, 'the rule that shows the picked part');
const css = fs.readFileSync(path.join(__dirname, '..', 'public', 'css', 'tips.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 parts are hidden on a phone');
});
await check('the parts a reader rarely needs are folds, open in the page and closed on a phone', async () => {