Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 统计与口味页的排名展开收起带上高度过渡

longmeidao439861ebac83
diff --git a/docs/BOARD_UI.md b/docs/BOARD_UI.md
index cd7c510e3..bcdab2f3e 100644
--- a/docs/BOARD_UI.md
+++ b/docs/BOARD_UI.md
@@ -255,7 +255,7 @@ Radial Chart Card、Bar List Card、Heatmap 与 Sankey 的 Pro 源码**未取得
| 位置 | 上游 | Peach |
| --- | --- | --- |
| 排名行 | 行 36px、圆角 8、无悬停类;填充条 `absolute inset-y-0 left-0` 圆角 8,`chart-6` 14% 透明,只对宽度和颜色做 500ms 过渡 | 行与填充条圆角 8,填充 14%,去掉行悬停底(两层叠一起就是回执里的「违和」);行高保留 44 容两行字 |
-| 「Show N more」 | 40×20 药丸,居中贴底 4px,`border-button-default` 描边、primary 底、xs 阴影,14px 箭头,悬停 primary-hover 150ms;被折起的行直接不渲染,没有渐隐 | 同尺寸同色;列表高度不再做 240ms 过渡(上游没有高度动画,切维度标签时它会跟着抖一下);保留 48px 渐隐是主动差异 |
+| 「Show N more」 | 40×20 药丸,居中贴底 4px,`border-button-default` 描边、primary 底、xs 阴影,14px 箭头,悬停 primary-hover 150ms;被折起的行直接不渲染,没有渐隐 | 同尺寸同色;保留 48px 渐隐是主动差异;点按展开键时列表高度与箭头同走 200ms 过渡(用户要求,上游没有高度动画),过渡只在点按那一下挂上,切维度标签引起的高度变化直接到位,不跟着抖 |
| 数据源卡的删除键 | 站上图标键 `size-9 rounded-2lg text-foreground-icon-secondary`,只过渡颜色 | 36px、圆角 10、透明底,悬停主文字色 6% 薄底加 `--drop` 文字,`transform:none` |
| 指标卡悬停 | 无对应 | `--surface` 与 `--ground` 在亮色里同为白,改主文字色 6% 混底 |
| 管理页标题 | 无对应 | `body body.cleanup-layout` 写错让标题一直留在 812px 窄列;标题、面包屑、导语不看布局类一律对齐 1120(复核、高清版、重复文件这些子页没有布局类),复核页容器同宽 |
diff --git a/frontend/src/board-controls.ts b/frontend/src/board-controls.ts
index 43e392032..b8f198f50 100644
--- a/frontend/src/board-controls.ts
+++ b/frontend/src/board-controls.ts
@@ -135,7 +135,10 @@ export function wireExpandableRanks(root:ParentNode) {
淡掉最后 44px)。多留一截空白的话渐隐盖的是空处,看不出下面还有内容。 */
const size=()=>{const row=list.children[4] as HTMLElement;if(!list.offsetWidth)return;outer.style.setProperty('--rank-collapsed-height',`${row.offsetTop-list.offsetTop+row.offsetHeight}px`);outer.style.setProperty('--rank-expanded-height',`${list.scrollHeight}px`)};
const update=()=>{const expanded=button.getAttribute('aria-expanded')==='true';outer.classList.toggle('expanded',expanded);[...list.children].forEach((child,i)=>(child as HTMLElement).inert=!expanded&&i>=5);size()};
- button.onclick=()=>{const expanded=button.getAttribute('aria-expanded')!=='true';button.setAttribute('aria-expanded',String(expanded));button.setAttribute('aria-label',expanded?'收起排名':'展开更多排名');update()};
+ /* 高度过渡只挂在点按那一下。切维度标签时内容换了、量出的高度跟着变,常驻过渡会让列表抖一下。 */
+ const settle=(event:Event)=>{if(event.target===list)outer.classList.remove('toggling')};
+ list.addEventListener('transitionend',settle);list.addEventListener('transitioncancel',settle);
+ button.onclick=()=>{const expanded=button.getAttribute('aria-expanded')!=='true';button.setAttribute('aria-expanded',String(expanded));button.setAttribute('aria-label',expanded?'收起排名':'展开更多排名');outer.classList.add('toggling');update()};
new ResizeObserver(size).observe(list);update();
});
}
diff --git a/frontend/test/board-controls.test.ts b/frontend/test/board-controls.test.ts
index b68389788..165ae74f3 100644
--- a/frontend/test/board-controls.test.ts
+++ b/frontend/test/board-controls.test.ts
@@ -46,6 +46,18 @@ describe('范围控件',()=>{
expect(sixth.inert).toBe(true);toggle.click();expect(sixth.inert).toBe(false);
expect(toggle.getAttribute('aria-expanded')).toBe('true');toggle.click();expect(sixth.inert).toBe(true);
});
+ it('排名的高度过渡只挂在点按那一下,过渡结束即摘掉',()=>{
+ document.body.innerHTML='<div class="tasteranks">'+Array.from({length:7},()=>'<button>排名</button>').join('')+'</div>';
+ wireExpandableRanks(document);
+ const outer=document.querySelector('.board-expand-ranks')!,list=document.querySelector('.board-rank-list')!;
+ expect(outer.classList.contains('toggling')).toBe(false);
+ document.querySelector<HTMLButtonElement>('.board-rank-expand')!.click();
+ expect(outer.classList.contains('toggling')).toBe(true);
+ list.firstElementChild!.dispatchEvent(new Event('transitionend',{bubbles:true}));
+ expect(outer.classList.contains('toggling')).toBe(true);
+ list.dispatchEvent(new Event('transitionend'));
+ expect(outer.classList.contains('toggling')).toBe(false);
+ });
it('两个端点分别保留数值与不限状态,重复接线不增加气泡',()=>{
document.body.innerHTML='<div class="dual-range"><input id="durMin" type="range" min="0" max="180" value="20"><input id="durMax" type="range" min="0" max="180" value="180"></div>';
const inputs=[...document.querySelectorAll('input')];inputs.forEach(syncBoardRange);inputs.forEach(syncBoardRange);
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 64db3f871..231db82c4 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -6539,7 +6539,6 @@ class WebUiSourceTests(unittest.TestCase):
board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")
self.assertIn(".board-rank-expand{position:absolute;z-index:1;bottom:4px;left:50%;transform:translateX(-50%);display:grid;place-items:center;width:40px;height:20px;", board)
self.assertIn(".board-rank-expand svg{width:14px;height:14px;", board)
- self.assertNotIn("transition:max-height", board)
self.assertIn(".board-rank-list .tasterank{position:relative;isolation:isolate;border:0;border-radius:8px;", board)
self.assertNotIn(".board-rank-list .tasterank:hover{background:var(--color-background-primary-hover)}", board)
self.assertIn(".metricstrip>button:hover{background:color-mix(in srgb,var(--color-text-primary) 6%,var(--ground))}", board)
@@ -10386,13 +10385,20 @@ class WebUiSourceTests(unittest.TestCase):
盖的那种要先猜卡片是什么底色,猜错就在图上留一道横带;淡的这种在任何底色上都
成立。boardui 实测:列表自己带 `linear-gradient(#000 calc(100% - 44px),transparent)`,
- 展开就取消,正好露五行、淡掉最后 44px;展开没有高度动画,只有箭头转 200ms。
+ 展开就取消,正好露五行、淡掉最后 44px。两头高度由 JS 量好写进变量,展开收起的
+ 高度过渡与箭头旋转共用同一组 200ms 曲线。
"""
board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")
controls = (Path(__file__).resolve().parents[1] / "frontend/src/board-controls.ts").read_text(encoding="utf-8")
self.assertIn(".board-expand-ranks:not(.expanded)>.board-rank-list"
"{mask-image:linear-gradient(#000 calc(100% - 44px),transparent)}", board)
self.assertNotIn(".board-expand-ranks:not(.expanded)::after", board)
+ # 过渡只挂在点展开键的那一下:切维度标签时内容换了、量出的高度跟着变,常驻过渡会让列表抖一下。
+ self.assertIn(".board-expand-ranks.toggling>.board-rank-list{transition:max-height .2s cubic-bezier(0,0,.2,1)}", board)
+ self.assertNotIn("overflow:hidden;transition:max-height", board)
+ self.assertIn(".board-rank-list,.board-expand-ranks.toggling>.board-rank-list,"
+ ".board-rank-expand svg{transition:none}", board)
+ self.assertIn("outer.classList.add('toggling')", controls)
# 箭头是描边字形。只给宽高的话 use 里那条折线会被默认 fill 填成一枚实心三角。
self.assertIn(".board-rank-expand svg{width:14px;height:14px;fill:none;stroke:currentColor;"
"stroke-width:2;stroke-linecap:round;stroke-linejoin:round;"
diff --git a/web/board.css b/web/board.css
index b32c4089f..3ff059ef7 100644
--- a/web/board.css
+++ b/web/board.css
@@ -1340,11 +1340,11 @@ html.board-high-contrast :is(.selectiondock,.reviewcontrols.is-stuck,.reviewgrou
/* 收起时最后一行是被 mask 淡掉的,不是被一块渐变色盖住(boardui 实测:列表自己带
`linear-gradient(#000 calc(100% - 44px),transparent)`,展开就取消)。盖的那种要先猜卡片
是什么底色,猜错就在图上留一道横带;淡的这种在任何底色上都成立。 */
-.board-expand-ranks{position:relative;padding-bottom:28px}.board-rank-list{position:relative;display:grid;grid-template-columns:1fr;max-height:var(--rank-collapsed-height,300px);overflow:hidden}.board-expand-ranks:not(.expanded)>.board-rank-list{mask-image:linear-gradient(#000 calc(100% - 44px),transparent)}.board-expand-ranks.expanded>.board-rank-list{max-height:var(--rank-expanded-height)}.board-rank-expand{position:absolute;z-index:1;bottom:4px;left:50%;transform:translateX(-50%);display:grid;place-items:center;width:40px;height:20px;padding:0;border:1px solid var(--line);border-radius:999px;background:var(--surface);box-shadow:0 1px 3px #0000001a;color:var(--muted)}.board-rank-expand svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transition:transform .2s cubic-bezier(0,0,.2,1)}.board-rank-expand[aria-expanded=true] svg{transform:rotate(180deg)}
+.board-expand-ranks{position:relative;padding-bottom:28px}.board-rank-list{position:relative;display:grid;grid-template-columns:1fr;max-height:var(--rank-collapsed-height,300px);overflow:hidden}.board-expand-ranks.toggling>.board-rank-list{transition:max-height .2s cubic-bezier(0,0,.2,1)}.board-expand-ranks:not(.expanded)>.board-rank-list{mask-image:linear-gradient(#000 calc(100% - 44px),transparent)}.board-expand-ranks.expanded>.board-rank-list{max-height:var(--rank-expanded-height)}.board-rank-expand{position:absolute;z-index:1;bottom:4px;left:50%;transform:translateX(-50%);display:grid;place-items:center;width:40px;height:20px;padding:0;border:1px solid var(--line);border-radius:999px;background:var(--surface);box-shadow:0 1px 3px #0000001a;color:var(--muted)}.board-rank-expand svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transition:transform .2s cubic-bezier(0,0,.2,1)}.board-rank-expand[aria-expanded=true] svg{transform:rotate(180deg)}
.board-rank-list .tasterank{position:relative;isolation:isolate;border:0;border-radius:8px;background:transparent;overflow:hidden;min-height:44px}.board-rank-list .taste-rank-track{position:absolute;inset:0;height:100%;margin:0;z-index:-1;background:none;opacity:.14}.board-rank-list .taste-rank-track i{height:100%;border-radius:8px}
.board-sankey-card{padding:20px;border-radius:20px;margin-bottom:20px;background:var(--color-background-secondary-default);min-width:0}.board-sankey-card header{display:grid;grid-template-columns:1fr auto;gap:8px;margin-bottom:20px}.board-sankey-card h3{margin:0;font:var(--board-heading)}.board-sankey-card header b{grid-row:2;font:var(--board-title);font-variant-numeric:tabular-nums}.board-sankey-card header span{grid-column:2;grid-row:2;color:var(--muted);align-self:end;font:var(--board-caption)}.board-sankey-scroll{overflow-x:auto}.board-sankey-scroll svg{display:block;width:100%;min-width:640px;max-height:520px}.board-sankey-links path{fill:none;stroke:var(--flow-color);opacity:.3;transition:opacity .2s;animation:board-heat-enter .6s ease-out}.board-sankey-nodes g{transition:opacity .2s}.board-sankey-nodes text{fill:var(--color-text-primary);font:var(--board-caption)}.board-sankey-nodes tspan{fill:var(--muted);font-size:11px}.board-sankey-card footer{display:flex;justify-content:space-between;color:var(--muted);font:var(--board-caption);margin-top:12px}
.tasteactions [data-taste-window] .gselectfield::before{content:'';width:16px;height:16px;flex:none;background:currentColor;mask:url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2"%3E%3Crect x="3" y="5" width="18" height="16" rx="2"/%3E%3Cpath d="M16 3v4M8 3v4M3 11h18"/%3E%3C/svg%3E') center/contain no-repeat}
-@media(prefers-reduced-motion:reduce){.board-sankey-links path{animation:none;transition:none}.board-rank-list,.board-rank-expand svg{transition:none}}
+@media(prefers-reduced-motion:reduce){.board-sankey-links path{animation:none;transition:none}.board-rank-list,.board-expand-ranks.toggling>.board-rank-list,.board-rank-expand svg{transition:none}}
/* ── 分段控件(boardui segmented-control.tsx):口味页的证据切换与工具栏的版式切换同一枚滑块 ──
轨道 tertiary 底、4px 内边距、10px 圆角、2px 间隔;选项 px 10 / py 4、6px 圆角;选中 Body Medium 主文字色,
diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.js
index aa2164824..1b0198b94 100644
--- a/web/dist/peach-ui.js
+++ b/web/dist/peach-ui.js
@@ -1290,10 +1290,12 @@ function Wt(e) {
}, a = () => {
let t = r.getAttribute("aria-expanded") === "true";
n.classList.toggle("expanded", t), [...e.children].forEach((e, n) => e.inert = !t && n >= 5), i();
+ }, o = (t) => {
+ t.target === e && n.classList.remove("toggling");
};
- r.onclick = () => {
+ e.addEventListener("transitionend", o), e.addEventListener("transitioncancel", o), r.onclick = () => {
let e = r.getAttribute("aria-expanded") !== "true";
- r.setAttribute("aria-expanded", String(e)), r.setAttribute("aria-label", e ? "收起排名" : "展开更多排名"), a();
+ r.setAttribute("aria-expanded", String(e)), r.setAttribute("aria-label", e ? "收起排名" : "展开更多排名"), n.classList.add("toggling"), a();
}, new ResizeObserver(i).observe(e), a();
});
}