= {
'huge:3': 'max-huge:grid-cols-3', 'mid:3': 'max-mid:grid-cols-3', 'mid2:3': 'max-mid2:grid-cols-3',
'nav:2': 'max-nav:grid-cols-2', 'short:2': 'max-short:grid-cols-2', 'mid2:2': 'max-mid2:grid-cols-2',
'tiny:1': 'max-tiny:grid-cols-1', 'narrow:1': 'max-narrow:grid-cols-1', 'short:1': 'max-short:grid-cols-1'
}
export type StatStep = { at: 'huge' | 'mid' | 'mid2' | 'nav' | 'short' | 'tiny' | 'narrow'; cols: 1 | 2 | 3 }
/**
* 指标卡栅格:列数与降列节奏都由容器声明,页面不写 @media。
* 默认沿用旧站 .stats:4 列 → ≤900 两列 → ≤560 收紧间距(卡片本身跟着换小字号内边距)。
* 卡片数不是 4 的页面把节奏写进 steps(用户管理 5 张卡:≤1280 三列、≤820 两列),
* 这样例外是可见的参数,而不是又一段散回样式表、没人敢删的 @media。
*/
export function StatGrid({ children, cols = 4, steps, className }: {
children: ReactNode; cols?: number; steps?: StatStep[]; className?: string
}) {
return (
STEP_CLS[`${st.at}:${st.cols}`]),
'max-narrow:gap-2', className)}
style={{ ['--cols' as string]: cols }}>
{children}
)
}
/** 进度条(.bar / .bar i) */
export function ProgressBar({ value, bad, className }: { value: number; bad?: boolean; className?: string }) {
const pct = Math.max(0, Math.min(100, Number(value) || 0))
return (
)
}
export function Divider({ className }: { className?: string }) {
return
}
export function Empty({ children = '暂无数据', className }: { children?: ReactNode; className?: string }) {
return {children}
}
export function Loading({ children = '读取中…', className }: { children?: ReactNode; className?: string }) {
return {children}
}
export function Spinner({ className }: { className?: string }) {
return
}
/** 提示条:成功用默认(青柠底),错误用 danger;只放一句人话,长说明收进抽屉 */
export function Notice({ children, danger, className, onClose }: {
children: ReactNode; danger?: boolean; className?: string; onClose?: () => void
}) {
if (!children) return null
return (
{children}
{onClose && (
)}
)
}
/** 数据回显(.val)与条件告警(.linehint):规范 §7 G2 —— 版面不放成段解释文字 */
export function Value({ children, muted, className }: { children: ReactNode; muted?: boolean; className?: string }) {
return {children}
}
export function LineHint({ children, className }: { children: ReactNode; className?: string }) {
return {children}
}
/** 等宽小字(路径 / id / 枚举码) */
export function Mono({ children, className, title }: { children: ReactNode; className?: string; title?: string }) {
return {children}
}
/** 文字链(.link):导航用 ,这里只给「打开外部资源 / 下载」 */
export function ExtLink({ href, children, className, download }: { href: string; children: ReactNode; className?: string; download?: boolean | string }) {
return {children}
}
/** 卡片行(.cardrow):标题 + 说明 + 右侧动作,列表里重复项的统一骨架 */
export function CardRow({ title, children, right, className, tone = 'border' }: {
title?: ReactNode; children?: ReactNode; right?: ReactNode; className?: string; tone?: 'border' | 'plain'
}) {
return (
{title &&
{title}
}
{children &&
{children}
}
{right &&
{right}
}
)
}
/** 元信息一行(.meta) */
export function Meta({ children, className }: { children: ReactNode; className?: string }) {
return {children}
}
/** 行内动作组(.actions) */
export function Actions({ children, className }: { children: ReactNode; className?: string }) {
return {children}
}
/** 通用栅格:.grid(4) .grid2 .grid3 .grid4 —— 1fr 轨道配 min-w-0,防止内容把列顶宽 */
export function Grid({ children, cols = 4, gap = 12, className, min = 0 }: {
children: ReactNode; cols?: number | string; gap?: number; className?: string; min?: number
}) {
return (
*]:min-w-0', className)}
style={{ gridTemplateColumns: `repeat(${cols},minmax(${min}px,1fr))`, gap }}>
{children}
)
}