From 9234ff688673c6a5452a9d39ae77264a6e097c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 4 Nov 2026 13:59:11 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20a=20branch=20rule=20nam?= =?UTF-8?q?es=20Pushes=20and=20Pull=20requests=20in=20the=20label=20column?= =?UTF-8?q?=20beside=20their=20first=20toggles=20instead=20of=20on=20lines?= =?UTF-8?q?=20of=20their=20own,=20and=20Save=20changes,=20Cancel=20and=20R?= =?UTF-8?q?emove=20rule=20stand=20under=20the=20fields=20with=20room=20abo?= =?UTF-8?q?ve;=20a=20short=20word=20action=20in=20any=20actions=20row=20st?= =?UTF-8?q?ands=20on=20the=20middle=20line=20of=20the=20tall=20submit=20be?= =?UTF-8?q?side=20it,=20no=20longer=20pinned=20to=20the=20row's=20top;=20t?= =?UTF-8?q?he=20mail=20settings'=20Send=20test=20mail=20to=20me=20sits=20b?= =?UTF-8?q?eside=20Save=20=E2=9C=85=20test:=20measure.ts=20checks=20alignm?= =?UTF-8?q?ent=20on=20every=20page=20and=20in=20every=20panel=20it=20opens?= =?UTF-8?q?:=20one=20control=20edge=20per=20form,=20each=20label=20on=20it?= =?UTF-8?q?s=20control's=20line,=20actions=20rows=20centred=20and=20on=20t?= =?UTF-8?q?he=20control=20edge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-web/src/pages/admin_mail.rs | 8 +-- crates/forge-web/src/pages/repo_settings.rs | 12 ++--- scripts/audit/measure.ts | 60 +++++++++++++++++++++ style/_one.scss | 6 +++ style/_one_admin.scss | 9 ++-- 5 files changed, 80 insertions(+), 15 deletions(-) diff --git a/crates/forge-web/src/pages/admin_mail.rs b/crates/forge-web/src/pages/admin_mail.rs index 2100119..feb0c74 100644 --- a/crates/forge-web/src/pages/admin_mail.rs +++ b/crates/forge-web/src/pages/admin_mail.rs @@ -281,10 +281,10 @@ async fn mail_view( (g::t(lang, K::SendMailCheckbox)) - - -
- +
+ + +
diff --git a/crates/forge-web/src/pages/repo_settings.rs b/crates/forge-web/src/pages/repo_settings.rs index d580ac4..b3af1df 100644 --- a/crates/forge-web/src/pages/repo_settings.rs +++ b/crates/forge-web/src/pages/repo_settings.rs @@ -652,8 +652,8 @@ async fn branch_rule_form( }
-

(g::t(lang, K::SectionPushes))

+ (g::t(lang, K::SectionPushes))
-

(g::t(lang, K::SectionPullRequests))

-
- - -
+ (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) {