mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-03-25 09:25:51 +00:00
UX Improvements
This commit is contained in:
parent
947491b21c
commit
5ef30bb652
1 changed files with 10 additions and 9 deletions
|
|
@ -579,35 +579,36 @@ export async function renderStore($app, storeLabelRaw) {
|
|||
|
||||
function exclusiveAnnotHtml(it) {
|
||||
const mode = String($exSort.value || "priceDesc");
|
||||
|
||||
|
||||
// If sorting by sale, annotate with sale change ($ / %). If unchanged, show nothing.
|
||||
if (mode === "salePct") {
|
||||
const p = Number.isFinite(it._salePct) ? it._salePct : 0;
|
||||
if (!p) return "";
|
||||
const abs = Math.abs(p);
|
||||
if (p < 0) return `<span class="badge badgeGood">${esc(abs)}% off</span>`;
|
||||
return `<span class="badge badgeBad">+${esc(abs)}%</span>`;
|
||||
if (p < 0) return `<span class="badge badgeGood">[${esc(abs)}% Off]</span>`;
|
||||
return `<span class="badge badgeBad">[+${esc(abs)}%]</span>`;
|
||||
}
|
||||
|
||||
|
||||
if (mode === "saleAbs") {
|
||||
const d = Number.isFinite(it._saleDelta) ? it._saleDelta : 0;
|
||||
if (!d) return "";
|
||||
const abs = Math.round(Math.abs(d));
|
||||
if (!abs) return "";
|
||||
if (d < 0) return `<span class="badge badgeGood">$${esc(abs)} off</span>`;
|
||||
return `<span class="badge badgeBad">+$${esc(abs)}</span>`;
|
||||
if (d < 0) return `<span class="badge badgeGood">[-$${esc(abs)}]</span>`;
|
||||
return `<span class="badge badgeBad">[+$${esc(abs)}]</span>`;
|
||||
}
|
||||
|
||||
|
||||
// Otherwise: show % off vs best other store (only when actually cheaper).
|
||||
const sp = it && Number.isFinite(it._storePrice) ? it._storePrice : null;
|
||||
const other = it && Number.isFinite(it._bestOther) ? it._bestOther : null;
|
||||
if (sp === null || other === null || !(other > 0)) return "";
|
||||
if (!(sp < other - EPS)) return "";
|
||||
|
||||
|
||||
const pct = Math.round(((other - sp) / other) * 100);
|
||||
if (!Number.isFinite(pct) || pct <= 0) return "";
|
||||
return `<span class="badge badgeGood">${esc(pct)}% off</span>`;
|
||||
return `<span class="badge badgeGood">[${esc(pct)}% Off]</span>`;
|
||||
}
|
||||
|
||||
|
||||
function renderCard(it) {
|
||||
const price = listingPriceStr(it);
|
||||
|
|
|
|||
Loading…
Reference in a new issue