index.tsx
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import type { ReactNode } from 'react';
import { UButton } from '@uj/ui';
export interface PageShellProps {
title: ReactNode;
/** 一句说明这个页面能做什么;写业务动作,不写字段名。 */
description?: ReactNode;
/** 子页面用:返回上一级。路由跳转方式由调用方提供,共享层不认识具体子应用的路由表。 */
onBack?: () => void;
/** 返回按钮文案,默认「返回」。 */
backLabel?: string;
/** 右上角动作区。 */
actions?: ReactNode;
/**
* 列表页:整屏定高,内容区(表格卡片)自己撑满剩余高度、表体内滚、分页贴底。
* 长表单页不要开,否则内容会被裁掉。
*/
fill?: boolean;
children: ReactNode;
}
/**
* 三个子应用共用的页面外壳:标题 + 说明 + 返回 + 右上角动作 + 内容。
*
* 统一这一层的原因:system 用内联 `padding: 10` 自己拼一遍、points 有 PageShell、
* store 又是第三套 .store-page/.store-page-header —— 同一件事三个写法,
* 标题字号、说明行高、动作间距全靠各自记,页面一多就参差。
*
* 只到页面骨架为止:控件、筛选、表格仍然是各页自己配(见「页面抽象阶梯」)。
*/
export function PageShell({
title,
description,
onBack,
backLabel = '返回',
actions,
fill = false,
children,
}: PageShellProps) {
return (
<div className={fill ? 'uj-page uj-page--fill' : 'uj-page'}>
<div className="uj-page__header">
<div>
<h2 className="uj-page__title">{title}</h2>
{description ? <p className="uj-page__desc">{description}</p> : null}
</div>
{onBack || actions ? (
<div className="uj-page__tools">
{onBack ? <UButton onClick={onBack}>{backLabel}</UButton> : null}
{actions}
</div>
) : null}
</div>
{fill ? <div className="uj-page__body">{children}</div> : children}
</div>
);
}