mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-04-27 15:07:43 +00:00
feat: V4 store page
This commit is contained in:
parent
13f15a8eb0
commit
50e0556452
4 changed files with 21 additions and 10 deletions
|
|
@ -231,9 +231,11 @@ export async function renderItem($app, skuInput) {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
document.getElementById("back").addEventListener("click", () => {
|
document.getElementById("back").addEventListener("click", () => {
|
||||||
location.hash = "#/";
|
const last = sessionStorage.getItem("viz:lastRoute");
|
||||||
|
if (last && last !== location.hash) location.hash = last;
|
||||||
|
else location.hash = "#/";
|
||||||
});
|
});
|
||||||
|
|
||||||
const $title = document.getElementById("title");
|
const $title = document.getElementById("title");
|
||||||
const $links = document.getElementById("links");
|
const $links = document.getElementById("links");
|
||||||
const $status = document.getElementById("status");
|
const $status = document.getElementById("status");
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ export function renderSearch($app) {
|
||||||
<div class="itemName">${esc(it.name || "(no name)")}</div>
|
<div class="itemName">${esc(it.name || "(no name)")}</div>
|
||||||
<a class="badge mono skuLink" href="${esc(
|
<a class="badge mono skuLink" href="${esc(
|
||||||
skuLink
|
skuLink
|
||||||
)}" onclick="event.stopPropagation()">${esc(displaySku(it.sku))}</a>
|
)}" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()">${esc(displaySku(it.sku))}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="metaRow">
|
<div class="metaRow">
|
||||||
<span class="mono price">${esc(price)}</span>
|
<span class="mono price">${esc(price)}</span>
|
||||||
|
|
@ -149,6 +149,7 @@ export function renderSearch($app) {
|
||||||
const sku = el.getAttribute("data-sku") || "";
|
const sku = el.getAttribute("data-sku") || "";
|
||||||
if (!sku) return;
|
if (!sku) return;
|
||||||
saveQuery($q.value);
|
saveQuery($q.value);
|
||||||
|
sessionStorage.setItem("viz:lastRoute", location.hash);
|
||||||
location.hash = `#/item/${encodeURIComponent(sku)}`;
|
location.hash = `#/item/${encodeURIComponent(sku)}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -419,7 +420,7 @@ export function renderSearch($app) {
|
||||||
<div class="itemName">${esc(r.name || "(no name)")}</div>
|
<div class="itemName">${esc(r.name || "(no name)")}</div>
|
||||||
<a class="badge mono skuLink" href="${esc(
|
<a class="badge mono skuLink" href="${esc(
|
||||||
skuLink
|
skuLink
|
||||||
)}" onclick="event.stopPropagation()">${esc(displaySku(sku))}</a>
|
)}" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()">${esc(displaySku(sku))}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="metaRow">
|
<div class="metaRow">
|
||||||
<span class="badge"${kindBadgeStyle}>${esc(kindLabel)}</span>
|
<span class="badge"${kindBadgeStyle}>${esc(kindLabel)}</span>
|
||||||
|
|
@ -440,6 +441,7 @@ export function renderSearch($app) {
|
||||||
const sku = el.getAttribute("data-sku") || "";
|
const sku = el.getAttribute("data-sku") || "";
|
||||||
if (!sku) return;
|
if (!sku) return;
|
||||||
saveQuery($q.value);
|
saveQuery($q.value);
|
||||||
|
sessionStorage.setItem("viz:lastRoute", location.hash);
|
||||||
location.hash = `#/item/${encodeURIComponent(sku)}`;
|
location.hash = `#/item/${encodeURIComponent(sku)}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,10 @@ export async function renderStore($app, storeLabelRaw) {
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
document.getElementById("back").addEventListener("click", () => (location.hash = "#/"));
|
document.getElementById("back").addEventListener("click", () => {
|
||||||
|
sessionStorage.setItem("viz:lastRoute", location.hash);
|
||||||
|
location.hash = "#/"
|
||||||
|
});
|
||||||
|
|
||||||
const $q = document.getElementById("q");
|
const $q = document.getElementById("q");
|
||||||
const $status = document.getElementById("status");
|
const $status = document.getElementById("status");
|
||||||
|
|
@ -230,7 +233,7 @@ export async function renderStore($app, storeLabelRaw) {
|
||||||
<div class="itemBody">
|
<div class="itemBody">
|
||||||
<div class="itemTop">
|
<div class="itemTop">
|
||||||
<div class="itemName">${esc(it.name || "(no name)")}</div>
|
<div class="itemName">${esc(it.name || "(no name)")}</div>
|
||||||
<a class="badge mono skuLink" href="${esc(skuLink)}" onclick="event.stopPropagation()">${esc(
|
<a class="badge mono skuLink" target="_blank" rel="noopener noreferrer" href="${esc(skuLink)}" onclick="event.stopPropagation()">${esc(
|
||||||
displaySku(it.sku)
|
displaySku(it.sku)
|
||||||
)}</a>
|
)}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -294,6 +297,7 @@ export async function renderStore($app, storeLabelRaw) {
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
const sku = el.getAttribute("data-sku") || "";
|
const sku = el.getAttribute("data-sku") || "";
|
||||||
if (!sku) return;
|
if (!sku) return;
|
||||||
|
sessionStorage.setItem("viz:lastRoute", location.hash);
|
||||||
location.hash = `#/item/${encodeURIComponent(sku)}`;
|
location.hash = `#/item/${encodeURIComponent(sku)}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,12 +245,15 @@ a.skuLink:hover { text-decoration: underline; cursor: pointer; }
|
||||||
margin-top: 12px; /* slightly more gap from the top text */
|
margin-top: 12px; /* slightly more gap from the top text */
|
||||||
}
|
}
|
||||||
|
|
||||||
.storeBar {
|
.storeBar{
|
||||||
display: flex;
|
display:flex;
|
||||||
gap: 8px;
|
gap:8px;
|
||||||
flex-wrap: wrap;
|
flex-wrap:wrap;
|
||||||
|
width:100%;
|
||||||
|
justify-content: space-between; /* spread each row to fill */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.storeBtn {
|
.storeBtn {
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
background: #0f1318;
|
background: #0f1318;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue