openvibers/openvibe.markets Commits

The search box keeps its examples; no empty picture squares (#1)

OP OpenVibers committed 13 days ago · 777c5c9feb · 3 files, +14 −2

Checked on openvibe.markets at 390 px. Shared's trending script filled the empty search box with the page's
own headings ("Where it looks"): the box now says data-ov-trending="own" and keeps its examples. Deals' feed
has no picture for most offers: such a card takes the whole width instead of an empty square. "Can I afford
it?" is a 44 px target on a phone.

Changes

ddiff --git a/public/markets.css b/public/markets.css
iindex 20a02af..abaf5c5 100644
---- a/public/markets.css
++++ b/public/markets.css
@@@ -47,3 +47,11 @@ html[data-ov-motion="off"] .mk-elsewhere a, html[data-ov-motion="off"] .mk-btn {
.mk-card-img { width: 56px; height: 56px; }
.mk-card-price { grid-column: 2; justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; align-items: baseline; gap: 8px; }
}
++/* A card without a picture: the words and the price only (Deals' feed often has none). */
++.mk-card--text { grid-template-columns: minmax(0, 1fr) auto; }
++.mk-afford { display: inline-flex; align-items: center; min-height: 32px; }
++@media (max-width: 520px) {
++ .mk-card--text { grid-template-columns: minmax(0, 1fr); }
++ .mk-card--text .mk-card-price { grid-column: 1; }
++ .mk-afford { min-height: 44px; padding: 0 2px; }
++}
ddiff --git a/server/views.js b/server/views.js
iindex a0cfc1d..7bc9643 100644
---- a/server/views.js
++++ b/server/views.js
@@@ -34,7 +34,7 @@ function page({ title, body, path = '/', description = 'Every marketplace, one s
}
const searchForm = (q = '') => `<form class="mk-search" method="get" action="/search" role="search">
--<label class="mk-search-box"><span class="mk-sr">What are you looking for?</span><input type="search" name="q" value="${esc(q)}" placeholder="Headphones, a sofa, a used road bike…" maxlength="100" autocomplete="off" required></label>
++<label class="mk-search-box"><span class="mk-sr">What are you looking for?</span><input type="search" name="q" value="${esc(q)}" placeholder="Headphones, a sofa, a used road bike…" maxlength="100" autocomplete="off" required data-ov-trending="own"></label>
<button class="mk-btn mk-btn--primary" type="submit">Search</button></form>`;
function home() {
@@@ -52,7 +52,8 @@ ${searchForm()}</section>
}
function results({ q, deals, links, now = Date.now() }) {
-- const card = (r) => `<li class="mk-card">${r.image ? `<img class="mk-card-img" src="${esc(r.image)}" alt="" loading="lazy" width="72" height="72">` : '<span class="mk-card-img mk-card-img--none" aria-hidden="true"></span>'}
++ // A deal without a picture takes the whole width: no empty square.
++ const card = (r) => `<li class="mk-card${r.image ? '' : ' mk-card--text'}">${r.image ? `<img class="mk-card-img" src="${esc(r.image)}" alt="" loading="lazy" width="72" height="72">` : ''}
<span class="mk-card-body"><a class="mk-card-title" href="${esc(r.url)}">${esc(r.title)}</a>
<small>${esc(r.store || 'A store')} · ${esc(r.source)}${r.condition && r.condition !== 'new' ? ` · ${esc(r.condition)}` : ''}</small></span>
<span class="mk-card-price">${r.price != null ? `<b>${esc(money(r.price, r.currency || 'USD'))}</b>${r.was != null && r.was > r.price ? `<s>${esc(money(r.was, r.currency || 'USD'))}</s>` : ''}<small>${esc(asOf(r.observed_at, now))}</small>
ddiff --git a/test/app.test.js b/test/app.test.js
iindex 810ad0a..9db91af 100644
---- a/test/app.test.js
++++ b/test/app.test.js
@@@ -51,6 +51,7 @@ const OFFERS = [
assert.match(r.text, /Every marketplace, one search/);
assert.match(r.text, /<form class="mk-search" method="get" action="\/search"/);
assert.match(r.text, /Facebook Marketplace/);
++ assert.match(r.text, /data-ov-trending="own"/, 'a product search keeps its own examples, never the page\'s headings');
assert.match(r.headers.get('cache-control'), /public/);
r = await get('/search?q=headphones');
@@@ -60,6 +61,8 @@ const OFFERS = [
assert.match(r.text, /\$149\.99<\/b><s>\$199\.99<\/s><small>as of 3 hours ago<\/small>/, 'a price with its time and the price before');
assert.match(r.text, /as of Nov 10, 2026/);
assert.match(r.text, /price not stated/);
++ assert.match(r.text, /<li class="mk-card mk-card--text">/, 'a deal without a picture has no empty square');
++ assert.match(r.text, /<img class="mk-card-img" src="https:\/\/img\.example\/nc\.jpg"/);
assert.match(r.text, /Shop Example · OpenVibe Deals/);
assert.match(r.text, /Refurb Co · OpenVibe Deals · refurbished/);
assert.match(r.text, /href="https:\/\/openvibe\.finance\/ahead\?cost=149\.99">Can I afford it\?/);