feat(ui): Layout 新增 toolbar 插槽

页头与页身之间的一条真实占位带(搜索 / 筛选 / 操作),宽度跟随容器,
contained 时与侧栏 + 内容同宽,height=screen 下不参与内容区滚动。
用它替代「搜索框 fixed + contentOffset 让位」的写法。

- Layout.tsx / Layout.module.css:新增 toolbar prop 与样式
- 展示页 #layout 增加「页头下的工具条」示例
- COMPONENTS.md 补契约、与 contentOffset 的分工说明、changelog
This commit is contained in:
2026-11-01 15:15:14 +08:00
parent ebe4af3dab
commit 93bb5cbb28
5 changed files with 73 additions and 1 deletions
+7
View File
@@ -82,6 +82,13 @@
border-bottom: 1px solid var(--su-border);
}
/* 页头与页身之间的工具条:宽度随容器(contained 时与两栏同宽),
在正常流里占位,不参与 body 的内部滚动(screen 模式下就是「固定带」)。 */
.toolbar {
flex-shrink: 0;
width: 100%;
}
.body {
display: flex;
flex: 1;
+8
View File
@@ -15,6 +15,11 @@ import styles from './Layout.module.css'
export type LayoutProps = {
/** 页头:整宽、默认吸顶 */
header?: ReactNode
/**
* 工具条:页头与页身之间的一条带(搜索、筛选、面包屑下方的操作)。
* 宽度跟随容器(`contained` 时与侧栏 + 内容同宽),不参与内容区滚动。
*/
toolbar?: ReactNode
/** 左侧栏:固定宽度、与内容并排 */
sider?: ReactNode
/** 右侧栏:固定宽度、与内容并排(资料聚合、目录、广告位) */
@@ -67,6 +72,7 @@ export type LayoutProps = {
export function Layout({
header,
toolbar,
sider,
aside,
footer,
@@ -124,6 +130,8 @@ export function Layout({
)}
<div className={contained ? styles.container : undefined} style={containerStyle}>
{toolbar !== undefined && <div className={styles.toolbar}>{toolbar}</div>}
<div className={styles.body}>
{sider !== undefined && (
<aside