-
(g::t(lang, K::SectionPullRequests))
-
-
-
-
+
+
+
+
diff --git a/scripts/audit/measure.ts b/scripts/audit/measure.ts
index 6fc0e98..ae90838 100644
--- a/scripts/audit/measure.ts
+++ b/scripts/audit/measure.ts
@@ -195,6 +195,64 @@ const DESIGN = `(() => {
return [...new Set(bad)];
})()`;
+// Alignment inside `root`: a form's controls share one edge, a label stands on its control's line,
+// an actions row is one centred line on the control edge.
+const ALIGN = `((root) => {
+ const bad = [];
+ const seen = (e) => { const r = e.getBoundingClientRect(); return r.width > 0 && r.height > 0 && getComputedStyle(e).visibility !== 'hidden'; };
+ const name = (e) => e.tagName.toLowerCase() + (e.classList.length ? '.' + [...e.classList].join('.') : '') + ' < ' + (e.parentElement.classList[0] || e.parentElement.tagName.toLowerCase());
+ const mid = (r) => r.top + r.height / 2;
+ // The first line box of an element's text, or its box when it has no text.
+ const line = (e) => { const t = [...e.childNodes].find((n) => n.nodeType === 3 && n.textContent.trim()); if (t) { const g = document.createRange(); g.selectNodeContents(t); const rs = g.getClientRects(); if (rs.length) return rs[0]; } return e.getBoundingClientRect(); };
+ // One line of an actions row: its visible children sharing the first child's line are centred on it.
+ for (const row of root.querySelectorAll('.acts')) {
+ if (!seen(row) || getComputedStyle(row).display !== 'flex' || getComputedStyle(row).flexDirection !== 'row') continue;
+ const kids = [...row.children].filter((k) => seen(k) && !k.matches('.hint, input[type=hidden]'));
+ if (kids.length < 2) continue;
+ const a = kids[0].getBoundingClientRect();
+ for (const k of kids.slice(1)) {
+ const b = k.getBoundingClientRect();
+ if (b.top > a.bottom || b.bottom < a.top) continue; // wrapped to another line
+ // A word action is centred by its text, a control by its box.
+ const kb = k.matches('a.act, span.act, button.act:not([class*=pill])') && getComputedStyle(k).backgroundColor === 'rgba(0, 0, 0, 0)' ? line(k) : b;
+ if (Math.abs(mid(kb) - mid(a)) > 2) bad.push('acts row off centre ' + Math.round(mid(kb) - mid(a)) + 'px: ' + name(k));
+ }
+ }
+ for (const form of root.querySelectorAll('.fields')) {
+ if (!seen(form) || form.getBoundingClientRect().width < 500) continue;
+ const fields = [...form.querySelectorAll('.field')].filter((f) => seen(f) && f.closest('.fields') === form && getComputedStyle(f).display === 'grid');
+ const edges = new Map();
+ for (const f of fields) {
+ const lab = f.querySelector(':scope > label:not(.switch), :scope > .field-label');
+ const ctl = [...f.children].find((k) => seen(k) && k !== lab && !k.matches('.hint'));
+ if (!ctl) continue;
+ const left = Math.round(ctl.getBoundingClientRect().left);
+ edges.set(left, (edges.get(left) || 0) + 1);
+ if (lab && seen(lab)) {
+ const target = ctl.matches('.checks') ? (ctl.querySelector('label, .switch') || ctl) : ctl;
+ const tb = target.getBoundingClientRect();
+ // A tall control (a box of text, a choice) is read by its first line, 38 high.
+ const lm = mid(line(lab)), cm = target.matches('input, select, textarea, button, .choice') ? (tb.height > 40 ? tb.top + 19 : mid(tb)) : mid(line(target.querySelector('span') || target));
+ if (Math.abs(lm - cm) > 3) bad.push('label off its control line ' + Math.round(cm - lm) + 'px: ' + name(lab));
+ }
+ // A heading standing over a field with an empty label column: the name belongs in that column.
+ const prev = f.previousElementSibling;
+ if (!lab && prev && prev.matches('h2, h3, h4') && seen(prev)) bad.push('group name on its own line over an empty label column: ' + name(prev));
+ }
+ if (!edges.size) continue;
+ const edge = [...edges].sort((x, y) => y[1] - x[1])[0][0];
+ for (const [left, n] of edges) if (left !== edge && edges.size > 1) bad.push('control edge ' + left + ' (form edge ' + edge + ', ' + n + ' fields): ' + name(form));
+ // The actions after the fields: on the control edge, with room above.
+ const acts = form.querySelector(':scope > .acts:last-child') || (form.nextElementSibling?.matches('.acts') ? form.nextElementSibling : null);
+ const first = acts && [...acts.children].find(seen);
+ if (first && fields.length > 1) {
+ const r = first.getBoundingClientRect();
+ if (Math.abs(Math.round(r.left) - edge) > 1) bad.push('actions off the control edge ' + (Math.round(r.left) - edge) + 'px: ' + name(acts));
+ }
+ }
+ return bad;
+})`;
+
// The rules a floating panel must keep, run while it is open.
const PANEL = `((root) => {
const bad = [];
@@ -229,6 +287,7 @@ const OPEN = `(async () => {
}
bad.push(...${PANEL}(root));
bad.push(...(${PANEL})(root));
+ bad.push(...(${ALIGN})(root).map((l) => 'open ' + (summary.textContent || '').trim().slice(0, 30) + ': ' + l));
if (document.documentElement.scrollWidth > innerWidth + 1) bad.push('opening makes the page wide: ' + (summary.textContent || '').trim().slice(0, 30));
}
if (e.tagName === 'DETAILS') { e.open = false; } else { document.querySelector(':popover-open')?.hidePopover(); }
@@ -251,6 +310,7 @@ for (const path of paths) {
// An account's own theme wins over the system's: the audit asks for the one it measures.
if (process.env.AUDIT_THEME) await js(`document.documentElement.setAttribute('data-theme', ${JSON.stringify(theme)})`);
const bad: string[] = (await js(DESIGN)) ?? ["page did not answer"];
+ bad.push(...((await js(`(${ALIGN})(document.querySelector('main') || document.body)`)) ?? []));
const code = await js("document.title");
if (/not found|error/i.test(code ?? "")) bad.push("title: " + code);
const name = path.replace(/[^a-z0-9]+/gi, "_").slice(0, 120) + "_" + width + (theme === "dark" ? "_dark" : "");
diff --git a/style/_one.scss b/style/_one.scss
index 06b73b4..55a58bd 100644
--- a/style/_one.scss
+++ b/style/_one.scss
@@ -347,6 +347,12 @@ button.link-button,
align-items: center;
gap: 4px;
margin-left: -10px;
+
+ // Every button is pinned to the top of a flex column by the old sheet; in a row of actions a
+ // short word action stands on the middle line of a tall submit instead.
+ > :is(button, .button) {
+ align-self: auto;
+ }
}
.sec > .acts {
diff --git a/style/_one_admin.scss b/style/_one_admin.scss
index d357792..45f37f3 100644
--- a/style/_one_admin.scss
+++ b/style/_one_admin.scss
@@ -318,11 +318,9 @@ $repo: 'main:has(> section.repo-head .tab.active[href$="/settings"])';
min-width: 0;
}
-#{$repo} .rule-head {
- margin: 12px 0 0;
- font-size: 14px;
- font-weight: 600;
- color: var(--muted);
+// Each group is named in the label column beside its first toggles; a little air between groups.
+#{$repo} .rule-pr {
+ margin-top: 10px;
}
#{$repo} .branch-rule-form label.switch {
@@ -386,6 +384,7 @@ $repo: 'main:has(> section.repo-head .tab.active[href$="/settings"])';
#{$repo} .rule-acts {
align-items: center;
+ margin-top: 16px;
margin-left: calc(var(--label-w) + 16px);
@media (max-width: 700px) {