Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 索引页骨架的搜索框与版式开关照接管后的 BoardUI 控件取几何

longmeidaoa4f283c3551c
diff --git a/frontend/e2e/index-people.test.ts b/frontend/e2e/index-people.test.ts
index 1e7a6a841..ce45894dd 100644
--- a/frontend/e2e/index-people.test.ts
+++ b/frontend/e2e/index-people.test.ts
@@ -1,8 +1,26 @@
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
-import type { Browser } from 'playwright-core';
+import type { Browser, Page } from 'playwright-core';
import { launch, requiredEnv, settle, visit, VIEWPORTS } from './harness.ts';
+/** 标题行里搜索框、放大镜与版式开关的竖向落位和尺寸,取整到像素;图标连同线宽一起比。 */
+const headControls = (page: Page, selectors: { search: string; icon: string; layout: string }) =>
+ page.evaluate((selectors) => {
+ const box = (selector: string) => {
+ const node = document.querySelector(selector);
+ if (!node) return null;
+ const { y, width, height } = node.getBoundingClientRect();
+ return { y: Math.round(y), width: Math.round(width), height: Math.round(height) };
+ };
+ const icon = document.querySelector(selectors.icon);
+ const search = box(selectors.search);
+ return {
+ search: search && { y: search.y, height: search.height },
+ icon: icon && { ...box(selectors.icon)!, stroke: getComputedStyle(icon).strokeWidth },
+ layout: box(selectors.layout),
+ };
+ }, selectors);
+
describe('本地与在线艺人共用名册布局', () => {
let browser: Browser;
before(async () => { browser = await launch() });
@@ -28,9 +46,17 @@ describe('本地与在线艺人共用名册布局', () => {
assert.deepEqual(await page.locator('#index [role="tab"]').allTextContents(), ['艺人', '卖家', '在线']);
assert.deepEqual(await page.locator('#index [role="tab"][aria-selected="true"]').allTextContents(), [selected]);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true);
+ const waiting = await headControls(page, {
+ search: '#index .geist-search input', icon: '#index .geist-search-prefix svg', layout: '#index .ihead .iconswitch' });
release();
await page.locator('#index [data-index-page]').waitFor();
assert.deepEqual(await page.locator('#index [role="tab"]').allTextContents(), ['艺人', '卖家', '在线']);
+ const ready = await headControls(page, {
+ search: '#index [data-index-search] [role="presentation"]', icon: '#index [data-index-search] svg',
+ layout: '#index [data-index-layout]' });
+ // 标题行的搜索框与版式开关接管时原地换下:框高、竖向落位、图标与开关宽度都不跳。
+ // 横向位置跟着计数读数的字宽走,骨架那条占位条量不出真数字,不比。
+ assert.deepEqual(waiting, ready, '骨架与接管后的标题行控件几何不同');
} finally { release(); await context.close() }
});
}
diff --git a/web/css/01-base.css b/web/css/01-base.css
index fde1a6741..cc170b084 100644
--- a/web/css/01-base.css
+++ b/web/css/01-base.css
@@ -262,25 +262,24 @@ button,[role="button"],summary{user-select:none;-webkit-user-select:none;-webkit
/* React 子树的焦点环由 BoardUI 组件自己画(输入框画在外框上);`:where` 让特指度保持 0,1,0。 */
:where(:not(.peach-react *)):focus-visible{outline:2px solid var(--tungsten);outline-offset:2px}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
-/* Geist Search Input:搜索图标占前缀位,查找中原位换 Spinner,输入框几何不变。
- 全站带搜索语义的输入共用这一份,各处只加宽度和位置。 */
+/* 静态搜索框:React 接管前的骨架里用(索引页标题行),接管后换成 BoardUI 的 InputBase。
+ 两者是同一只框的前后两帧,几何与面照 InputBase 取:无边框的填充底、20px 图标距左 8px、
+ 文字从 34px 起(8 + 20 + 2 + 4),框高跟同一行按钮共用 --control-h。 */
.geist-search{position:relative;min-width:0}
-.geist-search-prefix{position:absolute;z-index:1;left:12px;top:11px;
- display:grid;place-items:center;width:16px;height:16px;color:var(--muted);pointer-events:none}
-.geist-search-prefix>svg{width:16px;height:16px;stroke:currentColor;fill:none}
-.geist-search input[type="search"]{width:100%;min-width:0;height:38px;
- box-sizing:border-box;border:1px solid var(--field-ring);border-radius:var(--control-radius);
- background:var(--ground);color:var(--ink);padding:0 12px 0 38px;font-size:var(--fs-md);font-family:inherit;
- line-height:20px;transition:box-shadow .12s ease}
+.geist-search-prefix{position:absolute;z-index:1;left:8px;top:calc((var(--control-h) - 20px) / 2);
+ display:grid;place-items:center;width:20px;height:20px;color:var(--color-text-tertiary);pointer-events:none}
+.geist-search-prefix>svg{width:20px;height:20px;stroke:currentColor;stroke-width:2;fill:none}
+.geist-search input[type="search"]{width:100%;min-width:0;height:var(--control-h);
+ box-sizing:border-box;border:0;border-radius:var(--control-radius);
+ background:var(--color-background-tertiary-default);color:var(--ink);padding:0 8px 0 34px;font-size:var(--fs-md);
+ font-family:inherit;line-height:20px;transition:box-shadow .12s ease}
.geist-search input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none;appearance:none}
-.geist-search input[type="search"]::placeholder{color:var(--muted)}
+.geist-search input[type="search"]::placeholder{color:var(--color-text-tertiary)}
/* 悬停与聚焦是同一枚 2px inset ring 在两档灰之间换档,聚焦压过悬停(BoardUI Input
- 的 `ring-2 ring-inset`,2026-09-09 取证登记 boardui-input)。环画在静止那条边的
- 内侧,三态边框同色——把聚焦态的边改成透明只会露出控件自己的底,那正是环外那条
- 亮边的来源。上游把 box-shadow 写进了 transition,环是渐变出来的,不是硬切。 */
+ 的 `ring-2 ring-inset`,2026-09-09 取证登记 boardui-input)。上游把 box-shadow 写进了
+ transition,环是渐变出来的,不是硬切。 */
.geist-search input[type="search"]:hover{box-shadow:inset 0 0 0 2px var(--color-border-button-hover)}
.geist-search input[type="search"]:focus{outline:0;box-shadow:inset 0 0 0 2px var(--color-border-button-active)}
-.geist-search:focus-within .geist-search-prefix{color:var(--ink)}
/* 纯文本输入框:全站唯一一份。此前每处自己拼内边距,控件高度散在 34/40/43 三档,
而 <=760px 那条把输入框字号顶到 16 像素的防放大规则只抬没写死高度的那几个,
同一行里的按钮不动,两个控件就差一截。
diff --git a/web/css/06-index.css b/web/css/06-index.css
index 9a7a3cc04..707ada0ee 100644
--- a/web/css/06-index.css
+++ b/web/css/06-index.css
@@ -29,6 +29,9 @@
.igrid[data-cells="company"]{grid-template-columns:repeat(auto-fill,minmax(180px,1fr))}
.igrid[data-cells="company"][data-layout="big"] .icell .ring{aspect-ratio:1}
.index .ihead .iconswitch{flex:none}
+/* 骨架里的版式开关是接管后那枚 BoardUI 分段器的替身:每格 28px 见方、图标 16px,整枚宽度对得上。 */
+.index .ihead .iconswitch>label{width:28px;height:28px}
+.index .ihead .iconswitch svg{width:16px;height:16px}
.tagwall{display:flex;flex-wrap:wrap;gap:7px}
/* 标签行骨架前面那枚色点,占的是真标签类型色点的位置。 */
.alphatag::before{content:"";width:7px;height:7px;border-radius:50%;