Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 修复侧栏高亮与窄屏搜索开合

longmeidao3e23f180f020
diff --git a/docs/BOARD_UI.md b/docs/BOARD_UI.md
index b16e6fe24..f713c76fd 100644
--- a/docs/BOARD_UI.md
+++ b/docs/BOARD_UI.md
@@ -1,5 +1,13 @@
# BoardUI 适配
+## 窄屏搜索玻璃动效
+
+2026-09-11 核对 [liquid-gooey spring.ts](https://github.com/Jakubantalik/Libraries/blob/422180dd7a5ac646c85deedc65500c4a74339127/packages/liquid-gooey/src/spring.ts),MIT,源码 SHA-256 `9dc0d5e9dd269000d95743572320039404982803d1b2da9977e717b5956d5481`。
+
+Peach 复用已采样的短程弹簧(208ms,stiffness 3600、damping 68、mass 1),以 CSS 裁切和透明度衔接开合;搜索建议在展开完成后解除裁切。控件固定 36px 高度,按顶栏实际高度居中,右侧按钮依次为搜索、沉浸、多选。
+
+未新增依赖;上游未作为完整搜索组件复刻。上游搜索交互与本轮浏览器实测未取得,本轮按用户要求不调用浏览器工具。
+
## 数据整理子页
2026-09-09 使用内置浏览器读取组件目录及 Dashboard 侧栏的八个模板。线上 CSS 资源版本为
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md
index 0e9fa5bc4..a4533a876 100644
--- a/docs/HANDOFF.md
+++ b/docs/HANDOFF.md
@@ -71,7 +71,7 @@
## 参考产品证据登记
-- [Board 取证](BOARD_UI.md#数据整理子页)。
+- [Board 与搜索动效取证](BOARD_UI.md)。
- [Geist 控件](reference-snapshots/vercel-geist-controls-measured.md);[复核操作](reference-snapshots/vercel-review-actions.md);[README 维护](README_MAINTENANCE.md)。
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 3547252ce..4ae328ae6 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -1552,6 +1552,15 @@ class WebUiSourceTests(unittest.TestCase):
self.assertCode('</div>\n <div class="settingsscroll">')
self.assertPageContains("@media(max-width:600px){.settingsscroll{padding:0 17px 17px}")
+ def test_sidebar_glide_tracks_layout_and_resets_hover_on_toggle(self):
+ self.assertPageContains("const navGlideResize=new ResizeObserver(resizeNavGlide);")
+ self.assertPageContains("navGlideResize.observe($('#drawer'));")
+ self.assertPageContains("navGlideResize.observe($('#drawerScroll'));")
+ self.assertPageContains("syncNavGlide(false,navGlideTarget);")
+ self.assertPageContains("document.addEventListener('board:sidebar',()=>{\n"
+ " navGlideTarget=null;\n"
+ " if(navGlideTick)cancelAnimationFrame(navGlideTick);")
+
def test_studio_metadata_is_not_compiled_as_inline_javascript(self):
self.assertPageLacks('onerror="this.parentNode.innerHTML=')
self.assertPageLacks('onload="if(this.naturalWidth')
@@ -2306,7 +2315,7 @@ class WebUiSourceTests(unittest.TestCase):
def test_narrow_top_bar_keeps_the_actions_on_the_right(self):
"""窄屏下搜索框绝对定位后脱离了流,动作按钮会挤在品牌名右侧、右半条留空。"""
- self.assertPageContains("#immerseBtn{margin-left:auto}")
+ self.assertPageContains("#searchBtn{margin-left:auto}")
def test_deleting_one_search_record_keeps_the_menu_open(self):
"""删除按钮不能抢焦点,也不能整段重建下拉栏。
@@ -2491,9 +2500,21 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains(".top:has(.search.open) #filterBtn,")
self.assertPageContains(".top:has(.search.open) .searchback{display:inline-flex")
# 搜索框不铺满:左边留出返回按钮的位置。
- # 左右 8、两者间距 4、同高 36、纵向各 8——全部取自 `.top` 自己的 padding/gap。
- self.assertPageContains(".search{position:absolute;left:48px;right:8px;top:8px;height:36px")
- self.assertPageContains(".searchback{display:inline-flex;position:absolute;left:8px;top:8px")
+ # 搜索和返回键共享顶栏中心线。
+ self.assertPageContains(".search{position:absolute;left:48px;right:8px;top:calc(50% - 18px);height:36px")
+ self.assertPageContains(".searchback{display:inline-flex;position:absolute;left:8px;top:calc(50% - 18px)")
+
+ def test_narrow_search_order_and_interruptible_glass_transition(self):
+ root = Path(__file__).resolve().parents[1]
+ html = (root / "web/index.html").read_text(encoding="utf-8")
+ board = (root / "web/board.css").read_text(encoding="utf-8")
+ self.assertLess(html.index('id="searchBtn"'), html.index('id="immerseBtn"'))
+ self.assertLess(html.index('id="immerseBtn"'), html.index('id="selectMode"'))
+ self.assertIn("transition:clip-path calc(var(--spring-press-ms) * 1ms) var(--spring-press)", board)
+ self.assertIn(".top .search.search-ready{clip-path:none}", board)
+ self.assertPageContains("if(document.activeElement===$('#q'))return;")
+ self.assertPageContains("$('#searchBtn').setAttribute('aria-expanded',String(open));")
+ self.assertPageContains("if(open&&matchMedia('(prefers-reduced-motion:reduce)').matches)")
def test_unlinked_identity_does_not_look_clickable(self):
"""渲染成 `<span>` 的归属不能长得像链接。
diff --git a/web/app.js b/web/app.js
index 6bdc6077c..9b77be658 100644
--- a/web/app.js
+++ b/web/app.js
@@ -3325,6 +3325,19 @@ function syncNavGlide(animate,target){
/* 侧栏纵滚时玻璃原地跟上:容器滚走了它不动就会脱开对准的那一格。一帧只算一次——
每次都要量位置,逐个滚动事件地量等于把滚动这件事拖回主线程排队。 */
let navGlideTick=0;
+/* 开合与响应式布局都按实际尺寸同步;开合后悬停目标归回当前导航项。 */
+function resizeNavGlide(){
+ navGlide?.getAnimations().forEach(animation=>animation.cancel());
+ syncNavGlide(false,navGlideTarget);
+}
+const navGlideResize=new ResizeObserver(resizeNavGlide);
+navGlideResize.observe($('#drawer'));
+navGlideResize.observe($('#drawerScroll'));
+document.addEventListener('board:sidebar',()=>{
+ navGlideTarget=null;
+ if(navGlideTick)cancelAnimationFrame(navGlideTick);
+ navGlideTick=requestAnimationFrame(()=>{navGlideTick=0;syncNavGlide(false)});
+});
$('#drawerScroll').addEventListener('scroll',()=>{
if(navGlideTick)return;
navGlideTick=requestAnimationFrame(()=>{navGlideTick=0;syncNavGlide(false)});
@@ -9488,16 +9501,34 @@ async function tokNext(d){
}
$('#immerseBtn').onclick=()=>openTok();
-$('#searchBtn').onclick=()=>{const s=$('.search');s.classList.toggle('open');
- if(s.classList.contains('open'))$('#q').focus()};
+function setNarrowSearchOpen(open){
+ const search=$('.search');
+ if(search.classList.contains('search-ready')){
+ search.classList.remove('search-ready');
+ void search.offsetWidth;
+ }
+ search.classList.toggle('open',open);
+ $('#searchBtn').setAttribute('aria-expanded',String(open));
+ if(open&&matchMedia('(prefers-reduced-motion:reduce)').matches)search.classList.add('search-ready');
+}
+$('.search').addEventListener('transitionend',event=>{
+ if(event.target===$('.search')&&event.propertyName==='clip-path'&&$('.search').classList.contains('open'))
+ $('.search').classList.add('search-ready');
+});
+$('#searchBtn').onclick=()=>{setNarrowSearchOpen(true);$('#q').focus()};
/* 窄屏退出搜索。失焦那条 140ms 的兜底只在输入框为空时才收起搜索栏,
输入过内容就没有出口了;返回按钮无条件收起,并清掉下拉栏。 */
$('#searchBack').onclick=()=>{
- $('.search').classList.remove('open');
+ setNarrowSearchOpen(false);
hideSearchMenu();
$('#q').blur();
+ $('#searchBtn').focus();
};
-$('#q').addEventListener('blur',()=>setTimeout(()=>{if(!$('#q').value&&!$('#searchMenu').matches(':hover'))$('.search').classList.remove('open');hideSearchMenu()},140));
+$('#q').addEventListener('blur',()=>setTimeout(()=>{
+ if(document.activeElement===$('#q'))return;
+ if(!$('#q').value&&!$('#searchMenu').matches(':hover'))setNarrowSearchOpen(false);
+ hideSearchMenu();
+},140));
/* 收起下拉栏不能只有失焦这一条路:焦点未必在输入框上,而下拉栏照样开着。
落在 `.search` 之外的第一下按压一律收起,这条判据不问焦点在哪儿。走捕获期
的 pointerdown,是因为被点的那个东西自己可能吃掉事件或立刻把自己从页面里
diff --git a/web/board.css b/web/board.css
index 1545cafed..ab214a0a2 100644
--- a/web/board.css
+++ b/web/board.css
@@ -532,6 +532,17 @@ body>.board-filter-frame{margin-inline:16px}
.drawer #brandHome .mark{width:28px;height:28px}.drawer #brandHome h1{font-size:20px;letter-spacing:.02em}.drawer #brandHome .sub{display:none}
.edge::before{content:'';width:28px;height:28px;background:url('/peach-logo.png') center/contain no-repeat;padding:0;margin:4px 0 16px}
.top .search{max-width:none;flex:1 1 0;min-width:0;margin-left:0;margin-right:0}
+/* 搜索沿横向展开,复用短程玻璃弹簧;文字与控件高度保持固定。 */
+@media(max-width:760px){
+ .top .search{display:flex;visibility:hidden;pointer-events:none;opacity:0;
+ clip-path:inset(0 80px 0 max(0px,calc(100% - 116px)) round 18px);
+ transition:clip-path calc(var(--spring-press-ms) * 1ms) var(--spring-press),
+ opacity calc(var(--spring-press-ms) * 1ms),visibility 0s calc(var(--spring-press-ms) * 1ms)}
+ .top .search.open{visibility:visible;pointer-events:auto;opacity:1;
+ clip-path:inset(0 0 0 0 round 18px);transition-delay:0s}
+ .top .search.search-ready{clip-path:none}
+ .top .search:not(.search-ready) .searchmenu{visibility:hidden}
+}
.board-filter-frame #tagbar{height:48px;gap:6px;padding:8px 12px}
.board-filter-frame #tagbar .pill{height:30px;padding:0 10px;font-size:13px;line-height:20px;border-radius:8px;border:1px solid transparent}
/* 四枚视图自己不铺底,选中那一枚的填充由 `.viewglide` 那块滑过去的玻璃提供:
diff --git a/web/css/19-immersive.css b/web/css/19-immersive.css
index 514fd46dc..39cb96e5e 100644
--- a/web/css/19-immersive.css
+++ b/web/css/19-immersive.css
@@ -157,11 +157,10 @@ body:has(#batchbar:not([hidden])) #stage{padding-bottom:180px}
.ib svg{width:19px;height:19px}
/* 展开的搜索栏不铺满整条:左边留出返回按钮,和 YouTube 手机版一致——
否则进了搜索就没有退出的入口,只能靠失焦或 Esc。 */
- /* 间距统一到顶栏自己的口径:左右留白 8(`.top` 的 padding),返回键与搜索框之间
- 4(`.top` 的 gap),两者同高 36(`.ib` 的窄屏尺寸),纵向各留 (52-36)/2=8。
+ /* 左右留白 8、返回键与搜索框间距 4、控件同高 36,按顶栏实际高度垂直居中。
不用 transform 居中——`.searchmenu` 在窄屏是 position:fixed,祖先一有 transform
就会改成相对它定位,下拉栏会整个跑偏。 */
- .search{position:absolute;left:48px;right:8px;top:8px;height:36px;padding:0 14px;
+ .search{position:absolute;left:48px;right:8px;top:calc(50% - 18px);height:36px;padding:0 14px;
max-width:none;margin:0;display:none;z-index:5;background:var(--surface)}
.search.open{display:flex}
/* 展开搜索时整条顶栏让位:筛选、品牌和右侧动作全部收起,只留返回箭头和输入框。
@@ -172,7 +171,7 @@ body:has(#batchbar:not([hidden])) #stage{padding-bottom:180px}
.top:has(.search.open) #immerseBtn,
.top:has(.search.open) #selectMode,
.top:has(.search.open) #settingsBtn{display:none!important}
- .top:has(.search.open) .searchback{display:inline-flex;position:absolute;left:8px;top:8px;z-index:6}
+ .top:has(.search.open) .searchback{display:inline-flex;position:absolute;left:8px;top:calc(50% - 18px);z-index:6}
.searchmenu{position:fixed;left:8px;right:8px;top:56px;max-height:70vh;overflow:auto;overscroll-behavior:contain}
#searchBtn{display:inline-flex!important}
/* 移动端不需要密度切换和筛选抽屉按钮挤在一起 */
@@ -180,7 +179,7 @@ body:has(#batchbar:not([hidden])) #stage{padding-bottom:180px}
/* 宽屏靠 `.search{flex:1}` 把动作按钮顶到右边;窄屏搜索框收成绝对定位后脱离
了流,没有东西再撑开中间,按钮会全部挤在品牌名右侧、右半条留空。
动作组的第一个按钮吃掉剩余空间,整组回到右边。 */
- #immerseBtn{margin-left:auto}
+ #searchBtn{margin-left:auto}
/* 窄屏改成单列居中,头像在名字上方——参考 beeg 的资料页。
左像右文那套是给宽屏的:手机上 92 px 头像旁边只剩两百多像素,别名和链接被挤成
两三行,头像下面又空着一大片。居中之后名字和链接都拿到整行宽度。 */
diff --git a/web/index.html b/web/index.html
index b6464bf8d..be364fd92 100644
--- a/web/index.html
+++ b/web/index.html
@@ -187,9 +187,8 @@
<div class="search"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-search"/></svg>
<input id="q" name="q" type="search" placeholder="FC2" autocomplete="off" aria-label="搜索作品、女优、厂牌或标签">
<div class="searchmenu" id="searchMenu" hidden></div></div>
- <button class="ib" id="immerseBtn" title="沉浸模式 · 随机连播" aria-label="进入沉浸模式"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-play"/></svg></button>
-
<button class="ib" id="searchBtn" title="搜索" aria-label="搜索"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-search"/></svg></button>
+ <button class="ib" id="immerseBtn" title="沉浸模式 · 随机连播" aria-label="进入沉浸模式"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-play"/></svg></button>
<button class="ib" id="selectMode" title="多选(Ctrl 单项,Shift 连续)" aria-label="多选模式" aria-pressed="false"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-square-check-big"/></svg></button>
<button class="ib" id="density" title="密度:大图 / 密集" aria-label="切换卡片密度"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-layout-grid"/></svg></button>
<button class="ib" id="settingsBtn" title="设置" aria-label="打开设置"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-settings"/></svg></button>