1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-07-21 18:55:36 +02:00

refactor(ui): replace entry table with flexbox layout

This commit is contained in:
TheGeneralist 2026-06-23 22:45:37 +02:00
parent 623d2a12cc
commit b895d6331c
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
3 changed files with 102 additions and 72 deletions

View file

@ -82,7 +82,7 @@ async function getJson(url) {
} }
function appendCell(row, text, className) { function appendCell(row, text, className) {
const cell = document.createElement("td"); const cell = document.createElement("div");
if (className) cell.className = className; if (className) cell.className = className;
cell.textContent = text; cell.textContent = text;
row.append(cell); row.append(cell);
@ -133,30 +133,30 @@ function renderEntries() {
} }
for (const entry of state.entries) { for (const entry of state.entries) {
const row = document.createElement("tr"); const row = document.createElement("div");
row.tabIndex = 0; row.tabIndex = 0;
row.dataset.entryUid = entry.entry_uid; row.dataset.entryUid = entry.entry_uid;
if (entry.entry_uid === state.selectedEntryUid) { if (entry.entry_uid === state.selectedEntryUid) {
row.classList.add("is-selected"); row.classList.add("is-selected");
} }
appendCell(row, formatTimestamp(entry.archived_at)); appendCell(row, formatTimestamp(entry.archived_at), "col-added");
const titleCell = appendCell(row, ""); const titleCell = appendCell(row, "", "col-title");
titleCell.append(sourceIcon(entry.source_kind)); titleCell.append(sourceIcon(entry.source_kind));
const title = document.createElement("span"); const title = document.createElement("span");
title.className = "entry-title"; title.className = "entry-title";
title.textContent = valueText(entry.title) || valueText(entry.entry_uid); title.textContent = valueText(entry.title) || valueText(entry.entry_uid);
titleCell.append(title); titleCell.append(title);
const typeCell = appendCell(row, ""); const typeCell = appendCell(row, "", "col-type");
const type = document.createElement("span"); const type = document.createElement("span");
type.className = "type-pill"; type.className = "type-pill";
type.textContent = valueText(entry.entity_kind); type.textContent = valueText(entry.entity_kind);
typeCell.append(type); typeCell.append(type);
appendCell(row, formatBytes(entry.total_artifact_bytes)); appendCell(row, formatBytes(entry.total_artifact_bytes), "col-size");
appendCell(row, valueText(entry.original_url), "url-cell"); appendCell(row, valueText(entry.original_url), "url-cell col-url");
row.addEventListener("click", () => selectEntry(entry)); row.addEventListener("click", () => selectEntry(entry));
row.addEventListener("keydown", (event) => { row.addEventListener("keydown", (event) => {
@ -308,11 +308,11 @@ async function loadRuns() {
runsBody.innerHTML = ""; runsBody.innerHTML = "";
for (const run of runs) { for (const run of runs) {
const row = document.createElement("tr"); const row = document.createElement("tr");
appendCell(row, valueText(run.started_at)); for (const val of [run.started_at, run.status, run.requested_count, run.completed_count, run.failed_count]) {
appendCell(row, valueText(run.status)); const td = document.createElement("td");
appendCell(row, String(run.requested_count)); td.textContent = valueText(String(val ?? ""));
appendCell(row, String(run.completed_count)); row.append(td);
appendCell(row, String(run.failed_count)); }
runsBody.append(row); runsBody.append(row);
} }
} }

View file

@ -27,25 +27,16 @@
</div> </div>
<section id="archive-view" class="view is-active"> <section id="archive-view" class="view is-active">
<table class="entry-table"> <div class="entry-table">
<colgroup> <div class="entry-header-row">
<col class="col-added"> <div class="col-added">Added</div>
<col class="col-title"> <div class="col-title">Title</div>
<col class="col-type"> <div class="col-type">Type</div>
<col class="col-size"> <div class="col-size">Size</div>
<col class="col-url"> <div class="col-url">Original URL</div>
</colgroup> </div>
<thead> <div id="entries-body"></div>
<tr> </div>
<th>Added</th>
<th>Title</th>
<th>Type</th>
<th>Size</th>
<th>Original URL</th>
</tr>
</thead>
<tbody id="entries-body"></tbody>
</table>
</section> </section>
<section id="runs-view" class="view"> <section id="runs-view" class="view">

View file

@ -136,12 +136,86 @@ select {
.entry-table { .entry-table {
width: 100%; width: 100%;
border-collapse: collapse;
table-layout: fixed;
font-size: 13px; font-size: 13px;
overflow: auto;
} }
.entry-table th { .entry-header-row {
display: flex;
align-items: stretch;
position: sticky;
top: 0;
z-index: 1;
background: #ded5c7;
border-bottom: 1px solid #cec4b5;
color: #5d625e;
font-size: 11px;
text-transform: uppercase;
}
.entry-header-row > div {
padding: 10px;
flex-shrink: 0;
}
#entries-body > div {
display: flex;
align-items: baseline;
cursor: default;
border-bottom: 1px solid var(--line-soft);
}
#entries-body > div > div {
padding: 10px;
flex-shrink: 0;
overflow: hidden;
}
#entries-body > div:nth-child(even) {
background: #f2ede5;
}
#entries-body > div:nth-child(odd) {
background: var(--paper-3);
}
#entries-body > div.is-selected {
background: #eee2d2;
outline: 2px solid var(--accent);
outline-offset: -2px;
}
.col-added {
width: 168px;
}
.col-title {
flex: 1 1 0;
min-width: 0;
overflow: hidden;
}
.col-type {
width: 120px;
}
.col-size {
width: 100px;
}
.col-url {
flex: 0 0 30%;
min-width: 0;
overflow: hidden;
}
/* Runs table (still a <table>) */
#runs-view .entry-table {
border-collapse: collapse;
table-layout: auto;
}
#runs-view .entry-table th {
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 1; z-index: 1;
@ -154,49 +228,14 @@ select {
text-transform: uppercase; text-transform: uppercase;
} }
.entry-table td { #runs-view .entry-table td {
padding: 10px; padding: 10px;
border-bottom: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
vertical-align: top; vertical-align: top;
} }
.entry-table tr:nth-child(even) td { #runs-view .entry-table tr:nth-child(even) td { background: #f2ede5; }
background: #f2ede5; #runs-view .entry-table tr:nth-child(odd) td { background: var(--paper-3); }
}
.entry-table tr:nth-child(odd) td {
background: var(--paper-3);
}
.entry-table tr {
cursor: default;
}
.entry-table tr.is-selected td {
background: #eee2d2;
border-top: 2px solid var(--accent);
border-bottom: 2px solid var(--accent);
}
.col-added {
width: 178px;
}
.col-title {
width: 38%;
}
.col-type {
width: 130px;
}
.col-size {
width: 110px;
}
.col-url {
width: 34%;
}
.entry-title { .entry-title {
color: var(--link); color: var(--link);