Peach: Local-first video metadata scraper and media manager.
fix(web): 浮层上下留一样宽的空隙,详情不再钻到它底下
longmeidaof4ce8ae36f7e
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 7a58c9983..48f05fe6e 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -6068,12 +6068,28 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains(".grid>.stage{grid-column:1/-1;width:100%;min-width:0}")def test_inline_detail_stays_below_the_visible_sticky_navigation(self):+ """详情展开后停在最后一层粘着的东西下面 8px。++ 名单要跟着粘的那一层走:`#tagbar` 与 `#count` 被收进 `.board-filter-frame` 之后+ 自己是 `position:relative`,只按这两个旧名字量就只剩顶栏那 64px,详情停在 144px、+ 浮层底边却在 168px,最上面 24px 连同关闭键一起压在它下面。两个旧名字留着,+ `original-design` 那条退路下粘的仍是它们自己。++ 顶栏那一段另有出处:`html` 的 `scroll-padding-top` 已经替它留好,而它和+ `scroll-margin-top` 是叠加的,再算一遍就把落点压低整整一个顶栏(要 176px,+ 实测落在 248px)。+ """self.assertPageLacks("body.detail-open .tagbar{position:relative;top:auto;z-index:1}")self.assertPageContains("function itemDetailStickyOffset()")- self.assertPageContains("['.top','#tagbar','#count','.entitytagbar','.entitycollectionhead']")+ self.assertPageContains("['.top','.board-filter-frame','#tagbar','#count',"+ "'.entitytagbar','.entitycollectionhead']")self.assertPageContains("el.compareDocumentPosition(stage)&Node.DOCUMENT_POSITION_FOLLOWING")self.assertPageContains("el.offsetParent===null||css.position!=='sticky'")- self.assertPageContains("stage.style.scrollMarginTop=`${itemDetailStickyOffset()+8}px`")+ self.assertPageContains("getComputedStyle(document.documentElement).scrollPaddingTop)||0")+ self.assertPageContains("stage.style.scrollMarginTop="+ "`${Math.max(0,itemDetailStickyOffset()+8-paved)}px`")+ self.assertIn("html{color-scheme:light;scroll-padding-top:calc(var(--topH) + 8px);",+ stylesheet_source())self.assertCode("buildBars();\n scrollItemDetailIntoView();")def test_catalog_skeleton_collects_the_bottom_loading_dots(self):@@ -7711,6 +7727,24 @@ class WebUiSourceTests(unittest.TestCase):"background:var(--picked);color:var(--ink)}", board)self.assertIn(".board-filter-frame #tagbar .pill{height:30px;padding:0 10px;font-size:13px;", board)+ def test_the_floating_filter_panel_leaves_the_same_gap_above_and_below(self):+ """浮层上下留一样宽的空隙;上面那段由页面给,它自己就不再加一层。++ 上沿是几段叠出来的:`.tiers` 收尾 8px、`main` 上沿 14px,浮层自己再要 8px,+ 而空着的 `.combo` 那 10px 下边距把它顶成 10px——实测上面 32px、下面 20px,+ 同一块浮层两头差 12px。前两段是每个页面共用的,改不动;所以浮层上面不加,+ 下面照那两段的和写,两个数从同一处读出来,谁改了页面上沿测试就在这里说话。+ """+ root = Path(__file__).resolve().parents[1]+ board = (root / "web/board.css").read_text(encoding="utf-8")+ base = stylesheet_source()+ rail = re.search(r"\.tiers\{[^}]*?padding:10px 0 (\d+)px", base)+ gutter = re.search(r"\bmain\{[^}]*?padding:(\d+)px \d+px", base)+ self.assertTrue(rail and gutter, "读不到 .tiers 的收尾与 main 的上沿")+ gap = int(rail.group(1)) + int(gutter.group(1))+ self.assertIn(f"background:var(--ground);margin:0 0 {gap}px;", board)+ self.assertIn(".combo:empty{margin-bottom:0}", base)+def test_a_profile_website_link_shows_the_sites_own_mark(self):"""官网那一格的文字是域名,图标是站点自己的那枚;取不到才露出地球。"""app = self.app_jsdiff --git a/web/app.js b/web/app.jsindex 4abbdcdbb..d7177d5f2 100644--- a/web/app.js+++ b/web/app.js@@ -1293,7 +1293,10 @@ function placeItemDetail(anchor,above=false){function itemDetailStickyOffset(){const stage=$('#stage');- return ['.top','#tagbar','#count','.entitytagbar','.entitycollectionhead'].reduce((bottom,selector)=>{+ /* 玻璃筛选条把 `#tagbar` 与 `#count` 收进 `.board-filter-frame` 之后,粘住的是外面这一层,+ 里面两条成了 `position:relative`。只按里面两个名字量就只剩顶栏那 64px:详情停在 144px,+ 筛选条底边却在 168px,最上面 24px 连同关闭键一起压在它下面。 */+ return ['.top','.board-filter-frame','#tagbar','#count','.entitytagbar','.entitycollectionhead'].reduce((bottom,selector)=>{const el=$(selector),css=el&&getComputedStyle(el);const beforeStage=!!el&&(el.compareDocumentPosition(stage)&Node.DOCUMENT_POSITION_FOLLOWING);if(!beforeStage||el.offsetParent===null||css.position!=='sticky')return bottom;@@ -1304,7 +1307,11 @@ function itemDetailStickyOffset(){function scrollItemDetailIntoView(){const stage=$('#stage');- stage.style.scrollMarginTop=`${itemDetailStickyOffset()+8}px`;+ /* `html` 的 `scroll-padding-top` 已经替顶栏留了一段,它和 `scroll-margin-top` 是叠加的:+ 把顶栏那 72px 再算一遍,落点就比要的位置低整整一个顶栏。扣掉它之后这个数只负责+ 顶栏以外还粘着的东西,也就是筛选条那一层。 */+ const paved=parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop)||0;+ stage.style.scrollMarginTop=`${Math.max(0,itemDetailStickyOffset()+8-paved)}px`;stage.scrollIntoView({behavior:'auto',block:'start'});scheduleStickySurfaces();}diff --git a/web/board.css b/web/board.cssindex f4604d71d..c40d582d6 100644--- a/web/board.css+++ b/web/board.css@@ -197,7 +197,10 @@ body :is(#manageTitle,#manageCrumb,#manageLede){max-width:var(--board-content);w:root[data-theme="dark"]{--page:#111;--ground:#1c1c1c;--surface:#232323;--sunk:#171717;--ink:#fafafa;--ink-2:#d4d4d4;--muted:#a3a3a3;--line:#383838;--line-soft:#303030;--inset:#303030;--picked:#303030;--hover:rgba(255,255,255,.07);--tungsten:#60a5fa}body::before{display:none}.tiers{background:transparent}-.board-filter-frame{position:sticky;top:calc(var(--topH) + 8px);z-index:60;border:0;border-radius:16px;background:var(--ground);margin:8px 0 20px;box-shadow:0 2px 14px #00000014}+/* 面板上沿那道空隙不由自己决定:`.tiers` 收尾留 8px、`main` 上沿又是 14px,它自己那+ 8px 还被 `.combo` 的下边距吃掉,加起来 32px,下面却只有 20px,同一块浮层上下差出 12px。+ 上面这 22px 改不动(两处都是别的页面共用的),所以自己不再加,下面照同一个数写。 */+.board-filter-frame{position:sticky;top:calc(var(--topH) + 8px);z-index:60;border:0;border-radius:16px;background:var(--ground);margin:0 0 22px;box-shadow:0 2px 14px #00000014}.board-filter-frame .tagbar,.board-filter-frame .count{position:relative;top:auto;left:auto;width:auto;margin:0;background:transparent;box-shadow:none;border:0;padding:10px 16px}.board-filter-frame .tagbar{border-bottom:0;border-radius:16px 16px 0 0}.board-filter-frame .count{border-radius:0 0 16px 16px;min-width:0}diff --git a/web/css/03-filterbar.css b/web/css/03-filterbar.cssindex 7701df3ca..04aebf341 100644--- a/web/css/03-filterbar.css+++ b/web/css/03-filterbar.css@@ -27,6 +27,8 @@/* 多标签交集筛选条 */.combo{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin:0 0 10px}+/* 一条也没有时不占位:高度是 0,那 10px 下边距却照留,成了下面那块浮层头顶的一段空白。 */+.combo:empty{margin-bottom:0}/* 交集条上的每一颗都是已经生效的筛选。 */.combo .cb{min-height:36px;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:0 9px 0 12px;border-radius:var(--tag-radius);border:1px solid var(--field-ring);color:var(--ink-2);