gui: a page's bar room comes out of its right padding, so both sides match
v0.1.1904 had every page keep its scrollbar's room, so nothing moves
when a page grows past the window. The owner asked whether the clear
bar now makes the sides uneven: it did, by the bar's width (8px on the
Mac, 10px on Windows and Linux), and the centred pages sat 4px to the
left.
layout.js measures the bar of a .view into --bar (again on resize, so
a text-size zoom is followed), and app.css takes it from each page's
right padding: the panel's 12px, the window's 16px, the centred pages'
max(16px, 50% - 600px) and the phone web's safe-area right. The heads
and strips that reach over the padding (Library's and Settings' sticky
heads, Providers' after-list fade, the masking record's bar) reach that
much less on the right, or they would run the page sideways. A plugin's
page, whose frame scrolls itself, shows a bar only when it needs one.
layout.js's measuring adds 254 bytes to the core's scripts; the budget is
raised by exactly that, with no room added.
page-width-steady.test.cjs now checks every page's left gap against its
right gap with the bar (chromium and webkit, the Mac's 8px bar and the
10px one, 1100 and 1600 wide) and that no page scrolls sideways; that
check found Providers' after-list fade running 4px past the page. With
v0.1.1904's CSS it is red ("agents: 16px on the left, 24px on the
right (bar 8px)", 26px with the 10px bar, 94/102 centred). page-width's
"centred" check compared paddings only, and now counts the bar too.
Run on mote at this head (f70cb6825's tree, on origin/main 174250b27):
page-width-steady, page-width, inner-scroll-contain, settings-tabs-stick,
library-all, agent-layout, i18n-keys, text-size, view-scrollbar: 168 of
168 pass; go test ./internal/gui -run Budget ok. Before the last rebase,
209 GUI files that reach pages, heads, panels, providers, masking,
library, settings and the gateway (3087 tests) had 29 reds; the same
files on origin/main d4f1d6480 had the same ones, apart from flakes:
gateway-key-limit and gateway-key-cycle (#4072, from f835bd713),
gateway-older (waits for #gateway .dot, which f835bd713 replaced; filed
with #4072's fix next), menu-input-scroll (#3402), header-centre webkit
(a ResizeObserver loop message, red on main too), account-mask chromium
zh, and gateway-caller-keys / gateway-key-models reading the page right
after a resize to 560 (#3523, #3797).
Not tried: the real Windows and Linux apps.
This commit is contained in:
@@ -535,7 +535,11 @@ body:not(.side-nav) .side-toggle .st-pane { opacity: 0; }
|
||||
window's height WebKit laid the page out at the full width under the
|
||||
bar and, on each redraw, 8px narrower for a few frames (@LingYi_Stu on
|
||||
X) */
|
||||
.view { flex: 1; min-height: 0; overflow-y: scroll; padding: 0 12px 4px; display: flex; flex-direction: column; animation: view-in .24s var(--ease); }
|
||||
/* the bar's room comes out of the right padding, so a page's sides stay
|
||||
the same width. Its width depends on the engine and the system, so
|
||||
layout.js measures it into --bar, again on a resize (a text-size zoom
|
||||
comes as one) */
|
||||
.view { flex: 1; min-height: 0; overflow-y: scroll; padding: 0 max(0px, calc(12px - var(--bar, 0px))) 4px 12px; display: flex; flex-direction: column; animation: view-in .24s var(--ease); }
|
||||
/* a box that scrolls in a page, marked by app.js while it overflows: the
|
||||
wheel at its ends stays with it (contain keeps the Mac's bounce on it).
|
||||
Only then: Chromium holds the wheel even in a box that doesn't overflow.
|
||||
@@ -543,13 +547,13 @@ body:not(.side-nav) .side-toggle .st-pane { opacity: 0; }
|
||||
:where(.holds) { overscroll-behavior-y: contain; }
|
||||
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }
|
||||
@media (prefers-reduced-motion: reduce) { .view { animation-name: fade-in; } }
|
||||
body.window .view { padding: 2px 16px 8px; }
|
||||
body.window .view { padding: 2px max(0px, calc(16px - var(--bar, 0px))) 8px 16px; }
|
||||
/* every page keeps to a width the eye can follow across, centred in a
|
||||
maximized window, rather than its name at one edge and its switch at the
|
||||
other (#860); Routing, Usage and Sessions too, so a large screen doesn't
|
||||
stretch them alone edge to edge while the others sit in the middle (面条 on
|
||||
Discord): their tables and charts lay out by the room they get */
|
||||
body.window :is(#view-agents, #view-sessions, #view-providers, #view-routing, #view-gateway, #view-usage, #view-library, #view-plugins, #view-settings) { padding-left: max(16px, calc(50% - 600px)); padding-right: max(16px, calc(50% - 600px)); }
|
||||
body.window :is(#view-agents, #view-sessions, #view-providers, #view-routing, #view-gateway, #view-usage, #view-library, #view-plugins, #view-settings) { padding-left: max(16px, calc(50% - 600px)); padding-right: max(0px, calc(max(16px, calc(50% - 600px)) - var(--bar, 0px))); }
|
||||
/* a view takes focus (tabIndex -1) only so the keys scroll it after a click;
|
||||
a ring round the whole list there marks nothing a reader can act on (#1601) */
|
||||
.view:focus { outline: none; }
|
||||
@@ -2865,7 +2869,7 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
in the content box (a negative margin-end was sideways scroll in macOS
|
||||
15's WebKit: see .lib-head, #1236) */
|
||||
#view-providers .after-list { position: sticky; bottom: -8px; z-index: 2; margin: 0 0 -8px; padding: 14px 4px 12px; transition: opacity .18s ease, visibility 0s; }
|
||||
#view-providers .after-list::before { content: ""; position: absolute; z-index: -1; inset: 0 -12px; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--bg) 12px); }
|
||||
#view-providers .after-list::before { content: ""; position: absolute; z-index: -1; inset: 0 calc(var(--bar, 0px) - 12px) 0 -12px; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--bg) 12px); } /* the bar's room is out of the padding */
|
||||
/* stepping aside it fades, then goes; back, it is there at once, so the
|
||||
focus can go to it as the sheet closes */
|
||||
#view-providers .after-list.away { opacity: 0; visibility: hidden; transition: opacity .18s ease, visibility 0s .18s; }
|
||||
@@ -3330,7 +3334,7 @@ body:not(.side-nav) #view-settings .set-head { position: sticky; top: 0; z-index
|
||||
body.window:not(.side-nav) #view-settings .set-head { top: -2px; --bleed-l: 16px; --bleed-r: 16px; }
|
||||
body:not(.side-nav) #view-settings .set-head::before {
|
||||
content: ""; position: absolute; z-index: -1; pointer-events: none;
|
||||
top: -6px; bottom: -6px; left: calc(-1 * var(--bleed-l)); right: calc(-1 * var(--bleed-r));
|
||||
top: -6px; bottom: -6px; left: calc(-1 * var(--bleed-l)); right: calc(var(--bar, 0px) - var(--bleed-r));
|
||||
background: color-mix(in srgb, var(--bg) 92%, transparent);
|
||||
-webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
|
||||
box-shadow: 0 1px 0 transparent; transition: box-shadow .18s var(--ease);
|
||||
@@ -3770,7 +3774,7 @@ body.panel .modal { padding: 16px 12px; }
|
||||
body.web .view {
|
||||
--view-left: max(12px, env(safe-area-inset-left));
|
||||
--view-right: max(12px, env(safe-area-inset-right));
|
||||
padding: 2px var(--view-right) 12px var(--view-left);
|
||||
padding: 2px max(0px, calc(var(--view-right) - var(--bar, 0px))) 12px var(--view-left);
|
||||
}
|
||||
body.web .foot { padding-bottom: max(8px, env(safe-area-inset-bottom)); min-width: 0; }
|
||||
body.web .foot .status { min-width: 0; overflow-wrap: anywhere; }
|
||||
|
||||
@@ -15,4 +15,8 @@
|
||||
if (!web && /^Mac/.test(navigator.platform)) document.body.classList.add("mac");
|
||||
if (!web && /^Linux/.test(navigator.platform)) document.body.classList.add("linux");
|
||||
if (/^Win/.test(navigator.platform)) document.documentElement.classList.add("win");
|
||||
// --bar: see app.css, .view
|
||||
function bar() { var p = document.createElement("div"); p.className = "view"; p.style.cssText = "position:absolute;visibility:hidden;height:9px"; document.body.appendChild(p); document.documentElement.style.setProperty("--bar", p.offsetWidth - p.clientWidth + "px"); p.remove(); }
|
||||
bar();
|
||||
addEventListener("resize", bar);
|
||||
})();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
}
|
||||
.lib-head::before {
|
||||
content: ""; position: absolute; z-index: -1; pointer-events: none;
|
||||
top: 0; bottom: 0; left: calc(-1 * var(--bleed-l)); right: calc(-1 * var(--bleed-r));
|
||||
top: 0; bottom: 0; left: calc(-1 * var(--bleed-l)); right: calc(var(--bar, 0px) - var(--bleed-r)); /* the bar's room is out of the padding */
|
||||
background: color-mix(in srgb, var(--bg) 92%, transparent);
|
||||
-webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
|
||||
box-shadow: 0 1px 0 transparent; transition: box-shadow .18s var(--ease);
|
||||
|
||||
@@ -148,12 +148,12 @@
|
||||
scrolls under them, on the frosted strip Settings' head has */
|
||||
.msk-onebar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px; min-height: 28px; }
|
||||
.msk-onebar::before {
|
||||
content: ""; position: absolute; z-index: -1; pointer-events: none; inset: -6px -12px;
|
||||
content: ""; position: absolute; z-index: -1; pointer-events: none; inset: -6px calc(var(--bar, 0px) - 12px) -6px -12px; /* the bar's room is out of the padding */
|
||||
background: color-mix(in srgb, var(--bg) 92%, transparent);
|
||||
-webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
|
||||
}
|
||||
body.window .msk-onebar { top: -2px; }
|
||||
body.window .msk-onebar::before { inset: -6px -16px; }
|
||||
body.window .msk-onebar::before { inset: -6px calc(var(--bar, 0px) - 16px) -6px -16px; }
|
||||
.msk-back { display: inline-flex; align-items: center; gap: 2px; margin-left: -4px; }
|
||||
.msk-crumb { color: var(--faint); }
|
||||
.msk-when { font-size: 12.5px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -9,6 +9,9 @@
|
||||
// default), and both engines draw the app's own thin bar, as the app does:
|
||||
// the Mac's 8px one and, with the platform said to be Windows, the 10px
|
||||
// one Windows and Linux get. A dialog's fields keep their bar's room too.
|
||||
// The bar's room comes out of the right padding (the owner: does the
|
||||
// clear bar make the sides uneven?), so the content sits as far from the
|
||||
// window's right edge, bar and all, as from its left.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -60,10 +63,11 @@ const onPlatform = async (browser, platform, viewport) => {
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) for (const platform of ["MacIntel", "Win32"]) {
|
||||
const launch = () => (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium", ignoreDefaultArgs: ["--hide-scrollbars"] }));
|
||||
|
||||
test(`${engine} ${platform}: no page narrows when it grows past the window`, async (t) => {
|
||||
// 1600 wide, the pages that centre their content have more than 16px a side
|
||||
for (const width of [1100, 1600]) test(`${engine} ${platform} ${width}: no page narrows when it grows past the window`, async (t) => {
|
||||
const browser = await launch();
|
||||
t.after(() => browser.close());
|
||||
const page = await onPlatform(browser, platform, { width: 1100, height: 700 });
|
||||
const page = await onPlatform(browser, platform, { width, height: 700 });
|
||||
page.setDefaultTimeout(6000);
|
||||
await page.route("**/*", serve("en"));
|
||||
await page.goto("http://magpie.test/?view=agents");
|
||||
@@ -75,6 +79,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const before = await shown(page).catch(() => null);
|
||||
if (!before || before.id !== `view-${id}`) continue; // a page this fixture doesn't open
|
||||
tried++;
|
||||
const sides = await page.evaluate((vid) => {
|
||||
const v = document.getElementById(vid), cs = getComputedStyle(v), bar = v.offsetWidth - v.clientWidth;
|
||||
return { left: parseFloat(cs.paddingLeft), right: parseFloat(cs.paddingRight) + bar, bar, wide: v.scrollWidth > v.clientWidth + 1 };
|
||||
}, before.id);
|
||||
assert(sides.bar > 0, `${id}: the page keeps its bar's room`);
|
||||
assert(Math.abs(sides.left - sides.right) <= 0.5, `${id}: ${sides.left}px on the left, ${sides.right}px on the right (bar ${sides.bar}px)`);
|
||||
assert(!sides.wide, `${id}: the page scrolls sideways`);
|
||||
// whatever opens in it: a block taller than the window, then gone
|
||||
const grown = await page.evaluate((vid) => {
|
||||
const v = document.getElementById(vid), b = document.createElement("div");
|
||||
|
||||
@@ -38,7 +38,8 @@ const box = (page, v) => page.evaluate((v) => {
|
||||
const cs = getComputedStyle(e);
|
||||
const r = e.getBoundingClientRect();
|
||||
const pl = parseFloat(cs.paddingLeft), pr = parseFloat(cs.paddingRight);
|
||||
return { left: Math.round(r.left + pl), width: Math.round(e.clientWidth - pl - pr), pl, pr };
|
||||
// pr is the right side's gap with the bar's room, which comes out of the padding
|
||||
return { left: Math.round(r.left + pl), width: Math.round(e.clientWidth - pl - pr), pl, pr: pr + e.offsetWidth - e.clientWidth };
|
||||
}, v);
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
|
||||
Reference in New Issue
Block a user