迁移平台资产库:三类母版网格/列表/素材墙 + AI 生成抽屉;Drawer 宽度可传类、Pager 支持自定义每页档位

main
mula.liu 2026-11-01 18:54:46 +08:00
parent 569f4c2f1d
commit 13e1990888
3 changed files with 2076 additions and 12 deletions

View File

@ -165,10 +165,17 @@ export function TagChip({ children, onRemove, className, removeTitle }: {
)
}
/** 分页条(规范 §5):page_size 唯一的家,筛选栏里不再出现「每页」 */
export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra }: {
/**
* 分页条(规范 §5):page_size 唯一的家,筛选栏里不再出现「每页」。
*
* 档位默认覆盖表格页的常用宽度;卡片墙这类一格 150px 的网格要的是 24/60/120/全部,
* 所以档位开成入参,由页面自己给(sizes 里 0 表示不分页)。
*/
const DEFAULT_SIZES = [12, 20, 24, 30, 48, 60, 120]
export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra, sizes = DEFAULT_SIZES }: {
page: number; pages: number; total?: number; pageSize?: number
onPageSize?: (size: number) => void; onPage: (page: number) => void; extra?: ReactNode
sizes?: number[]
}) {
const last = Math.max(1, pages)
return (
@ -182,7 +189,7 @@ export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra
<label className="flex items-center gap-1.5 m-0 text-muted text-tiny whitespace-nowrap">
<span className="flex-none">每页</span>
<select value={pageSize} onChange={(e) => onPageSize(Number(e.target.value))} className="w-auto min-w-[64px]">
{[12, 20, 24, 30, 48, 60, 120].map((n) => <option key={n} value={n}>{n}</option>)}
{sizes.map((n) => <option key={n} value={n}>{n || '全部'}</option>)}
</select>
</label>
)}

View File

@ -37,7 +37,7 @@ function useScrollLock(open: boolean) {
}, [open])
}
export function Drawer({ open, onClose, eyebrow, title, sub, children, actions, wide, closeOnBackdrop = true, label }: {
export function Drawer({ open, onClose, eyebrow, title, sub, children, actions, width, closeOnBackdrop = true, label }: {
open: boolean
onClose: () => void
/** 眉标(ASSET · 人物 / EDIT MODEL) */
@ -47,8 +47,9 @@ export function Drawer({ open, onClose, eyebrow, title, sub, children, actions,
children: ReactNode
/** 底部动作条;不传就不渲染这一行 */
actions?: ReactNode
/** 超长表单抽屉:宽档 1360px(默认)已是上限,此参数留给更窄的场景 */
wide?: boolean
/** 宽度档:默认 1360px 表单抽屉;只放一块面板的抽屉要窄一些,
* 好让左侧列表仍可见(旧站 .gen-drawer 就是 980px),传 Tailwind 宽度类即可 */
width?: string
closeOnBackdrop?: boolean
label?: string
}) {
@ -60,7 +61,7 @@ export function Drawer({ open, onClose, eyebrow, title, sub, children, actions,
onMouseDown={(e) => { if (closeOnBackdrop && e.target === e.currentTarget) onClose() }}>
<section role="dialog" aria-modal="true" aria-label={typeof label === 'string' ? label : undefined}
className={cn('flex flex-col min-w-0 h-screen border-l border-line-strong bg-shell shadow-drawer',
'w-[min(1360px,calc(100vw-20px))] max-huge:w-[calc(100vw-16px)] max-short:w-screen')}>
width || 'w-[min(1360px,calc(100vw-20px))] max-huge:w-[calc(100vw-16px)] max-short:w-screen')}>
<header className="flex-none flex justify-between items-start gap-[14px] p-[20px_24px_15px] max-short:p-[20px_14px_15px] border-b border-[--c-bg-emphasis] bg-[linear-gradient(120deg,var(--c-bg-raised),var(--c-bg-panel)_55%)]">
<div className="min-w-0">
{eyebrow && <small className="text-tiny tracking-[1.6px] text-muted font-bold">{eyebrow}</small>}
@ -84,9 +85,11 @@ export function Drawer({ open, onClose, eyebrow, title, sub, children, actions,
}
/** 居中模态:只放一两句确认文案 + 两个动作;长表单请用 Drawer */
export function Modal({ open, onClose, title, children, footer, width = 560, closeOnBackdrop = true, label }: {
export function Modal({ open, onClose, eyebrow, title, children, footer, width = 560, closeOnBackdrop = true, label }: {
open: boolean
onClose: () => void
/** 眉标同 Drawer:先说「这是什么动作」,标题只放对象名 */
eyebrow?: ReactNode
title?: ReactNode
children: ReactNode
footer?: ReactNode
@ -105,7 +108,10 @@ export function Modal({ open, onClose, title, children, footer, width = 560, clo
className="w-full max-w-full bg-shell border border-line-strong rounded-float shadow-pop overflow-hidden max-h-[calc(100vh-32px)] flex flex-col">
{title && (
<header className="flex-none flex items-center justify-between gap-3 p-[14px_18px] border-b border-[--c-bg-emphasis] bg-[linear-gradient(120deg,var(--c-bg-raised),var(--c-bg-panel)_55%)]">
<h2 className="text-md font-bold m-0">{title}</h2>
<div className="min-w-0">
{eyebrow && <small className="block text-tiny tracking-[1.6px] text-muted font-bold">{eyebrow}</small>}
<h2 className="text-md font-bold m-0">{title}</h2>
</div>
<button type="button" aria-label="关闭" onClick={onClose}
className="flex-none grid place-items-center w-(--ctl-h-md) h-(--ctl-h-md) border border-line-strong rounded-tile bg-card text-ink-2 text-ui hover:text-accent-bright hover:bg-accent-tint">✕</button>
</header>

File diff suppressed because it is too large Load Diff