Improve Persistent Queue History Filters Popover UI
This commit is contained in:
+13
-4
@@ -109,10 +109,19 @@
|
||||
.pqueue-thumb-row{display:flex;flex-wrap:wrap;gap:.5rem}
|
||||
.pqueue-thumb-wrap{position:relative;width:100px;height:100px;border-radius:8px;overflow:hidden;background:rgba(24,24,27,.6);border:1px solid rgba(82,82,91,.24);cursor:pointer}
|
||||
.pqueue-history-sentinel{display:flex;align-items:center;justify-content:center;min-height:48px;opacity:.7}
|
||||
.pqueue-popover{position:fixed;min-width:280px;max-width:420px;max-height:80vh;overflow:auto;padding:.85rem;background:#1a1a1a;border:1px solid rgba(82,82,91,.28);border-radius:12px;box-shadow:0 18px 40px rgba(0,0,0,.45);z-index:100000}
|
||||
.pqueue-popover__section{display:flex;gap:.5rem;flex-wrap:wrap;margin-bottom:.6rem}
|
||||
.pqueue-popover__grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.5rem}
|
||||
.pqueue-popover .pqueue-input{width:100%}
|
||||
.pqueue-popover{position:fixed;min-width:320px;max-width:420px;max-height:80vh;overflow-y:auto;overflow-x:hidden;padding:0;background:#1a1a1a;border:1px solid rgba(82,82,91,.22);border-radius:12px;box-shadow:0 18px 40px rgba(0,0,0,.45);z-index:100000}
|
||||
.pqueue-popover__arrow{position:absolute;top:-8px;left:24px;width:16px;height:16px;background:#1a1a1a;border-left:1px solid rgba(82,82,91,.22);border-top:1px solid rgba(82,82,91,.22);transform:rotate(45deg);border-top-left-radius:3px}
|
||||
.pqueue-popover__header{position:sticky;top:0;display:flex;align-items:center;gap:.5rem;justify-content:space-between;padding:.7rem .85rem;border-bottom:1px solid rgba(82,82,91,.22);background:#1a1a1a;backdrop-filter:blur(6px);border-top-left-radius:12px;border-top-right-radius:12px}
|
||||
.pqueue-popover__title{font-weight:600;color:var(--heading-text,#f9fafb)}
|
||||
.pqueue-popover__hint{font-size:.72rem;color:var(--subtle-text,#9ca3af)}
|
||||
.pqueue-popover__section{display:flex;gap:.5rem;flex-wrap:wrap;margin:.7rem .85rem}
|
||||
.pqueue-popover__grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.6rem;margin:.25rem .85rem}
|
||||
.pqueue-popover .pqueue-input{width:100%;min-width:0;max-width:100%}
|
||||
.pqueue-popover__footer{position:sticky;bottom:0;display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.6rem .85rem;border-top:1px solid rgba(82,82,91,.22);background:#1a1a1a;backdrop-filter:blur(6px);border-bottom-left-radius:12px;border-bottom-right-radius:12px}
|
||||
.pqueue-popover__footer-right{display:flex;gap:.35rem;align-items:center}
|
||||
.pqueue-popover__presets{padding:.5rem;border:1px solid rgba(82,82,91,.22);border-radius:12px;background:rgba(24,24,27,.55)}
|
||||
.pqueue-field{display:flex;flex-direction:column;gap:.25rem}
|
||||
.pqueue-field__label{font-size:.72rem;color:var(--subtle-text,#9ca3af)}
|
||||
@media(max-width:520px){.pqueue-popover{max-width:92vw}.pqueue-popover__grid{grid-template-columns:1fr}}
|
||||
.pqueue-thumb{width:100%;height:100%;object-fit:cover;display:block}
|
||||
.pqueue-thumb-badge{position:absolute;right:6px;bottom:6px;padding:.15rem .5rem;border-radius:.6rem;background:rgba(15,23,42,.75);color:#fff;font-size:.68rem}
|
||||
|
||||
+73
-15
@@ -967,37 +967,95 @@
|
||||
},
|
||||
|
||||
buildFiltersPopover(anchor) {
|
||||
const since = UI.el("input", { type: "date", class: "pqueue-input", value: state.filters?.historySince || "" });
|
||||
const sinceTime = UI.el("input", { type: "time", class: "pqueue-input", value: state.filters?.historySinceTime || "" });
|
||||
const until = UI.el("input", { type: "date", class: "pqueue-input", value: state.filters?.historyUntil || "" });
|
||||
const untilTime = UI.el("input", { type: "time", class: "pqueue-input", value: state.filters?.historyUntilTime || "" });
|
||||
const since = UI.el("input", { type: "date", class: "pqueue-input", value: state.filters?.historySince || "", id: "pqueue-since-date" });
|
||||
const sinceTime = UI.el("input", { type: "time", class: "pqueue-input", value: state.filters?.historySinceTime || "", id: "pqueue-since-time", step: "1" });
|
||||
const until = UI.el("input", { type: "date", class: "pqueue-input", value: state.filters?.historyUntil || "", id: "pqueue-until-date" });
|
||||
const untilTime = UI.el("input", { type: "time", class: "pqueue-input", value: state.filters?.historyUntilTime || "", id: "pqueue-until-time", step: "1" });
|
||||
const onChange = () => Events.updateHistoryDateFilters(since.value, until.value, sinceTime.value, untilTime.value);
|
||||
since.addEventListener("change", onChange);
|
||||
sinceTime.addEventListener("change", onChange);
|
||||
until.addEventListener("change", onChange);
|
||||
untilTime.addEventListener("change", onChange);
|
||||
[since, sinceTime, until, untilTime].forEach((el) => el.addEventListener("change", onChange));
|
||||
|
||||
const presets = UI.el("div", { class: "pqueue-popover__section" }, [
|
||||
// store DOM refs so presets can reflect UI immediately
|
||||
state.dom.historySince = since;
|
||||
state.dom.historySinceTime = sinceTime;
|
||||
state.dom.historyUntil = until;
|
||||
state.dom.historyUntilTime = untilTime;
|
||||
|
||||
const dates = UI.el("div", { class: "pqueue-popover__grid" }, [
|
||||
UI.el("label", { class: "pqueue-field" }, [UI.el("span", { class: "pqueue-field__label", text: "Since date" }), since]),
|
||||
UI.el("label", { class: "pqueue-field" }, [UI.el("span", { class: "pqueue-field__label", text: "Since time" }), sinceTime]),
|
||||
UI.el("label", { class: "pqueue-field" }, [UI.el("span", { class: "pqueue-field__label", text: "Until date" }), until]),
|
||||
UI.el("label", { class: "pqueue-field" }, [UI.el("span", { class: "pqueue-field__label", text: "Until time" }), untilTime]),
|
||||
]);
|
||||
|
||||
const presets = UI.el("div", { class: "pqueue-popover__section pqueue-popover__presets" }, [
|
||||
UI.button({ text: "Today", variant: "ghost", subtle: true, size: "sm", onClick: () => Events.applyHistoryPreset("today") }),
|
||||
UI.button({ text: "Last 24h", variant: "ghost", subtle: true, size: "sm", onClick: () => Events.applyHistoryPreset("24h") }),
|
||||
UI.button({ text: "Last 7d", variant: "ghost", subtle: true, size: "sm", onClick: () => Events.applyHistoryPreset("7d") }),
|
||||
UI.button({ text: "Clear", variant: "ghost", subtle: true, size: "sm", onClick: () => Events.applyHistoryPreset("clear") }),
|
||||
]);
|
||||
|
||||
const dates = UI.el("div", { class: "pqueue-popover__grid" }, [since, sinceTime, until, untilTime]);
|
||||
const header = UI.el('div', { class: 'pqueue-popover__header' }, [
|
||||
UI.el('div', { class: 'pqueue-popover__title', text: 'History filters' }),
|
||||
UI.el('div', { class: 'pqueue-popover__hint', text: 'Local timezone applied' }),
|
||||
UI.button({ icon: 'ti ti-x', variant: 'ghost', subtle: true, title: 'Close', onClick: () => { pop?.remove(); state.dom.filtersPopover = null; } })
|
||||
]);
|
||||
|
||||
const pop = UI.el('div', { class: 'pqueue-popover' }, [
|
||||
const footer = UI.el('div', { class: 'pqueue-popover__footer' }, [
|
||||
UI.el('div', { class: 'pqueue-popover__footer-left' }, [UI.el('span', { class: 'pqueue-muted', text: UI.currentHistoryRangeLabel() })]),
|
||||
UI.el('div', { class: 'pqueue-popover__footer-right' }, [
|
||||
UI.button({ text: 'Clear', variant: 'ghost', subtle: true, size: 'sm', onClick: () => Events.applyHistoryPreset('clear') }),
|
||||
UI.button({ text: 'Done', variant: 'secondary', size: 'sm', onClick: () => { pop?.remove(); state.dom.filtersPopover = null; } })
|
||||
])
|
||||
]);
|
||||
|
||||
const pop = UI.el('div', { class: 'pqueue-popover', role: 'dialog', 'aria-label': 'History filters' }, [
|
||||
UI.el('div', { class: 'pqueue-popover__arrow' }),
|
||||
header,
|
||||
UI.el('div', { class: 'pqueue-popover__section' }, [UI.el('strong', { text: 'Date range' })]),
|
||||
dates,
|
||||
UI.el('div', { class: 'pqueue-popover__section' }, [UI.el('strong', { text: 'Presets' })]),
|
||||
presets
|
||||
presets,
|
||||
footer
|
||||
]);
|
||||
// Position near anchor
|
||||
|
||||
// keyboard handling: Esc closes; Tab traps within
|
||||
const keyHandler = (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
pop.remove();
|
||||
state.dom.filtersPopover = null;
|
||||
} else if (e.key === 'Tab') {
|
||||
const focusables = pop.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
||||
const list = Array.from(focusables).filter((n) => !n.hasAttribute('disabled'));
|
||||
if (!list.length) return;
|
||||
const first = list[0];
|
||||
const last = list[list.length - 1];
|
||||
if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
|
||||
else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
|
||||
}
|
||||
};
|
||||
pop.addEventListener('keydown', keyHandler);
|
||||
|
||||
// Position near anchor and align arrow
|
||||
try {
|
||||
const rect = anchor.getBoundingClientRect();
|
||||
pop.style.top = `${rect.bottom + 8 + window.scrollY}px`;
|
||||
pop.style.left = `${Math.min(rect.left + window.scrollX, window.innerWidth - 360)}px`;
|
||||
const maxLeft = window.innerWidth - 360;
|
||||
const left = Math.min(rect.left + window.scrollX, maxLeft);
|
||||
const top = rect.bottom + 8 + window.scrollY;
|
||||
pop.style.top = `${top}px`;
|
||||
pop.style.left = `${left}px`;
|
||||
const arrow = pop.querySelector('.pqueue-popover__arrow');
|
||||
if (arrow) {
|
||||
const anchorCenter = rect.left + rect.width / 2 + window.scrollX;
|
||||
const popLeft = left;
|
||||
const offset = Math.max(14, Math.min((anchorCenter - popLeft), 346));
|
||||
arrow.style.left = `${offset}px`;
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
// focus first input
|
||||
window.setTimeout(() => since.focus(), 0);
|
||||
|
||||
return pop;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user