fix(admin-web): measure which table columns fit instead of guessing breakpoints
Long translations (German row actions) overflowed fixed container breakpoints; tables now drop secondary columns level by level until their rows fit the panel. Charts set direction in CSS, which SVG honours. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
6 files changed
+51
-35
No files matched your search
@@ -120,8 +120,8 @@ input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); margi
|
|||||||
.segmented .btn:last-child { border-start-end-radius: var(--radius); border-end-end-radius: var(--radius); }
|
.segmented .btn:last-child { border-start-end-radius: var(--radius); border-end-end-radius: var(--radius); }
|
||||||
.segmented .btn[aria-pressed="true"] { position: relative; }
|
.segmented .btn[aria-pressed="true"] { position: relative; }
|
||||||
|
|
||||||
/* Panels and tiles. Panels are size containers: tables inside drop secondary columns when the panel is narrow. */
|
/* Panels and tiles */
|
||||||
.panel { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-card); padding: 16px 18px; display: grid; gap: 10px; align-content: start; min-width: 0; container-type: inline-size; }
|
.panel { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius-card); padding: 16px 18px; display: grid; gap: 10px; align-content: start; min-width: 0; }
|
||||||
.panel.flush { padding: 0; gap: 0; overflow-x: auto; }
|
.panel.flush { padding: 0; gap: 0; overflow-x: auto; }
|
||||||
.panel-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
|
.panel-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
|
||||||
.panel-head h2 { flex: 1; }
|
.panel-head h2 { flex: 1; }
|
||||||
@@ -145,7 +145,8 @@ svg.bar .track { fill: var(--stroke); }
|
|||||||
svg.bar .fill { fill: var(--accent); }
|
svg.bar .fill { fill: var(--accent); }
|
||||||
svg.bar.muted .fill { fill: var(--text-faint); }
|
svg.bar.muted .fill { fill: var(--text-faint); }
|
||||||
[dir="rtl"] svg.bar { transform: scaleX(-1); }
|
[dir="rtl"] svg.bar { transform: scaleX(-1); }
|
||||||
svg.chart { width: 100%; height: auto; max-height: 220px; }
|
/* Charts keep a left-to-right axis in right-to-left pages (SVG ignores the HTML dir attribute). */
|
||||||
|
svg.chart { width: 100%; height: auto; max-height: 220px; direction: ltr; }
|
||||||
svg.chart .axis { stroke: var(--stroke); }
|
svg.chart .axis { stroke: var(--stroke); }
|
||||||
svg.chart .column { fill: var(--accent); }
|
svg.chart .column { fill: var(--accent); }
|
||||||
svg.chart.sun .column { fill: var(--sun); }
|
svg.chart.sun .column { fill: var(--sun); }
|
||||||
@@ -182,28 +183,21 @@ svg.chart .label { fill: var(--text-muted); }
|
|||||||
.table.compact .row:hover { background: none; }
|
.table.compact .row:hover { background: none; }
|
||||||
.table.compact.stats { grid-template-columns: minmax(0, 1fr) max-content max-content; }
|
.table.compact.stats { grid-template-columns: minmax(0, 1fr) max-content max-content; }
|
||||||
.table.compact.files { grid-template-columns: minmax(0, 1fr) max-content max-content max-content; }
|
.table.compact.files { grid-template-columns: minmax(0, 1fr) max-content max-content max-content; }
|
||||||
@container (max-width: 900px) {
|
/* Narrow panels or long translations: fitColumns() (ui.js) hides secondary columns level by level until the rows fit. */
|
||||||
.table.users { grid-template-columns: minmax(140px, 1.4fr) max-content minmax(120px, 1.3fr) max-content max-content; }
|
.table.users.fit-1 { grid-template-columns: minmax(120px, 1.4fr) max-content minmax(100px, 1.3fr) max-content max-content; }
|
||||||
.table.users .col-seen, .table.users .col-uploads { display: none; }
|
.table.users.fit-1 .col-seen, .table.users.fit-1 .col-uploads { display: none; }
|
||||||
.table.jobs { grid-template-columns: minmax(70px, max-content) minmax(100px, 1.6fr) minmax(80px, 1fr) max-content max-content; }
|
.table.users.fit-2 { grid-template-columns: minmax(110px, 1fr) max-content max-content max-content; }
|
||||||
.table.jobs .col-node, .table.jobs .col-created { display: none; }
|
.table.users.fit-2 .col-quota { display: none; }
|
||||||
.table.nodes { grid-template-columns: minmax(100px, 1fr) minmax(100px, 1.2fr) max-content max-content; }
|
.table.users.fit-3 { grid-template-columns: minmax(100px, 1fr) max-content max-content; }
|
||||||
.table.nodes .col-owner, .table.nodes .col-heartbeat { display: none; }
|
.table.users.fit-3 .col-status { display: none; }
|
||||||
.table.audit { grid-template-columns: max-content minmax(70px, .8fr) minmax(90px, max-content) minmax(100px, 2fr); }
|
.table.jobs.fit-1 { grid-template-columns: minmax(70px, max-content) minmax(100px, 1.6fr) minmax(80px, 1fr) max-content max-content; }
|
||||||
.table.audit .col-from { display: none; }
|
.table.jobs.fit-1 .col-node, .table.jobs.fit-1 .col-created { display: none; }
|
||||||
}
|
.table.jobs-mini.fit-1 { grid-template-columns: minmax(60px, max-content) minmax(80px, 1.5fr) minmax(60px, 1fr) max-content max-content; }
|
||||||
@container (max-width: 700px) {
|
.table.jobs-mini.fit-1 .col-node { display: none; }
|
||||||
.table.users { grid-template-columns: minmax(110px, 1fr) max-content max-content max-content; }
|
.table.nodes.fit-1 { grid-template-columns: minmax(100px, 1fr) minmax(100px, 1.2fr) max-content max-content; }
|
||||||
.table.users .col-quota { display: none; }
|
.table.nodes.fit-1 .col-owner, .table.nodes.fit-1 .col-heartbeat { display: none; }
|
||||||
}
|
.table.audit.fit-1 { grid-template-columns: max-content minmax(70px, .8fr) minmax(90px, max-content) minmax(100px, 2fr); }
|
||||||
@container (max-width: 620px) {
|
.table.audit.fit-1 .col-from { display: none; }
|
||||||
.table.users { grid-template-columns: minmax(100px, 1fr) max-content max-content; }
|
|
||||||
.table.users .col-status { display: none; }
|
|
||||||
}
|
|
||||||
@container (max-width: 560px) {
|
|
||||||
.table.jobs-mini { grid-template-columns: minmax(60px, max-content) minmax(80px, 1.5fr) minmax(60px, 1fr) max-content max-content; }
|
|
||||||
.table.jobs-mini .col-node { display: none; }
|
|
||||||
}
|
|
||||||
.table-foot { display: flex; align-items: center; gap: 16px; padding: 10px 18px; font-size: 12px; }
|
.table-foot { display: flex; align-items: center; gap: 16px; padding: 10px 18px; font-size: 12px; }
|
||||||
.table-foot a { white-space: nowrap; }
|
.table-foot a { white-space: nowrap; }
|
||||||
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
|
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Dashboard (mockup Admin.html, BRIEF §14.8): storage, archive, jobs, render nodes, charts, activity, active jobs.
|
// Dashboard (mockup Admin.html, BRIEF §14.8): storage, archive, jobs, render nodes, charts, activity, active jobs.
|
||||||
import { t, plural, applyStrings, culture } from "../i18n.js";
|
import { t, plural, applyStrings, culture } from "../i18n.js";
|
||||||
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, columns, toast, errorText, emptyState, redraw } from "../ui.js";
|
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, formatDuration, bar, columns, toast, errorText, emptyState, redraw, fitColumns } from "../ui.js";
|
||||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders } from "../jobs.js";
|
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders } from "../jobs.js";
|
||||||
import { activityText } from "../audit.js";
|
import { activityText } from "../audit.js";
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ export async function render(root, { api, setMeta, onEvent }) {
|
|||||||
<section class="panel">
|
<section class="panel">
|
||||||
<div class="panel-head"><h2 data-i18n="Admin.Dashboard.Jobs"></h2><a href="#/jobs" data-i18n="Admin.Dashboard.Queue" data-i18n-title="Admin.Dashboard.Queue.Tip"></a></div>
|
<div class="panel-head"><h2 data-i18n="Admin.Dashboard.Jobs"></h2><a href="#/jobs" data-i18n="Admin.Dashboard.Queue" data-i18n-title="Admin.Dashboard.Queue.Tip"></a></div>
|
||||||
${d.activeJobs.length === 0 ? emptyState("Admin.Jobs.Empty", SCAN_BUTTON) : `
|
${d.activeJobs.length === 0 ? emptyState("Admin.Jobs.Empty", SCAN_BUTTON) : `
|
||||||
<div class="table jobs-mini" role="table" aria-label="${attr(t("Admin.Dashboard.Jobs"))}">
|
<div class="table jobs-mini" data-levels="1" role="table" aria-label="${attr(t("Admin.Dashboard.Jobs"))}">
|
||||||
<div class="thead" role="row"><span role="columnheader" data-i18n="Admin.Jobs.Kind"></span><span role="columnheader" data-i18n="Admin.Jobs.Target"></span>
|
<div class="thead" role="row"><span role="columnheader" data-i18n="Admin.Jobs.Kind"></span><span role="columnheader" data-i18n="Admin.Jobs.Target"></span>
|
||||||
<span role="columnheader" class="col-node" data-i18n="Admin.Jobs.Node"></span><span role="columnheader" data-i18n="Admin.Jobs.Progress"></span>
|
<span role="columnheader" class="col-node" data-i18n="Admin.Jobs.Node"></span><span role="columnheader" data-i18n="Admin.Jobs.Progress"></span>
|
||||||
<span role="columnheader" data-i18n="Admin.Jobs.State"></span><span role="columnheader"><span class="sr-only" data-i18n="Admin.Common.Actions"></span></span></div>
|
<span role="columnheader" data-i18n="Admin.Jobs.State"></span><span role="columnheader"><span class="sr-only" data-i18n="Admin.Common.Actions"></span></span></div>
|
||||||
@@ -120,6 +120,7 @@ export async function render(root, { api, setMeta, onEvent }) {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
root.querySelector("#reload")?.addEventListener("click", load);
|
root.querySelector("#reload")?.addEventListener("click", load);
|
||||||
|
root.querySelectorAll(".table[data-levels]").forEach(fitColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEvent((e) => {
|
onEvent((e) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Jobs (BRIEF §14.8): queue and history with cancel/pause/resume/retry/priority, log tails, render nodes.
|
// Jobs (BRIEF §14.8): queue and history with cancel/pause/resume/retry/priority, log tails, render nodes.
|
||||||
import { t, plural, applyStrings } from "../i18n.js";
|
import { t, plural, applyStrings } from "../i18n.js";
|
||||||
import { escapeHtml, attr, formatTime, formatDateTime, toast, errorText, confirmDialog, emptyState, redraw } from "../ui.js";
|
import { escapeHtml, attr, formatTime, formatDateTime, toast, errorText, confirmDialog, emptyState, redraw, fitColumns } from "../ui.js";
|
||||||
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders, logText } from "../jobs.js";
|
import { kindLabel, nodeLabel, progressCell, stateCell, stateLabel, encoders, logText } from "../jobs.js";
|
||||||
|
|
||||||
const FILTERS = ["all", "running", "queued", "paused", "failed", "done", "cancelled"];
|
const FILTERS = ["all", "running", "queued", "paused", "failed", "done", "cancelled"];
|
||||||
@@ -18,7 +18,7 @@ export async function render(root, { api, setMeta, onEvent }) {
|
|||||||
root.innerHTML = `
|
root.innerHTML = `
|
||||||
<div class="chips" role="group" aria-label="${attr(t("Admin.Jobs.State"))}">${FILTERS.map((f) => `<button class="chip" data-filter="${f}" aria-pressed="${f === filter}" data-i18n="Admin.Jobs.Filter.${cap(f)}" data-i18n-title="Admin.Jobs.Filter.Tip"></button>`).join("")}</div>
|
<div class="chips" role="group" aria-label="${attr(t("Admin.Jobs.State"))}">${FILTERS.map((f) => `<button class="chip" data-filter="${f}" aria-pressed="${f === filter}" data-i18n="Admin.Jobs.Filter.${cap(f)}" data-i18n-title="Admin.Jobs.Filter.Tip"></button>`).join("")}</div>
|
||||||
<section class="panel flush">
|
<section class="panel flush">
|
||||||
<div class="table jobs" role="table" aria-label="${attr(t("Admin.Nav.Jobs"))}">
|
<div class="table jobs" data-levels="1" role="table" aria-label="${attr(t("Admin.Nav.Jobs"))}">
|
||||||
<div class="thead" role="row"><span role="columnheader" data-i18n="Admin.Jobs.Kind"></span><span role="columnheader" data-i18n="Admin.Jobs.Target"></span>
|
<div class="thead" role="row"><span role="columnheader" data-i18n="Admin.Jobs.Kind"></span><span role="columnheader" data-i18n="Admin.Jobs.Target"></span>
|
||||||
<span role="columnheader" class="col-node" data-i18n="Admin.Jobs.Node"></span><span role="columnheader" data-i18n="Admin.Jobs.Progress"></span>
|
<span role="columnheader" class="col-node" data-i18n="Admin.Jobs.Node"></span><span role="columnheader" data-i18n="Admin.Jobs.Progress"></span>
|
||||||
<span role="columnheader" data-i18n="Admin.Jobs.State"></span><span role="columnheader" class="col-created" data-i18n="Admin.Jobs.Created"></span>
|
<span role="columnheader" data-i18n="Admin.Jobs.State"></span><span role="columnheader" class="col-created" data-i18n="Admin.Jobs.Created"></span>
|
||||||
@@ -29,7 +29,7 @@ export async function render(root, { api, setMeta, onEvent }) {
|
|||||||
</section>
|
</section>
|
||||||
<section class="panel flush" aria-labelledby="nodes-title">
|
<section class="panel flush" aria-labelledby="nodes-title">
|
||||||
<div class="panel-head padded"><h2 id="nodes-title" data-i18n="Admin.Jobs.Nodes"></h2></div>
|
<div class="panel-head padded"><h2 id="nodes-title" data-i18n="Admin.Jobs.Nodes"></h2></div>
|
||||||
<div class="table nodes" role="table" aria-labelledby="nodes-title">
|
<div class="table nodes" data-levels="1" role="table" aria-labelledby="nodes-title">
|
||||||
<div class="thead" role="row"><span role="columnheader" data-i18n="Admin.Jobs.NodeName"></span><span role="columnheader" class="col-owner" data-i18n="Admin.Jobs.Owner"></span>
|
<div class="thead" role="row"><span role="columnheader" data-i18n="Admin.Jobs.NodeName"></span><span role="columnheader" class="col-owner" data-i18n="Admin.Jobs.Owner"></span>
|
||||||
<span role="columnheader" data-i18n="Admin.Jobs.Encoders"></span><span role="columnheader" class="col-heartbeat" data-i18n="Admin.Jobs.Heartbeat"></span>
|
<span role="columnheader" data-i18n="Admin.Jobs.Encoders"></span><span role="columnheader" class="col-heartbeat" data-i18n="Admin.Jobs.Heartbeat"></span>
|
||||||
<span role="columnheader" data-i18n="Admin.Jobs.State"></span><span role="columnheader"><span class="sr-only" data-i18n="Admin.Common.Actions"></span></span></div>
|
<span role="columnheader" data-i18n="Admin.Jobs.State"></span><span role="columnheader"><span class="sr-only" data-i18n="Admin.Common.Actions"></span></span></div>
|
||||||
@@ -113,6 +113,7 @@ export async function render(root, { api, setMeta, onEvent }) {
|
|||||||
applyStrings(nodeHost);
|
applyStrings(nodeHost);
|
||||||
});
|
});
|
||||||
nodeHost.querySelectorAll("[data-forget]").forEach((b) => b.addEventListener("click", () => forget(nodes.find((n) => n.id === b.dataset.forget))));
|
nodeHost.querySelectorAll("[data-forget]").forEach((b) => b.addEventListener("click", () => forget(nodes.find((n) => n.id === b.dataset.forget))));
|
||||||
|
root.querySelectorAll(".table[data-levels]").forEach(fitColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buttons(job) {
|
function buttons(job) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Logs (BRIEF §14.8): server log tail and downloads, diagnostics bundle, sign-in log (with failed attempts), audit log.
|
// Logs (BRIEF §14.8): server log tail and downloads, diagnostics bundle, sign-in log (with failed attempts), audit log.
|
||||||
import { t, plural, applyStrings } from "../i18n.js";
|
import { t, plural, applyStrings } from "../i18n.js";
|
||||||
import { escapeHtml, attr, formatBytes, formatDateTime, toast, errorText, routeParams, emptyState } from "../ui.js";
|
import { escapeHtml, attr, formatBytes, formatDateTime, toast, errorText, routeParams, emptyState, fitColumns } from "../ui.js";
|
||||||
import { actionLabel, detailText } from "../audit.js";
|
import { actionLabel, detailText } from "../audit.js";
|
||||||
|
|
||||||
const VIEWS = ["server", "signins", "audit"];
|
const VIEWS = ["server", "signins", "audit"];
|
||||||
@@ -82,7 +82,7 @@ export async function render(root, { api, setMeta, actions }) {
|
|||||||
}
|
}
|
||||||
root.innerHTML = `
|
root.innerHTML = `
|
||||||
<section class="panel flush">
|
<section class="panel flush">
|
||||||
<div class="table audit" role="table" aria-label="${attr(t(view === "signins" ? "Admin.Logs.View.Signins" : "Admin.Logs.View.Audit"))}">
|
<div class="table audit" data-levels="1" role="table" aria-label="${attr(t(view === "signins" ? "Admin.Logs.View.Signins" : "Admin.Logs.View.Audit"))}">
|
||||||
<div class="thead" role="row"><span role="columnheader" data-i18n="Admin.Logs.When"></span><span role="columnheader" data-i18n="Admin.Logs.Who"></span>
|
<div class="thead" role="row"><span role="columnheader" data-i18n="Admin.Logs.When"></span><span role="columnheader" data-i18n="Admin.Logs.Who"></span>
|
||||||
<span role="columnheader" data-i18n="Admin.Logs.What"></span><span role="columnheader" data-i18n="Admin.Logs.Details"></span>
|
<span role="columnheader" data-i18n="Admin.Logs.What"></span><span role="columnheader" data-i18n="Admin.Logs.Details"></span>
|
||||||
<span role="columnheader" class="col-from" data-i18n="Admin.Logs.From"></span></div>
|
<span role="columnheader" class="col-from" data-i18n="Admin.Logs.From"></span></div>
|
||||||
@@ -100,6 +100,7 @@ export async function render(root, { api, setMeta, actions }) {
|
|||||||
${cursor ? `<div class="table-foot"><span class="spacer"></span><button class="btn small" id="more" data-i18n="Admin.Common.More" data-i18n-title="Admin.Common.More.Tip"></button></div>` : ""}
|
${cursor ? `<div class="table-foot"><span class="spacer"></span><button class="btn small" id="more" data-i18n="Admin.Common.More" data-i18n-title="Admin.Common.More.Tip"></button></div>` : ""}
|
||||||
</section>`;
|
</section>`;
|
||||||
applyStrings(root);
|
applyStrings(root);
|
||||||
|
fitColumns(root.querySelector(".table.audit"));
|
||||||
root.querySelector("#more")?.addEventListener("click", async () => {
|
root.querySelector("#more")?.addEventListener("click", async () => {
|
||||||
await showAudit(true);
|
await showAudit(true);
|
||||||
root.querySelector("#more")?.focus();
|
root.querySelector("#more")?.focus();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Users (mockup AdminUsers.html, BRIEF §14.8): accounts table and a side panel to create, edit and reset accounts, or to
|
// Users (mockup AdminUsers.html, BRIEF §14.8): accounts table and a side panel to create, edit and reset accounts, or to
|
||||||
// change one's own password (a reset of one's own account would end this session and lose the temporary password).
|
// change one's own password (a reset of one's own account would end this session and lose the temporary password).
|
||||||
import { t, plural, applyStrings } from "../i18n.js";
|
import { t, plural, applyStrings } from "../i18n.js";
|
||||||
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, bar, toast, confirmDialog, errorText, emptyState, markInvalid, clearInvalid, redraw, focusPlace, restoreFocus } from "../ui.js";
|
import { escapeHtml, attr, formatBytes, formatNumber, formatTime, bar, toast, confirmDialog, errorText, emptyState, markInvalid, clearInvalid, redraw, focusPlace, restoreFocus, fitColumns } from "../ui.js";
|
||||||
import { icons } from "../icons.js";
|
import { icons } from "../icons.js";
|
||||||
|
|
||||||
const ROLES = ["viewer", "uploader", "editor", "admin"];
|
const ROLES = ["viewer", "uploader", "editor", "admin"];
|
||||||
@@ -31,7 +31,7 @@ export async function render(root, { api, info, setMeta, actions }) {
|
|||||||
root.innerHTML = `
|
root.innerHTML = `
|
||||||
<div class="split">
|
<div class="split">
|
||||||
<div class="panel flush">
|
<div class="panel flush">
|
||||||
<div class="table users" role="table" aria-label="${attr(t("Admin.Nav.Users"))}">
|
<div class="table users" data-levels="3" role="table" aria-label="${attr(t("Admin.Nav.Users"))}">
|
||||||
<div class="thead" role="row">
|
<div class="thead" role="row">
|
||||||
<span role="columnheader" data-i18n="Admin.Users.User"></span><span role="columnheader" data-i18n="Admin.Users.Role"></span>
|
<span role="columnheader" data-i18n="Admin.Users.User"></span><span role="columnheader" data-i18n="Admin.Users.Role"></span>
|
||||||
<span role="columnheader" class="col-quota" data-i18n="Admin.Users.Quota"></span><span role="columnheader" class="col-seen" data-i18n="Admin.Users.LastSeen"></span>
|
<span role="columnheader" class="col-quota" data-i18n="Admin.Users.Quota"></span><span role="columnheader" class="col-seen" data-i18n="Admin.Users.LastSeen"></span>
|
||||||
@@ -45,6 +45,7 @@ export async function render(root, { api, info, setMeta, actions }) {
|
|||||||
<aside class="panel side" id="side" hidden></aside>
|
<aside class="panel side" id="side" hidden></aside>
|
||||||
</div>`;
|
</div>`;
|
||||||
applyStrings(root);
|
applyStrings(root);
|
||||||
|
const table = root.querySelector(".table");
|
||||||
const side = root.querySelector("#side");
|
const side = root.querySelector("#side");
|
||||||
side.addEventListener("keydown", (e) => {
|
side.addEventListener("keydown", (e) => {
|
||||||
if (e.key === "Escape") {
|
if (e.key === "Escape") {
|
||||||
@@ -92,6 +93,7 @@ export async function render(root, { api, info, setMeta, actions }) {
|
|||||||
drawTable();
|
drawTable();
|
||||||
search.focus();
|
search.focus();
|
||||||
});
|
});
|
||||||
|
fitColumns(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowHtml(row) {
|
function rowHtml(row) {
|
||||||
@@ -159,12 +161,14 @@ export async function render(root, { api, info, setMeta, actions }) {
|
|||||||
side.hidden = false;
|
side.hidden = false;
|
||||||
side.innerHTML = html;
|
side.innerHTML = html;
|
||||||
applyStrings(side);
|
applyStrings(side);
|
||||||
|
fitColumns(table);
|
||||||
side.querySelector("#close").addEventListener("click", closeSide);
|
side.querySelector("#close").addEventListener("click", closeSide);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeSide() {
|
function closeSide() {
|
||||||
side.hidden = true;
|
side.hidden = true;
|
||||||
side.innerHTML = "";
|
side.innerHTML = "";
|
||||||
|
fitColumns(table);
|
||||||
if (opener) restoreFocus(opener.scope, opener.place);
|
if (opener) restoreFocus(opener.scope, opener.place);
|
||||||
opener = null;
|
opener = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export function columns(items, { label, sun = false, valueLabel = null, edgeLabe
|
|||||||
const max = Math.max(1, ...items.map((i) => i.value));
|
const max = Math.max(1, ...items.map((i) => i.value));
|
||||||
const step = width / Math.max(1, items.length);
|
const step = width / Math.max(1, items.length);
|
||||||
const barWidth = Math.max(2, Math.min(32, step * 0.65));
|
const barWidth = Math.max(2, Math.min(32, step * 0.65));
|
||||||
let svg = `<svg class="chart${sun ? " sun" : ""}" viewBox="0 0 ${width} ${height}" role="img" aria-label="${attr(label)}" dir="ltr">`;
|
let svg = `<svg class="chart${sun ? " sun" : ""}" viewBox="0 0 ${width} ${height}" role="img" aria-label="${attr(label)}">`;
|
||||||
svg += `<line class="axis" x1="0" y1="${base}" x2="${width}" y2="${base}"/>`;
|
svg += `<line class="axis" x1="0" y1="${base}" x2="${width}" y2="${base}"/>`;
|
||||||
items.forEach((item, i) => {
|
items.forEach((item, i) => {
|
||||||
const h = item.value > 0 ? Math.max(2, (item.value / max) * (base - 18)) : 0;
|
const h = item.value > 0 ? Math.max(2, (item.value / max) * (base - 18)) : 0;
|
||||||
@@ -83,6 +83,21 @@ export function columns(items, { label, sun = false, valueLabel = null, edgeLabe
|
|||||||
return svg + "</svg>";
|
return svg + "</svg>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides a table's secondary columns level by level (fit-1 … fit-n in admin.css, n = data-levels) until its rows fit
|
||||||
|
* the panel: the widths depend on the language and on the side panel, so they are measured rather than guessed.
|
||||||
|
*/
|
||||||
|
export function fitColumns(table) {
|
||||||
|
const host = table.parentElement;
|
||||||
|
const levels = Number(table.dataset.levels);
|
||||||
|
for (let level = 0; level <= levels; level++) {
|
||||||
|
for (let i = 1; i <= levels; i++) table.classList.toggle(`fit-${i}`, i <= level);
|
||||||
|
if (host.scrollWidth <= host.clientWidth) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("resize", () => document.querySelectorAll(".table[data-levels]").forEach(fitColumns));
|
||||||
|
|
||||||
/** An empty state: one sentence and one button (BRIEF §0.2). */
|
/** An empty state: one sentence and one button (BRIEF §0.2). */
|
||||||
export function emptyState(sentenceKey, button = "") {
|
export function emptyState(sentenceKey, button = "") {
|
||||||
return `<div class="empty"><span data-i18n="${attr(sentenceKey)}"></span>${button}</div>`;
|
return `<div class="empty"><span data-i18n="${attr(sentenceKey)}"></span>${button}</div>`;
|
||||||
|
|||||||
Reference in new issue
Block a user