feat(dropdown-filter): new component

This commit is contained in:
Timi
2026-11-19 14:36:12 +08:00
parent 2556fc26ff
commit 0796e73ab1
9 changed files with 558 additions and 1 deletions
+113
View File
@@ -57,6 +57,63 @@
}
/**
* 列表页顶部的筛选栏:搜索框 + 下拉菜单贴在内容区顶部,展开的菜单和搜索框连成一块。
*
* 由 `DropdownFilter` 使用,也接受手写结构——只要根节点挂上这个类,
* 内部的 `.t-input` / `.menus` 就按同一套样式渲染。`z-index` 让整条栏浮在列表之上,
* 毛玻璃背景用 `::after` 单独一层,往下渐隐,内容滚过去才有层次感。
*/
.tui-filters {
top: -1rem;
margin: -1rem 0 0;
padding: 1rem 1rem 0;
z-index: 10;
position: sticky;
&::after {
top: 0;
left: 0;
mask: linear-gradient(to top, transparent 0%, #000 60%);
width: 100%;
height: 100%;
content: "";
z-index: -1;
position: absolute;
backdrop-filter: blur(var(--tui-backdrop-blur, 10px));
-webkit-mask: linear-gradient(to top, transparent 0%, #000 60%);
-webkit-backdrop-filter: blur(var(--tui-backdrop-blur, 10px));
}
.t-input {
--td-button-border-radius: 99rem;
border: 1px solid var(--td-component-border);
height: 2.25rem;
padding: .25rem .25rem .25rem .75rem;
z-index: 2;
position: relative;
border-radius: 1rem;
}
.tabs {
--td-tab-item-height: 32px;
}
.menus {
--td-spacer-1: 6px;
width: 100%;
border: 1px solid rgba(148, 163, 184, .18);
z-index: 1;
overflow: hidden;
margin-top: -1rem;
border-top: none;
padding-top: .8rem;
border-radius: 0 0 1rem 1rem;
}
}
.tui-page-layout {
min-height: 100vh;
box-sizing: border-box;
@@ -90,6 +147,48 @@
flex-shrink: 0;
}
}
/**
* 列表页的滚动容器。
*
* 内容区自己不滚动(`tui-page-content` 默认 `overflow: hidden`),
* 列表页把滚动权交给这个容器:外层只分配高度,`t-pull-down-refresh` 负责滚。
* track 撑满高度并纵向排列,空态才能垂直居中。
*/
.pull-refresh {
flex: 1;
min-height: 0;
overflow-x: hidden;
overflow-y: auto;
padding-bottom: calc(var(--tui-safe-bottom, 0px) + 1rem);
-webkit-overflow-scrolling: touch;
.t-pull-down-refresh__track {
gap: 1rem;
display: flex;
min-height: 100%;
height: auto;
flex-direction: column;
}
/**
* 筛选菜单展开时 TDesign 会给 track 写 `overflow: hidden`,
* 那会让 track 变成 sticky 的滚动容器,筛选栏跟着整条滚走。
* 有 `:has()` 时自动识别,没有时由 `.has-dropdown-filter` 兜底。
*/
@supports selector(:has(*)) {
&:has(.tui-filters) .t-pull-down-refresh__track {
overflow: visible !important;
}
}
&.has-dropdown-filter {
.t-pull-down-refresh__track {
overflow: visible !important;
}
}
}
}
&.tui-navbar {
@@ -119,6 +218,20 @@
}
}
}
/**
* 列表页的顶部间距必须落在真正的滚动容器上,内容才能穿进导航栏的毛玻璃层。
* 分栏形态下内容区不滚动、滚动的是主栏里的列表容器,间距的落点一样,
* 所以两种形态共用这一条。
*/
&.tui-navbar .tui-page-content.list {
padding-top: 0;
padding-bottom: 0;
.pull-refresh {
padding-top: calc(var(--tui-nav-height) + 1rem);
}
}
}
/**