The owner, 11-12, on the Providers page's Add sheet: 向上滑动,然后这些区域 不在可视区域的时候,这些区域应该自动浮现在Header处. Beside the sidebar (side-nav, a window 1024px wide or more), the sheet's search, Custom provider and Import… now show in the title bar's empty right, left of its buttons, once the sheet's head row has scrolled out of sight. They are put there the way Library's, Plugins' and Settings' tools are: position: fixed inside --tools-l/--tools-r/--top-h, which app.js tools() keeps out of the crumb's way (its head query now includes #addSheet .add-tools.afloat). Scrolled back up, they are in their row again. Close stays in the sheet; the screenshot's box didn't cover it. The group is pinned, never copied, so there is one search: the words typed and the focus stay with it both ways. Each change is a 180ms fade in going into the bar and 140ms coming back, cubic-bezier(.23, 1, .32, 1), opacity only, so reduced motion keeps it. Nothing moves in the sheet: the head row keeps its height while its tools are up. Narrow (no sidebar, which covers 420px and the panel): the bar has no free room, so the sheet's whole head (label, tools, Close) is held at the top of the page while the sheet is under it, the way Settings' head is in a narrow window. It has the same blur strip and a hairline once stuck. At 760px and under, the tools take a line of their own under the label. The code is in a new addfloat.js, which renderAdd imports the first time the sheet opens. In app.js it took TestCoreScriptBudget 487 bytes over (1266031 > 1265544); with the move the budget passes and isn't raised. old-webkit's list of scripts loaded on demand names it. Run at 39ac4fafe (on origin/main2d2333cfa), then again after rebasing onbe8e352a2: - New add-sheet-float.test.cjs: 22/22 (chromium and webkit; en, zh, zh-TW, ja, de; 1100px and 420px). It scrolls with the real wheel. In the bar, it checks the search is in the title bar left of its buttons and right of the crumb, with Custom provider and Import… there too; narrow, that the head is held at the top. Then: the search is clear to press, a click scrolls nothing and takes the focus, typing "Relay 2" filters the tiles with one search kept, and scrolling back puts it in its row with the words and focus. - Red on the old code (git archive of the base's internal/gui): 0/22, on "in the bar once out of sight" (wide) and "the head held at the page's top" (narrow). - go test ./internal/gui -run Budget: ok (mica). - Related GUI files on mote, both engines, 380 tests, 376 pass: add-sheet, add-sheet-custom, add-button, add-partners-shine, add-sponsor-me, the six providers-*, i18n-keys, provider-detect-draft, provider-env-paste, provider-add-gemini, provider-retrieval-only, provider-url-each-api, modal-title-drag, model-id-space, builtins, old-webkit. The four reds are filed and come from other changes: - add-sheet "quiet rows" chromium en: tlscerts.js reads a null draft's serverPin (#6216). It was red in en, and in zh after the rebase, both times beside other files. Alone, chromium, 2/2 green on origin/main and 2/2 here; - old-webkit: headerpresets.js isn't in its list (#6030); - old-webkit: .side-foot:has() in app.css (#5919). - After rebasing onbe8e352a2: Budget ok; add-sheet-float, add-sheet, old-webkit and i18n-keys 34/38, the same three filed reds. - i18n-keys first ran out of memory under mote-run -C internal/gui: it walks ../../.., which there is all of ~/runs. Run from the tree's root: 4/4. Not tried: the real app (Wails on macOS, WebKitGTK on Linux, WebView2 on Windows). Only Playwright's engines were run, so the title bar's dragging around the pinned tools (--wails-draggable) wasn't checked in a real window.
25 lines
1.5 KiB
JavaScript
25 lines
1.5 KiB
JavaScript
// addToolsFloat: the add sheet's tools (search, Custom provider, Import…)
|
|
// scrolled out of sight show in the title bar's empty right, as Library's,
|
|
// Plugins' and Settings' tools do beside the sidebar (app.css
|
|
// .add-tools.afloat); scrolled back they are in their row again. The group
|
|
// itself is pinned, never a copy, so there is one search, its words and
|
|
// focus kept. A narrow window has no room in its bar: the sheet's head is
|
|
// held at the top of the page while the sheet is under it, as Settings'
|
|
// is (app.css). Each change fades in; a fade only, so reduced motion keeps it.
|
|
// app.js renderAdd imports this as the sheet first opens.
|
|
window.addToolsFloat = function (drawn) {
|
|
const v = $("#view-providers"), g = v.querySelector("#addSheet:not([hidden]) .add-tools");
|
|
if (!g) return;
|
|
const head = g.parentElement, sheet = head.parentElement, top = v.getBoundingClientRect().top;
|
|
const side = document.body.classList.contains("side-nav");
|
|
const h = head.getBoundingClientRect();
|
|
const up = side && !v.hidden && h.bottom <= top + 2;
|
|
head.classList.toggle("stuck", !side && h.top - sheet.getBoundingClientRect().top > 6.5);
|
|
if (up === g.classList.contains("afloat")) return;
|
|
g.classList.toggle("afloat", up);
|
|
self.sideTools?.();
|
|
if (!drawn) g.animate([{ opacity: 0 }, { opacity: 1 }], { duration: up ? 180 : 140, easing: "cubic-bezier(.23, 1, .32, 1)" });
|
|
};
|
|
$("#view-providers").addEventListener("scroll", () => addToolsFloat(), { passive: true });
|
|
addEventListener("resize", () => addToolsFloat());
|