组件层补齐信息块三件套:统计卡配色块、回显改用 Descriptions、卡头不再被压成竖排
症状(用户第 6/7 条:「统计使用的信息块都加入底纹」「大的统计卡片…每个页面逐个优化」
以及 430 档实测):
① 回显有两种假象——灰底圆角盒 + label 在上(长得就是禁用输入框,旁边真输入框
时分不清哪个能填)、只读值外面再套一圈描边 Tag;同一屏「这块是信息」靠脑补。
② 统计卡与页面底色同色,四张并排时先看到四块同色灰、数字反而最弱。
③ 标签把语义色铺成底:满屏「完成 / 已交付 / 合格」各一块浅绿,绿色从语义色
变成第二个品牌色,还把数字压住。
④ 430 档卡头:right 那句「下一步:时间线合成 + 配音/字幕/混音 — …」要 400px+,
而 antd 的卡头是不换行的 flex,标题只剩 15px ⇒「流程进度」一个字一行。
⑤ 768 档 /assets 筛选条:Col 的断点量视口,正文 = 视口 − 侧栏 224 − 内边距 32,
5 等分在 md 给 3 列时每格 158,选中值「全部类型」77px 被裁成 53px。
做法:① 新增 Info(antd Descriptions):label 列降一档字号 + text-tertiary +
--nex-info-label-w 定列宽,值列 overflow-wrap:anywhere;卡内回显挂
nex-info-in-card 去掉双层描边;配套 Value(title) / Count / Clamp 三只小件。
统计卡 Stat = Card + Statistic,识别度交给数字左侧 32px 语义色块
(color-mix 12%,深色档提到 18%),卡面回到 antd 自己的 colorBgContainer。
② 标签底一律中性 fill-tertiary(深色 8%),语义只由头部 6px 圆点承载
(--nex-tag-tint 由 tone 映射到 --ant-color-*);Notice/Alert 保留 antd 语义底。
③ .nex-panel .ant-card-head-wrapper{flex-wrap:wrap} + .ant-card-extra
{flex-shrink:0;max-width:100%}:宽屏同排读完,窄屏整句掉到第二行
(实测 430 标题 292×24、1440 一字未动)。
④ Controls 的 ROW_STEPS 按正文宽整体降一档(5 等分改 ≤1600 四列 / ≤1200 三列 /
≤992 两列 / ≤576 单列),新增 OptionGrid;.nex-ctlbar-grid 里 --nex-ctl-w
让位给列宽,同一行控件右缘必然对齐;新增 colSpans(cols,oneAt,steps) 支持逐档列数。
⑤ Table 补动作列与行高纪律需要的口子;RecordAudio 的麦克风状态条改中性底。
为什么:页面不准 import antd(R8)、.ant-* 只准出现在 styles/app.css、#hex 只准
theme/antd.ts——皮肤集中在这一层,19 个页面才共用同一把尺子;
antd Descriptions 的 span 不跟断点走,所以项里写 span 的回显 column 必须是定值
(已在 §13.1 登记)。色值一律由语义变量比例混合,明暗两档自动跟主题。
main
parent
d65a78ce59
commit
69bd8937ca
|
|
@ -329,7 +329,7 @@ export function RecordAudio({ label = '录制', target = '新版本', disabled =
|
|||
{blocked ? <Segs text={blocked} className="text-error" /> : supported && (
|
||||
<>
|
||||
<p className={cn('m-0 flex flex-wrap items-center gap-2 rounded-lg border px-2 py-1.5 text-xs',
|
||||
micOk ? 'border-success-border bg-success-bg text-success' : 'border-warning-border bg-warning-bg text-warning')}>
|
||||
micOk ? 'border-border-secondary bg-fill-tertiary text-success' : 'border-warning-border bg-warning-bg text-warning')}>
|
||||
<span className="inline-flex min-w-0 items-center gap-1.5 [overflow-wrap:anywhere]">{micOk ? <IconCheck /> : <IconWarn />}{micStatusText}</span>
|
||||
<span className="grow"></span>
|
||||
<TextLink onClick={() => void recheck()}>重新检测</TextLink>
|
||||
|
|
|
|||
|
|
@ -57,19 +57,64 @@ export function Dense({ children, className }: { children: ReactNode; className?
|
|||
* 放不下时才折行(Flex wrap)。字段仍不带下边距(app.css 归零)。
|
||||
* 为什么还给 Ctlbar 而不是新建一只组件:它表达的语义就是「含字段的横条」,
|
||||
* 要改的是「字段这一横条里该长成什么样」,不是多出第八种容器。
|
||||
*
|
||||
* `cols={N}`(2026-11 第七轮):**三个以上同类字段并排时必须是栅格**,不再是 flex-wrap
|
||||
* 自然排列。自然排列下每个 inline 字段按「标签宽 + 控件宽」定尺,标签字数不一样
|
||||
* (状态 / 素材情况 / 排序)盒子就参差,同排控件的右边缘各在一个位置上——
|
||||
* 资产库那条筛选条实测 330 / 170 / 170 / 142 / 177。铺成 Row·Col 之后
|
||||
* 列边界由栅格给,控件列跟着格子伸缩,同排右边缘必然对齐。
|
||||
* 只有「几颗按钮 / 一个字段 + 动作」这种杂项横条才留在自然排列。
|
||||
*/
|
||||
export function Ctlbar({ children, className, as = 'div' }: {
|
||||
export function Ctlbar({ children, className, as = 'div', cols }: {
|
||||
children: ReactNode; className?: string; as?: 'div' | 'nav' | 'section'
|
||||
/** 这一条铺成 N 等分栅格(窄屏按 ROW_STEPS 自动降列);不写=按钮/杂项横条,自然排列 */
|
||||
cols?: 2 | 3 | 4 | 5 | 6
|
||||
}) {
|
||||
return (
|
||||
<Dense className="contents">
|
||||
<Flex component={as} wrap align="center" gap={8} className={cn('nex-ctlbar min-w-0', className)}>
|
||||
{children}
|
||||
</Flex>
|
||||
{cols ? (
|
||||
<Row gutter={[12, 8]} className={cn('nex-ctlbar nex-ctlbar-grid min-w-0', className)}>
|
||||
{toCols(children, colSpans(cols, undefined, ROW_STEPS[cols] || []), 'min-w-0')}
|
||||
</Row>
|
||||
) : (
|
||||
<Flex component={as} wrap align="center" gap={8} className={cn('nex-ctlbar min-w-0', className)}>
|
||||
{children}
|
||||
</Flex>
|
||||
)}
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一组的**可枚举选项**(出片预设、画质档位…)=等宽格子,不是 chip 流。
|
||||
*
|
||||
* 症状:出片预设用 ChipBar,6 个预设宽度 59–168 全凭文案长短,折行点随文案漂移,
|
||||
* 第二行右侧空出一段,读者没法用「第几行第几个」定位,也数不清选了几个。
|
||||
* 做法:选项是有限集合就是栅格——标签在上、每格等宽、胶囊撑满格子,
|
||||
* 选中态(CheckableTag)保持不变,只是坐在格子里。
|
||||
* 与 ChipBar 的分工:**筛已有内容**(标签云、状态快切)用 ChipBar 的胶囊流;
|
||||
* **从一组固定值里挑**(预设 / 档位 / 模板)用 OptionGrid。
|
||||
*/
|
||||
export function OptionGrid({ children, cols = 3, label, className, hint }: {
|
||||
children: ReactNode; cols?: 2 | 3 | 4; label?: ReactNode; className?: string; hint?: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('min-w-0', className)}>
|
||||
{(label || hint) && (
|
||||
<div className="mb-1.5 flex flex-wrap items-baseline justify-between gap-2">
|
||||
{label && <span className={GROUP_LABEL_CLS}>{label}</span>}
|
||||
{hint && <span className={GROUP_LABEL_CLS}>{hint}</span>}
|
||||
</div>
|
||||
)}
|
||||
<Dense className="contents">
|
||||
<Row gutter={[8, 8]} className="min-w-0 nex-opt-grid">
|
||||
{toCols(children, colSpans(cols, undefined, ROW_STEPS[cols] || []), 'min-w-0 nex-opt-cell')}
|
||||
</Row>
|
||||
</Dense>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡片 / 列表行 / 抽屉段落末尾的动作行:横排、换行、间距 8,档位由容器下发(24)。
|
||||
*
|
||||
|
|
@ -210,9 +255,15 @@ export function FormGrid({ children, className }: { children: ReactNode; classNa
|
|||
return <div className={cn('nex-form min-w-0', className)}>{children}</div>
|
||||
}
|
||||
|
||||
/** 每行 N 个字段时的降列节奏:档位名就是 antd Grid 的断点,站内不再有 900/1100 这种私有宽度 */
|
||||
/* 每行 N 个字段时的降列节奏:档位名就是 antd Grid 的断点,站内不再有 900/1100 这种私有宽度。
|
||||
⚠ 档位按**正文宽**取,不是按视口宽:侧栏占 224(≤md 折叠成 64)+ 内容内边距 32,
|
||||
768 视口的正文只有 512。原先 5 等分在 md 档给到 3 列,实测每格 158——
|
||||
「素材类型」的标签 69 之后只剩 69 给下拉,选中值「全部类型」77px 被省略号裁成 53px
|
||||
(visualcheck 768 档 /assets 三条红灯)。整体降一档后 ≤1600 四列、≤1200 三列、
|
||||
≤992 两列、≤576 单列,最窄的一格也有 231px。 */
|
||||
const ROW_STEPS: Record<number, GridStep[]> = {
|
||||
2: [{ at: 'sm', cols: 1 }],
|
||||
5: [{ at: '2xl', cols: 4 }, { at: 'xl', cols: 3 }, { at: 'lg', cols: 2 }, { at: 'sm', cols: 1 }],
|
||||
3: [{ at: 'md', cols: 2 }, { at: 'sm', cols: 1 }],
|
||||
4: [{ at: 'lg', cols: 3 }, { at: 'md', cols: 2 }, { at: 'sm', cols: 1 }],
|
||||
6: [{ at: 'xl', cols: 4 }, { at: 'lg', cols: 3 }, { at: 'md', cols: 2 }, { at: 'sm', cols: 1 }]
|
||||
|
|
|
|||
|
|
@ -17,9 +17,12 @@
|
|||
* (26 处调用),antd Row 是 24 等分栅格,两者不是一个东西;
|
||||
* 这里把 antd 的那对引进来叫 AntRow/AntCol,铺列由本文件的 Layout 负责。
|
||||
*/
|
||||
import type { CSSProperties, ReactNode } from 'react'
|
||||
import { Avatar, Col as AntCol, Divider, Flex, Row as AntRow, Typography } from 'antd'
|
||||
import { type CSSProperties, type ReactNode } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Avatar, Breadcrumb as AntBreadcrumb, Col as AntCol, Divider, Flex, Row as AntRow, Typography } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { ActionGroup } from './Controls'
|
||||
import { Clamp } from './Table'
|
||||
import { Panel } from './Panel'
|
||||
import { splitSpans, type GridCollapse } from './grid'
|
||||
|
||||
|
|
@ -122,23 +125,73 @@ const WRAP_ACTIONS = 'max-lg:w-full max-lg:[&>button]:flex-1'
|
|||
* 标题只有一层中文——旧站在标题上方另加一行全大写英文眉标,切不到英文,
|
||||
* 只是装饰,现在整层删掉(见 UI规范 §1)。
|
||||
*/
|
||||
export function PageHead({ title, meta, actions, className }: {
|
||||
title?: ReactNode; meta?: ReactNode; actions?: ReactNode; className?: string
|
||||
/**
|
||||
* 页头 = 页面身份 + 页面级主操作。
|
||||
*
|
||||
* 口径(2026-11 第四轮 · 用户第 1 条):**内容页的标题和主按钮只在这里出现一次**。
|
||||
* 以前项目子页没有页头,标题写在第一张卡的卡头里(「资产管理」「分镜工作台」),
|
||||
* 主按钮又写在页签条右端或某张卡的卡头右端,读者要在一堆卡头里找那颗主按钮;
|
||||
* 于是同一个动作在两个页面分别位于「页签右侧 / 卡头右侧 / 表单末尾」三处。
|
||||
* 分工(写进 UI规范 §2):
|
||||
* PageHead 只放**整页成立**的动作(新建、入队、批量放行、开始导出);
|
||||
* PanelHead 只放**离开这一块就不成立**的动作(某张表的导出、某个表单的保存);
|
||||
* Tabs 的右端不再放按钮(页签是「看哪一份」,按钮是「做一件事」,两者同排必然打架)。
|
||||
* sub:一句话说明这一页的职责,替代以前写在卡头里的长段说明文字。
|
||||
* 宽度限 72ch:整屏宽的次要说明在 2560 上会拉成一条读不回行的横线。
|
||||
*/
|
||||
export function PageHead({ title, sub, meta, actions, className }: {
|
||||
title?: ReactNode
|
||||
/** 标题下方的一句话职责说明(12px 次要色) */
|
||||
sub?: ReactNode
|
||||
/** 标题上方一行:返回链接 / 只读状态(渲染在标题之前) */
|
||||
meta?: ReactNode
|
||||
actions?: ReactNode
|
||||
className?: string
|
||||
}) {
|
||||
return (
|
||||
<Flex component="header" wrap justify="space-between" align="center" gap={12}
|
||||
className={cn('mb-6 min-w-0 max-lg:items-start', className)}>
|
||||
<Flex vertical gap={6} className="min-w-0 max-lg:w-full">
|
||||
className={cn('mb-5 min-w-0 max-lg:items-start', className)}>
|
||||
<Flex vertical gap={4} className="min-w-0 max-lg:w-full">
|
||||
{meta && <Row className={WRAP_ACTIONS}>{meta}</Row>}
|
||||
{title && (
|
||||
<Typography.Title level={3} className="!mb-0 !min-w-0">{title}</Typography.Title>
|
||||
)}
|
||||
{sub && (
|
||||
<Typography.Text type="secondary"
|
||||
className="!mb-0 block max-w-[72ch] text-xs leading-relaxed">{sub}</Typography.Text>
|
||||
)}
|
||||
</Flex>
|
||||
{actions && <Row className={WRAP_ACTIONS}>{actions}</Row>}
|
||||
{actions && <ActionGroup className={WRAP_ACTIONS}>{actions}</ActionGroup>}
|
||||
</Flex>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 面包屑 = antd Breadcrumb(层级导航的唯一实现)。
|
||||
*
|
||||
* 症状:项目子页顶部写着「← 项目总览 + 状态 Tag + 当前节点 Tag」,
|
||||
* 这三样在应用顶栏的流程控制台里全都有,等于同屏两遍项目信息。
|
||||
* 做法:外壳只留一条面包屑(项目总览 / 项目名)表达「我在哪个项目里」,
|
||||
* 状态、进度、当前节点交给顶栏那一条,页面不再重复。
|
||||
* 为什么 items 收字符串/对象而不是 ReactNode:页面不能 import antd(规范 R8),
|
||||
* 跳转由组件内部 useNavigate 完成,页面只给 { label, to }。
|
||||
*/
|
||||
export function Breadcrumb({ items, className }: {
|
||||
items: { label: ReactNode; to?: string }[]
|
||||
className?: string
|
||||
}) {
|
||||
const navigate = useNavigate()
|
||||
return (
|
||||
<AntBreadcrumb className={cn('min-w-0', className)}
|
||||
items={items.map((it) => ({
|
||||
key: String(it.to ?? it.label),
|
||||
title: it.to
|
||||
? <a onClick={(e) => { e.preventDefault(); navigate(it.to!) }}>{it.label}</a>
|
||||
: <span className="min-w-0 truncate">{it.label}</span>
|
||||
}))} />
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面级工具条 = **只有卡头的那张 Card**(antd Card title + extra)。
|
||||
*
|
||||
|
|
@ -195,11 +248,17 @@ export function Between({ children, className, tight }: { children?: ReactNode;
|
|||
}
|
||||
|
||||
/** 行内错误回显(.error):12px 红字,紧贴它说明的那个控件,不占提示条的位置 */
|
||||
export function ErrorText({ children, className }: { children?: ReactNode; className?: string }) {
|
||||
export function ErrorText({ children, className, lines, title }: {
|
||||
children?: ReactNode; className?: string
|
||||
/** 表格单元格里必须给(R17 表格行高纪律):一条 60 字的报错能把整行顶到 100px 以上 */
|
||||
lines?: 1 | 2
|
||||
/** 配合 lines 的悬停全文:传拼接好的纯文本 */
|
||||
title?: string
|
||||
}) {
|
||||
if (!children) return null
|
||||
return (
|
||||
<Typography.Text type="danger" className={cn('!mt-1 block !text-xs [overflow-wrap:anywhere]', className)}>
|
||||
{children}
|
||||
{lines ? <Clamp lines={lines} title={title}>{children}</Clamp> : children}
|
||||
</Typography.Text>
|
||||
)
|
||||
}
|
||||
|
|
@ -220,7 +279,7 @@ export function Sub({ children, className }: { children?: ReactNode; className?:
|
|||
* 页签只存在于页面内部(kit 的 <Tabs>),这一层就是普通的正文纵排。
|
||||
*/
|
||||
export function PageStack({ children, className }: { children?: ReactNode; className?: string }) {
|
||||
return <Flex vertical gap={16} className={cn('min-w-0', className)}>{children}</Flex>
|
||||
return <Flex vertical gap={16} className={cn('nex-stack min-w-0', className)}>{children}</Flex>
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
* 卡头没有分隔线、指标卡数字与 antd 的 Statistic 差 6px、栅格按私有断点降列。
|
||||
* 做法:**布局也交给 antd**。Panel=Card(卡头用 Card 自己的 title/extra)、
|
||||
* Stat=Card+Statistic、Grid/StatGrid=Row+Col(断点用 antd Grid 的 xs…xxl)、
|
||||
* Info=Descriptions(只读回显:标签列 + 值列,替代「灰盒 + 标签在上」那种假输入框)、
|
||||
* Notice=Alert、Empty=Empty、ProgressBar=Progress、Divider=Divider。
|
||||
* 页面继续写 <Panel><PanelHead …/>正文</Panel>:Panel 会把作为第一个子节点的
|
||||
* PanelHead **吞进 Card 的 title/extra**,所以 52 处调用一行不用改,
|
||||
|
|
@ -17,7 +18,7 @@
|
|||
*/
|
||||
import { Children, isValidElement, type CSSProperties, type ReactNode } from 'react'
|
||||
import {
|
||||
Alert, Card, Divider as AntDivider, Empty as AntEmpty, Flex,
|
||||
Alert, Card, Descriptions, Divider as AntDivider, Empty as AntEmpty, Flex,
|
||||
Progress, Row, Spin, Statistic, Typography
|
||||
} from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
|
@ -140,6 +141,10 @@ export function SectionTitle({ children, action, className, title }: {
|
|||
* 病灶:同一个统计数字长出过三套皮肤——概览/仪表盘用自绘卡、资产库自己写了
|
||||
* 一张带渐变的 MetricCard、分镜顶栏又写了一套更小的 Metric。
|
||||
* 做法:数字与标题的度量交还 antd(.ant-statistic 的 title 14 / content 24)。
|
||||
* 2026-11 第六轮(用户第 2 条):**卡面不再有任何底纹**。上一轮压在卡面上的
|
||||
* 径向渐晕 + 135° 斜纹 + 84px 水印,四张并排时连成一片脏灰,数字反而不显眼;
|
||||
* 识别度改由数字左侧那只 32px 色块承担(底色与图形同取本卡语义色,见 app.css
|
||||
* `.nex-stat-mark`)——「配套的色块和图标」就是它的唯一装饰。
|
||||
* 2026-11 整删 inline 档:sticky 工具条里的「一列小数字」只活过分镜顶栏一处,
|
||||
* 它和同一排里的 antd 按钮高度打架,现在那一排改用 <Toolbar> 的一行摘要。
|
||||
* 指标数字从此只有 card 一种皮肤(栅格用 StatGrid)。
|
||||
|
|
@ -153,18 +158,30 @@ const STAT_TONE: Record<StatTone, string> = {
|
|||
warn: 'var(--ant-color-warning)', bad: 'var(--ant-color-error)'
|
||||
}
|
||||
|
||||
export function Stat({ label, value, hint, className, style, tone, active, onClick, title, valueSize = 'num' }: {
|
||||
export function Stat({ label, value, hint, className, style, tone, active, onClick, title, icon, valueSize = 'num' }: {
|
||||
label: ReactNode; value: ReactNode; hint?: ReactNode; className?: string; style?: CSSProperties
|
||||
/**
|
||||
* 这一张卡的语义色:数值、左侧色块、色块底三处同源。
|
||||
* 不写 = 主色;ok/warn/bad = antd 对应的语义色族(app.css `.nex-stat`)。
|
||||
*/
|
||||
tone?: StatTone
|
||||
/** 命中当前筛选:点亮描边 + 标题 */
|
||||
active?: boolean
|
||||
/** 整张卡是筛选入口 */
|
||||
onClick?: () => void
|
||||
title?: string
|
||||
/**
|
||||
* 识别图形(R16.2 改口径):渲染成数字左侧那只 32px 色块里的图标,
|
||||
* 「这格数的是镜头 / 任务 / 成本」先由图形说一遍,读者扫一眼就定位到要的卡。
|
||||
* 必须是 components/icons 登记表里的图形(规范 §11);不传就没有色块,正文满宽。
|
||||
*/
|
||||
icon?: ReactNode
|
||||
/** `num`(默认)=纯数字;`title`=放的是一段名字(模型控制台的「当前默认大模型」) */
|
||||
valueSize?: 'num' | 'title'
|
||||
}) {
|
||||
const color = tone ? STAT_TONE[tone] : undefined
|
||||
/* 色块主色:没有 tone 的统计卡用主色,有 tone 的用同一条语义色(数值 / 色块 / 色块底同源) */
|
||||
const tint = tone ? STAT_TONE[tone] : 'var(--ant-color-primary)'
|
||||
const labelNode = <span title={title}>{label}</span>
|
||||
/* value 里的 <i> 是「次要的一半」(9<i>/47</i> 里的分母、/ 未设置),样式只在这里定义一次 */
|
||||
const valueStyle: CSSProperties = {
|
||||
|
|
@ -191,14 +208,23 @@ export function Stat({ label, value, hint, className, style, tone, active, onCli
|
|||
formatter={isText ? undefined : () => value} valueStyle={valueStyle} />
|
||||
)
|
||||
return (
|
||||
<Card hoverable={!!onClick} onClick={onClick} className={cn('nex-stat min-w-0 bg-fill-tertiary', onClick && 'nex-stat-click', className)}
|
||||
/* active 是「这张卡被选中」,选择态用主色描边;success 只留给数字本身表示 ok(STAT_TONE.ok)。 */
|
||||
style={active ? { ...style, borderColor: 'var(--ant-color-primary-border)' } : style}
|
||||
styles={{ body: { padding: 20 } }}>
|
||||
{stat}
|
||||
{hint && (
|
||||
<Typography.Text type="secondary" className="!mt-2 block !text-xs leading-snug">{hint}</Typography.Text>
|
||||
)}
|
||||
<Card hoverable={!!onClick} onClick={onClick} className={cn('nex-stat min-w-0', onClick && 'nex-stat-click', className)}
|
||||
/* active 是「这张卡被选中」,选择态用主色描边;success 只留给数字本身表示 ok(STAT_TONE.ok)。
|
||||
--nex-stat-tint 只交给 app.css 上色块(.nex-stat-mark),卡面本身是 antd 的 colorBgContainer。 */
|
||||
style={{ ...(style || {}), ['--nex-stat-tint' as string]: tint,
|
||||
...(active ? { borderColor: 'var(--ant-color-primary-border)' } : {}) }}
|
||||
styles={{ body: { padding: 16 } }}>
|
||||
{/* 色块与正文并排:色块顶对齐标题(它标的是「这一格是什么」,不是数字),
|
||||
说明文字缩进到正文列里,不许钻到色块底下。 */}
|
||||
<Flex align="flex-start" gap={12} className="min-w-0">
|
||||
{icon ? <span className="nex-stat-mark" aria-hidden>{icon}</span> : null}
|
||||
<div className="min-w-0 flex-1">
|
||||
{stat}
|
||||
{hint && (
|
||||
<Typography.Text type="secondary" className="!mt-1.5 block !text-xs leading-snug">{hint}</Typography.Text>
|
||||
)}
|
||||
</div>
|
||||
</Flex>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
|
@ -226,14 +252,27 @@ export function Grid({ children, cols = 4, gap = 12, min, oneAt, steps, classNam
|
|||
}
|
||||
|
||||
/**
|
||||
* 指标卡栅格:列数与降列节奏都由容器声明,页面不写 @media。
|
||||
* 默认 4 列 → ≤992 两列 → ≤576 一列(antd 断点,不再用私有的 900/560)。
|
||||
* 指标卡栅格:**列数默认等于实际卡片数**(第 2 条「不同页面不需要固定的统计卡片数量」)。
|
||||
*
|
||||
* 症状:`cols` 以前固定 4,页面只有三张卡时右边空出一格,五张卡时第五张孤零零掉到
|
||||
* 第二行——同一站内的指标区因此有三种「数不完的最后一片空白」。
|
||||
* 做法:不写 cols 就按子节点数排布(除不尽 24 的列数由 grid.tsx 的 colSpans 转成
|
||||
* flex 百分比,五张卡就是五等分一行),最多 6 列,超出的自己折行;
|
||||
* 卡片在窄屏按比例降列(≤992 两列 → ≤576 一列)。
|
||||
* 为什么要保留 cols 参数:侧栏里的指标区(导出与成本那张半宽卡)必须写死 2 列——
|
||||
* 那里满屏断点量出来的是视口宽度,不是容器宽度。
|
||||
*/
|
||||
export function StatGrid({ children, cols = 4, steps, className, gap = 12 }: {
|
||||
export function StatGrid({ children, cols, steps, className, gap = 12 }: {
|
||||
children: ReactNode; cols?: number; steps?: StatStep[]; className?: string; gap?: number
|
||||
}) {
|
||||
const count = Children.toArray(children).filter(Boolean).length
|
||||
const merged: StatStep[] = steps || [{ at: 'lg', cols: 2 }, { at: 'sm', cols: 1 }]
|
||||
return <Grid cols={cols} steps={merged} gap={gap} className={className}>{children}</Grid>
|
||||
/* 同排统计卡必须等高:卡片自己 120、旁边那张因为多一行说明 136,
|
||||
一排四种底边就是肉眼可见的参差(第 4 轮体检 /models 实测)。 */
|
||||
return (
|
||||
<Grid cols={cols ?? Math.min(Math.max(count, 1), 6)} steps={merged} gap={gap}
|
||||
className={cn('[&>.ant-col>*]:h-full', className)}>{children}</Grid>
|
||||
)
|
||||
}
|
||||
|
||||
/** 进度条:antd Progress(站内只有这一条;bad=异常态用 antd 的 exception 色) */
|
||||
|
|
@ -303,9 +342,13 @@ export function Notice({ children, description, danger, className, onClose, type
|
|||
}
|
||||
|
||||
/** 数据回显(.val)与条件告警(.linehint):规范 §7 G2 —— 版面不放成段解释文字 */
|
||||
export function Value({ children, muted, className }: { children: ReactNode; muted?: boolean; className?: string }) {
|
||||
export function Value({ children, muted, className, title }: {
|
||||
children: ReactNode; muted?: boolean; className?: string
|
||||
/** 悬浮说明:口径 / 数据来源这种「不该占版面但读者会问」的第二层,走原生 title(G2) */
|
||||
title?: string
|
||||
}) {
|
||||
return (
|
||||
<Typography.Text
|
||||
<Typography.Text title={title}
|
||||
className={cn('!text-xs leading-relaxed wrap-anywhere', muted ? '!text-text-quaternary' : '!text-text-tertiary', className)}
|
||||
type={muted ? undefined : 'secondary'}>{children}</Typography.Text>
|
||||
)
|
||||
|
|
@ -354,7 +397,10 @@ export function ExtLink({ href, children, className, download }: {
|
|||
export const BLOCK_TONE: Record<'default' | 'info' | 'ok' | 'warn' | 'bad', string> = {
|
||||
default: 'border-border-secondary bg-fill-tertiary',
|
||||
info: 'border-info-border bg-info-bg',
|
||||
ok: 'border-success-border bg-success-bg',
|
||||
/* 「ok」这类信息块以前铺 antd 的 success 浅绿底——第 4 轮用户点名「浅绿色标签全部
|
||||
换到新的颜色设计」。新口径与 <Tag tone="ok"> 一致:中性底纹 + 语义描边,
|
||||
绿色只作为「这条信息是好消息」的线索,不再当大面积底色用。 */
|
||||
ok: 'border-success-border bg-fill-tertiary',
|
||||
warn: 'border-warning-border bg-warning-bg',
|
||||
bad: 'border-error-border bg-error-bg'
|
||||
}
|
||||
|
|
@ -380,6 +426,101 @@ export function Block({ children, tone = 'default', align = 'center', vertical,
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 只读回显(.nex-info)= antd Descriptions:**站内所有「这条记录长什么样」的
|
||||
* 属性回显只有这一种写法**(规范 R16.3)。
|
||||
*
|
||||
* 症状(用户截图指的那类块,原话「这种设计都是有问题的」):回显写成
|
||||
* `Block tone=default vertical` 的灰盒——label 在上、值在下、四周描边,
|
||||
* 和它旁边真正的输入框长得一模一样;用户去找可点的框,框里却没有可改的东西。
|
||||
* 同一屏里另一批回显写成「label:值」的裸文本行,两种读法各占一半。
|
||||
* 做法:一律 Descriptions(bordered + size=small + colon=false):
|
||||
* label 列由 antd 上 colorFillAlter 底纹(底纹来自语义色,不新增色值),
|
||||
* 值列左对齐长值折行,多属性并排走 column 分栏——一屏放得下的绝不多占一行。
|
||||
* 为什么不用灰盒:灰盒在 antd 语言里是「输入区的底色」,回显用它是借错了语义;
|
||||
* Descriptions 就是 antd 为「详情回显」准备的组件,明暗两档、圆角、分隔线
|
||||
* 全都跟主题走,不需要再养一套私有皮肤(度量集中在 app.css `.nex-info`)。
|
||||
*/
|
||||
export type InfoItem = {
|
||||
key?: string
|
||||
label: ReactNode
|
||||
value: ReactNode
|
||||
/** 等宽回显(路径 / id / 枚举码 / 密钥),走 kit 的 Mono */
|
||||
mono?: boolean
|
||||
/** 跨几列(与 antd Descriptions 的 span 同名同义):长地址、一段说明用 span 顶满 */
|
||||
span?: number
|
||||
}
|
||||
|
||||
/** 分栏数:固定几列,或按断点降列(窄屏/抽屉里 3 列会挤成竖排,交给 antd 自己降) */
|
||||
export type InfoColumns = number | Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', number>>
|
||||
|
||||
const INFO_BP: ('xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl')[] = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']
|
||||
|
||||
/**
|
||||
* 档位向上补齐:写到的那一档=它右边所有档的值。
|
||||
*
|
||||
* 症状:antd Descriptions 内部把 column 与内置 {xs:1,sm:2,md:3,lg:3,xl:3,xxl:3} 合并,
|
||||
* 再由宽到窄取第一个命中的档位。于是只写 `{ xs: 2, sm: 3, lg: 5 }` 的回显,
|
||||
* 1440 命中的是内置的 xl=3——**声明的 5 列在桌面上永远不生效**;
|
||||
* 卡片里的 `{ xs: 1, sm: 2 }` 同理,宽屏变成没声明过的 3 列,挤成竖排。
|
||||
* 做法:把没写的右档填成最近一次声明的值,页面只需要写「从哪一档开始降到几列」。
|
||||
* 为什么在容器补:12 个页面写的都是「窄屏少列、宽屏多列」这一个意图,
|
||||
* 让每个页面记住 antd 的默认表并要求它写满六档,是规范在给自己找麻烦。
|
||||
*/
|
||||
export function fillInfoColumns(column: InfoColumns): InfoColumns {
|
||||
if (typeof column === 'number') return column
|
||||
const out: Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', number>> = { ...column }
|
||||
let last: number | undefined
|
||||
INFO_BP.forEach((bp) => {
|
||||
if (out[bp] !== undefined) last = out[bp]
|
||||
else if (last !== undefined) out[bp] = last
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
export function Info({ items, column = 1, className, title, extra }: {
|
||||
items: (InfoItem | null | undefined | false)[]
|
||||
column?: InfoColumns
|
||||
className?: string
|
||||
/** 这一组回显的标题(antd Descriptions 的 title,走主题字号,不用页面自己写 h4) */
|
||||
title?: ReactNode
|
||||
/** 标题行右端动作(antd 5.29 Descriptions.extra):与标题同一行,不再另起一排 */
|
||||
extra?: ReactNode
|
||||
}) {
|
||||
const real = items.filter(Boolean) as InfoItem[]
|
||||
if (!real.length) return null
|
||||
return (
|
||||
<Descriptions className={cn('nex-info', className)} size="small" bordered colon={false}
|
||||
column={fillInfoColumns(column)} title={title} extra={extra}
|
||||
items={real.map((it, i) => ({
|
||||
key: it.key ?? String(i), label: it.label, span: it.span,
|
||||
children: it.mono ? <Mono className="wrap-anywhere">{it.value}</Mono> : it.value
|
||||
}))} />
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Info 里的计数值(.nex-info 的 number 档):等宽数字 + 可选单位。
|
||||
*
|
||||
* 症状:回显表里的 0 和 3 一样粗一样亮,一屏八个数字读不出哪个要管;
|
||||
* 这套「非零才上语义色」的口径原先写在调度中心页面里(局部函数 cnt),
|
||||
* 质检页要做同一个块只能再抄一遍——规范 §13.1 要求口径只有一份。
|
||||
* 做法:0 一律降到 colorTextTertiary(「没有要处理的」),非零才按 tone 上
|
||||
* success / warning / error;单位(条 / 次)比数字小一档、跟着降灰。
|
||||
* 为什么是组件不是常量函数:它出现在 12 个页面的 items 里,JSX 写法与 Info 一致。
|
||||
*/
|
||||
const COUNT_TONE: Record<'ok' | 'warn' | 'bad', string> = { ok: 'text-success', warn: 'text-warning', bad: 'text-error' }
|
||||
|
||||
export function Count({ n, unit, tone }: { n?: number; unit?: string; tone?: 'ok' | 'warn' | 'bad' }) {
|
||||
const num = Number(n) || 0
|
||||
return (
|
||||
<span className={`font-mono text-xs font-semibold ${num ? (tone ? COUNT_TONE[tone] : '') : 'text-text-tertiary'}`}>
|
||||
{num}
|
||||
{unit ? <span className="ml-0.5 text-xs font-normal text-text-tertiary">{unit}</span> : null}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡片行(.cardrow):标题 + 说明 + 右侧动作,列表里重复项的统一骨架。
|
||||
*
|
||||
|
|
|
|||
|
|
@ -20,9 +20,24 @@ export type TagSize = 'sm' | 'md'
|
|||
export const TAG_DENSE = 'nex-tag-dense'
|
||||
|
||||
/**
|
||||
* 语义色调:一一对应 antd 的四个语义色(success / error / warning / info + colorPrimary),
|
||||
* 每一档取「底纹 -bg / 描边 -border / 文字」三个 token,页面不许自己上色。
|
||||
* 语义色调:一一对应 antd 的四个语义色(success / error / warning / info + colorPrimary)。
|
||||
* 旧规范里的 pink / sky 没有任何调用点,跟着 palette.ts 一起删了。
|
||||
*
|
||||
* 2026-11 第七轮 · 用户「项目中的浅绿色标签都要处理到新的颜色设计上」:
|
||||
* 症状:整站的「完成 / 已交付 / 合格 / 已启用」标签铺满 antd 的 success 浅绿底
|
||||
* (light #f6ffed 底 / #52c41a 字)。项目列表 12 行里有 9 行是绿块,
|
||||
* 质检页一排六个计数也是绿块——绿色本来是「成功」的语义,量一大就变成
|
||||
* 整屏的品牌残留色,和新主色(antd 出厂蓝)打架,也把真正要看的数字压住了。
|
||||
* 做法:**标签不再用语义色铺底**。底色全站只有一档中性 fill-tertiary(= antd
|
||||
* 自己 Tag bordered=false 的默认底),文字用正文色,语义只留在**标签头部
|
||||
* 那颗 6px 圆点**上(Linear / GitHub / Vercel 的状态点同一套读法):
|
||||
* 扫表时靠点的颜色分「绿=完成 / 红=失败 / 橙=需注意 / 蓝=进行中」,
|
||||
* 面积上不再有任何彩色块。
|
||||
* 为什么语义底块(<Block> / Alert 那类整段提示)不改:那是 antd Alert 的语义,
|
||||
* 一条屏最多一个,铺底是它表达「这是一条通知」的方式;标签是行内小构件,
|
||||
* 一屏十几个,只能靠点。
|
||||
* 上色口径不变:色值仍只有 `--ant-color-<语义>` 一个来源(CSS 变量在 app.css
|
||||
* `.nex-tag-dot`),页面依旧不准自己写颜色。
|
||||
*/
|
||||
export type TagTone = 'default' | 'ok' | 'bad' | 'warn' | 'info' | 'accent' | 'mono'
|
||||
|
||||
|
|
@ -40,14 +55,15 @@ export function Tag({ tone = 'default', size = 'md', icon, children, className,
|
|||
title?: string
|
||||
}) {
|
||||
const v = TONE_VARS[tone as keyof typeof TONE_VARS]
|
||||
// 默认档也要有底纹:统计信息块「有底」才读得出「这是一块回显」而不是一个待点的按钮;
|
||||
// 语义色档走各自的 -bg / -border,两层互不影响(Tag 与 Badge 同一套尺子)。
|
||||
const style = v
|
||||
? { background: `var(--ant-color-${v}-bg)`, borderColor: `var(--ant-color-${v}-border)`, color: `var(--ant-color-${v})` }
|
||||
: { background: 'var(--ant-color-fill-tertiary)', borderColor: 'var(--ant-color-border-secondary)' }
|
||||
// 只读标签一律无边框(R16.3):底纹负责「这是一块回显」,描边负责「这可以点」,
|
||||
// 两者不能同时出现在一个不能点的东西上。
|
||||
// 语义档只把颜色交给 --nex-tag-tint,由 .nex-tag-dot 上的一点承载(见上面的口径注释)。
|
||||
const style = v ? { ['--nex-tag-tint' as string]: `var(--ant-color-${v})` } : undefined
|
||||
return (
|
||||
<AntTag title={title} className={cn('nex-tag', size === 'sm' && 'nex-tag-solo-sm', tone === 'mono' && 'font-mono')}
|
||||
style={style} bordered>
|
||||
<AntTag title={title} className={cn('nex-tag', v && 'nex-tag-tint',
|
||||
size === 'sm' && 'nex-tag-solo-sm', tone === 'mono' && 'font-mono')}
|
||||
style={style} bordered={false}>
|
||||
{v ? <span className="nex-tag-dot" aria-hidden /> : null}
|
||||
{icon && <span className="nex-tag-icon" aria-hidden>{icon}</span>}
|
||||
{children}
|
||||
</AntTag>
|
||||
|
|
@ -97,13 +113,11 @@ export function Badge({ children, tone = 'default', size = 'md', className }: {
|
|||
className?: string
|
||||
}) {
|
||||
const v = TONE_VARS[tone as keyof typeof TONE_VARS]
|
||||
// 默认档也要有底纹:统计信息块「有底」才读得出「这是一块回显」而不是一个待点的按钮;
|
||||
// 语义色档走各自的 -bg / -border,两层互不影响(Tag 与 Badge 同一套尺子)。
|
||||
const style = v
|
||||
? { background: `var(--ant-color-${v}-bg)`, borderColor: `var(--ant-color-${v}-border)`, color: `var(--ant-color-${v})` }
|
||||
: { background: 'var(--ant-color-fill-tertiary)', borderColor: 'var(--ant-color-border-secondary)' }
|
||||
// 数字气泡与标签同一套皮肤:中性底 + 语义色只给文字(计数本身就是要读的东西,
|
||||
// 不再补一颗点,否则「12」前面多个圆点会被读成状态)。
|
||||
const style = v ? { color: `var(--ant-color-${v})` } : undefined
|
||||
return (
|
||||
<AntTag className={cn('nex-tag nex-badge', size === 'sm' && 'nex-tag-solo-sm', className)} style={style} bordered>
|
||||
<AntTag className={cn('nex-tag nex-badge', size === 'sm' && 'nex-tag-solo-sm', className)} style={style} bordered={false}>
|
||||
{children}
|
||||
</AntTag>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ export function nodeHint(node: any): string {
|
|||
}
|
||||
|
||||
/* 序号圆点的填色:实心主色 + 白字(4.6:1)成立,实心 success + 白字不成立
|
||||
(light #52c41a / white = 2.3:1,dark #95de64 / white = 1.8:1),
|
||||
所以「完成」这一档取绿色族的浅底 + 主色字——正是 antd Tag color="success"
|
||||
与站内 <Tag tone="ok"> 用的那三个 token,不新造档位。
|
||||
(light #52c41a / white = 2.3:1,dark #95de64 / white = 1.8:1)。
|
||||
2026-11 第七轮:「完成」这一档也不再铺 success 浅底——用户要求全站的浅绿标签
|
||||
收进新配色,12 格的流程条如果每格底上都是一块浅绿,等于把这条 rail 刷回旧品牌。
|
||||
现在底是中性 fill-secondary,绿只留给**对勾本身与 done/total 的数字**(字形级着色,
|
||||
和 <Tag tone="ok"> 的「中性底 + 语义点」是同一条规矩)。
|
||||
「进行中」是实心主色(antd 的 processing 就是主色蓝),和完成一眼分得开。
|
||||
|
||||
整卡的底色口径(2026-11 第四轮改的,别再改回「完成=整块绿」):
|
||||
|
|
@ -50,7 +52,7 @@ export function nodeHint(node: any): string {
|
|||
· **failed** = 容器底 + 红边;**pending** = 容器底 + 更淡的边 + 70% 不透明度。
|
||||
「完成了多少」由一串绿勾 + 下面的 `FlowCaption`(已完成 x / y)负责,不靠铺面积。 */
|
||||
const NUM: Record<string, string> = {
|
||||
done: 'bg-success-bg text-success',
|
||||
done: 'bg-fill-secondary text-success',
|
||||
active: 'bg-primary text-on-primary',
|
||||
failed: 'bg-error text-error-bg',
|
||||
pending: 'bg-fill-secondary text-text-tertiary'
|
||||
|
|
|
|||
|
|
@ -33,9 +33,41 @@ export type Columns<T> = NonNullable<TableProps<T>['columns']>
|
|||
/**
|
||||
* 长文本列:允许折行而不是把整张表顶宽(旧 cellWrap)。
|
||||
* 用法是 column.className——antd 会把它落到该列的每个单元格上。
|
||||
*
|
||||
* 但它只解决「不顶宽表格」,不解决「不撑高行」:一句 90 字的质检结论
|
||||
* 在 464px 的列里仍要折 7 行,整张表一屏只剩 4 行可读。封顶交给 <Clamp>。
|
||||
*/
|
||||
export const cellWrap = 'max-w-[340px] whitespace-normal leading-normal wrap-anywhere'
|
||||
|
||||
/**
|
||||
* 单元格里读不完的长文案:最多折两行,剩下的收进原生 title。
|
||||
*
|
||||
* 症状(第 27 轮全站表格体检):审核留痕「说明」464px 被一条质检长文顶到 255px 行高,
|
||||
* 调度清单「说明」只剩 112px 时同一句话折成 8 行(行高 168px)——
|
||||
* 列宽和文案长度是两头堵,只调列宽永远调不完。
|
||||
* 做法:列宽先按「长文列 ≥ 200px」分配,文案本身用本组件封顶两行,
|
||||
* 完整内容挂原生 title,悬停看全。
|
||||
* 为什么不用 antd 的 column.ellipsis:它只支持单行,长说明折成一行等于没显示;
|
||||
* 也不为这一点事再包一层 Tooltip(R8:页面不 import antd,包组件要给全站用才值)。
|
||||
*/
|
||||
export function Clamp({ children, title, lines = 2, className }: {
|
||||
children?: ReactNode
|
||||
/** 悬停看全文:传拼接好的纯文本(组件猜不到调用方拼了什么) */
|
||||
title?: string
|
||||
/** 封顶行数:1 = 单行省略(标题类),2 = 两行省略(说明/错误类) */
|
||||
lines?: 1 | 2
|
||||
className?: string
|
||||
}) {
|
||||
if (children === null || children === undefined || children === '') return null
|
||||
return (
|
||||
<div title={title}
|
||||
className={cn('whitespace-normal leading-normal wrap-anywhere',
|
||||
lines === 1 ? 'line-clamp-1' : 'line-clamp-2', className)}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
type TableExtra<T> = {
|
||||
/** 列定义(antd Columns) */
|
||||
columns: Columns<T>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
* 为什么单独一个文件:Panel(Grid/StatGrid)、Page(Layout/Stack)、Controls
|
||||
* (FormRow)都要铺列,共用一份换算才不会三处三种降列节奏。
|
||||
*/
|
||||
import { Children, type ReactNode } from 'react'
|
||||
import { Children, Fragment, isValidElement, type ReactNode } from 'react'
|
||||
import { Col } from 'antd'
|
||||
|
||||
export type Bp = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
|
||||
|
|
@ -25,28 +25,46 @@ export type GridStep = { at: GridCollapse; cols: number }
|
|||
/** 指标卡的降列档位与通用栅格同一套 */
|
||||
export type StatStep = GridStep
|
||||
|
||||
/** 列数 + 降列档位 → antd Col 的六个断点值 */
|
||||
export function colSpans(cols: number, oneAt?: GridCollapse, steps?: GridStep[]): Partial<Record<Bp, number>> {
|
||||
const base = Math.max(1, Math.round(24 / Math.max(1, cols)))
|
||||
const out: Partial<Record<Bp, number>> = {}
|
||||
BP_ORDER.forEach((bp) => { out[bp] = base })
|
||||
/**
|
||||
* 一个断点上怎么铺:能整除 24 就照旧给 span(和站内其它栅格同一把尺子);
|
||||
* 除不尽(5 张统计卡这种「一行就得放完」的)必须改用百分比 flex——
|
||||
* span 只能取整数,24/5 取整成 5,5×5=25 > 24,第 5 张会被整张挤到下一行,
|
||||
* 页面就多出一个孤零零的半行(用户说的「能一行放完的别分两行」正是这一枪)。
|
||||
*/
|
||||
export type ColAt = { span?: number; flex?: string }
|
||||
|
||||
/** 列数 → antd Col 的六个断点值(值可以是 span 数,也可以是 flex 声明) */
|
||||
export function colSpans(cols: number, oneAt?: GridCollapse, steps?: GridStep[]): Record<Bp, ColAt> {
|
||||
const at = (n: number): ColAt => {
|
||||
const c = Math.max(1, Math.min(24, Math.round(n)))
|
||||
const span = 24 / c
|
||||
return Number.isInteger(span) ? { span } : { flex: `0 0 ${(100 / c).toFixed(4)}%` }
|
||||
}
|
||||
const out = {} as Record<Bp, ColAt>
|
||||
BP_ORDER.forEach((bp) => { out[bp] = at(cols) })
|
||||
const rules = [
|
||||
...(steps || []).map((s) => ({ at: s.at as string, cols: s.cols as number })),
|
||||
...(oneAt ? [{ at: oneAt as string, cols: 1 }] : [])
|
||||
].sort((a, b) => (AT_MIN[b.at] ?? 0) - (AT_MIN[a.at] ?? 0)) // 由宽到窄,窄档后覆盖
|
||||
for (const r of rules) {
|
||||
const limit = AT_MIN[r.at] ?? 0
|
||||
const span = Math.max(1, Math.round(24 / r.cols))
|
||||
BP_ORDER.forEach((bp) => { if (BP_MIN[bp] < limit) out[bp] = span })
|
||||
BP_ORDER.forEach((bp) => { if (BP_MIN[bp] < limit) out[bp] = at(r.cols) })
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** 把 N 个子节点铺进一行栅格(Grid / StatGrid / FormRow / Layout / Stack 共用) */
|
||||
export function toCols(children: ReactNode, spans: Partial<Record<Bp, number>>, colClass?: string): ReactNode[] {
|
||||
return Children.toArray(children).map((child, i) => (
|
||||
<Col key={i} className={colClass} {...spans}>{child}</Col>
|
||||
))
|
||||
export function toCols(children: ReactNode, spans: Record<Bp, ColAt>, colClass?: string): ReactNode[] {
|
||||
/* Fragment 必须先摊平:`{cond && <>字段A 字段B</>}` 在 Children.toArray 里只是**一个**孩子,
|
||||
A、B 会被塞进同一格竖排,这一行栅格当场少一列(模型抽屉的 3+1 换行就是这么来的)。
|
||||
条件分组要按「每个字段各占一格」算,所以这里递归展开 Fragment 再铺列。 */
|
||||
const cells: ReactNode[] = []
|
||||
const walk = (node: ReactNode) => Children.toArray(node).forEach((child) => {
|
||||
if (isValidElement(child) && child.type === Fragment) walk((child.props as { children?: ReactNode }).children)
|
||||
else cells.push(child)
|
||||
})
|
||||
walk(children)
|
||||
return cells.map((child, i) => <Col key={i} className={colClass} {...spans}>{child}</Col>)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -135,7 +135,16 @@ textarea) { width: 100%; min-width: 0 }
|
|||
|
||||
/* ── 卡片(Panel = antd Card):标题与副标题是中文短语,默认 ellipsis 会裁掉半句 ── */
|
||||
.nex-panel .ant-card-head-title { white-space: normal; overflow: visible; text-overflow: clip }
|
||||
.nex-panel .ant-card-extra { white-space: normal }
|
||||
/* 标题条同理:中文短语不许被 ellipsis 裁掉半句,right 那一块也按内容折行。
|
||||
卡头的 right 只是「一个计数 / 一句下一步」,长起来时不许把标题压成竖排。
|
||||
症状(430 档 /projects/10 的「流程进度」):right 那句「下一步:时间线合成 + 配音/字幕/混音 — …」
|
||||
要 400px 以上,而 antd 的 head 是不换行的 flex,标题只剩 30px ⇒ 「流程进度」一个字一行。
|
||||
做法:head 允许 wrap、right 最宽 100%——宽屏照旧同一行读完,窄屏整句掉到第二行。 */
|
||||
/* ⚠ 卡头的 flex 容器是 .ant-card-head-wrapper,不是 .ant-card-head(后者只是块级壳),
|
||||
写在壳上等于没写。extra 默认 flex-shrink:1 会被压成一条竖河,这里让它按内容定尺、
|
||||
放不下就整块掉到第二行。 */
|
||||
.nex-panel .ant-card-head-wrapper { flex-wrap: wrap; row-gap: var(--ant-margin-xxs) }
|
||||
.nex-panel .ant-card-extra { flex-shrink: 0; max-width: 100% }
|
||||
/* Card 的 body 不是 flex 子项,里面的 Row/Col 想收缩必须先从 min-width:auto 解放出来 */
|
||||
.nex-panel .ant-card-body { min-width: 0 }
|
||||
.nex-panel .ant-card-body > * { min-width: 0 }
|
||||
|
|
@ -148,6 +157,12 @@ textarea) { width: 100%; min-width: 0 }
|
|||
自绘的那几处(checkable tag 的高度)读不到 ConfigProvider,只能靠它对齐
|
||||
到同一个 controlHeightSM。 */
|
||||
.nex-ctlbar { margin-block-end: var(--ant-margin-sm) }
|
||||
/* 工具条铺成栅格之后,宽度归格子管:控件列吃掉标签以外的全部宽度,
|
||||
inline 字段上写的 width="narrow|wide"(--nex-ctl-w)在这里让位给列宽,
|
||||
同一行的控件右边缘因此必然对齐;胶囊选项铺进格子时同理要撑满。 */
|
||||
.nex-ctlbar-grid > .ant-col { display: flex; align-items: center; gap: var(--ant-margin-xs); min-width: 0 }
|
||||
.nex-ctlbar-grid > .ant-col > .ant-form-item { flex: 1 1 auto; min-width: 0 }
|
||||
.nex-ctlbar-grid .nex-field-inline .ant-form-item-control { flex: 1 1 auto; width: auto; min-width: 0 }
|
||||
|
||||
/* ── 下拉面板:宁可临时压住右边内容,也不让用户盲选 ────────────────────
|
||||
症状:时间线 / 交付页的字幕模式、配音来源这些选项,文案本身就是说明
|
||||
|
|
@ -190,6 +205,10 @@ textarea) { width: 100%; min-width: 0 }
|
|||
/* 禁用:5.29 的 CheckableTag 没有 disabled,语义由 Controls.Chip 贴 inline style,
|
||||
这里只负责把「点不动」这件事在光标上也说一遍 */
|
||||
.nex-chip.is-off.ant-tag { cursor: not-allowed }
|
||||
/* 胶囊铺进 OptionGrid 的等宽格子:宽度交给格子,文字居中。
|
||||
这条必须排在 .nex-chip.ant-tag 之后——两条特异度相同(类+类),
|
||||
写在前面会被上面的 display:inline-flex 覆盖回 inline-block,图标与文字的间隙就散了。 */
|
||||
.nex-opt-cell .ant-tag { margin-inline-end: 0; width: 100%; justify-content: center }
|
||||
|
||||
/* 多选回显 = antd Tag(closable):与 Tag 同度量,色调走 primary 那一族 */
|
||||
.nex-tag-chip.ant-tag {
|
||||
|
|
@ -228,6 +247,22 @@ textarea) { width: 100%; min-width: 0 }
|
|||
vertical-align: middle;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* 标签的底色只有一档:中性 fill-tertiary(= antd Tag bordered=false 的默认底)。
|
||||
语义色不再铺底(用户第七轮「浅绿色标签都要处理到新的颜色设计上」)——整屏的
|
||||
「完成 / 已交付 / 合格」如果各是一块浅绿,绿色就从语义色变成了第二个品牌色,
|
||||
和新主色(antd 出厂蓝)打架,也把数字压住。语义改由头部那颗 6px 圆点承载。
|
||||
色值仍然只有 --ant-color-* 一个来源:点用 --nex-tag-tint(由 Status.Tag 按 tone
|
||||
写成 var(--ant-color-success) 等),明暗两档自动跟主题。 */
|
||||
.nex-tag.ant-tag { background: var(--ant-color-fill-tertiary); color: var(--ant-color-text) }
|
||||
.nex-tag-dot {
|
||||
inline-size: 6px;
|
||||
block-size: 6px;
|
||||
flex: none;
|
||||
border-radius: 9999px;
|
||||
background: var(--nex-tag-tint, var(--ant-color-text-quaternary));
|
||||
}
|
||||
/* 深色档:fill-tertiary 只有 4% 白,标签在容器上分不出来,抬到 8% */
|
||||
html[data-theme='dark'] .nex-tag.ant-tag { background: color-mix(in srgb, var(--ant-color-text) 8%, transparent) }
|
||||
/* 密集档:挂在容器上,不挂在单个标签上 */
|
||||
.nex-tag-dense {
|
||||
--tag-h: var(--tag-h-sm);
|
||||
|
|
@ -319,3 +354,89 @@ textarea) { width: 100%; min-width: 0 }
|
|||
.anticon 由 antd 自己管尺寸与对齐;这里只兜住一件事——图标被塞进一排
|
||||
flex 控件时不要当行内盒参与基线计算(老手写 Icon.tsx 时代就靠这条)。 */
|
||||
.anticon { display: inline-flex; flex: none }
|
||||
|
||||
/* ── 统计卡(Stat = Card + Statistic):纯色卡面 + 配套色块图标 ────────────────
|
||||
症状(2026-11 第六轮 · 用户第 2 条原话「大的统计标签卡还是不美观,不要底纹,
|
||||
用配套的色块和图标区分」):上一轮在卡面上压了右上径向渐晕 + 135° 斜纹 +
|
||||
右下角 84px 水印图形。四张卡并排时那层纹理连成一片灰,斜纹和水印叠在一起
|
||||
像印刷错位,最该跳出来的数字反而被压住了。
|
||||
做法:卡面就是 antd Card 自己的 colorBgContainer——没有底纹、没有渐变、没有水印。
|
||||
识别度全部交给数字左侧那只 32px 圆角色块:底色 = 本卡语义色 12% 混合,
|
||||
图形 = 同一条语义色(--nex-stat-tint 由 Stat 的 tone 决定,默认主色)。
|
||||
四张卡并排时先由色块分出四类,数字回到唯一的视觉重心。
|
||||
为什么深色档单独提一档:12% 的饱和色压在 #141414 上几乎读不出来,提到 18%。
|
||||
为什么用 color-mix 而不是新色值:站内 `#hex` 只许出现在 theme/antd.ts(§2),
|
||||
这里按语义色变量比例混合,明暗两档自动跟着主题走,不产生第二套色板。 */
|
||||
.nex-stat { --nex-stat-tint: var(--ant-color-primary) }
|
||||
.nex-stat-mark {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
inline-size: 32px;
|
||||
block-size: 32px;
|
||||
flex: none;
|
||||
border-radius: var(--ant-border-radius-lg);
|
||||
background: color-mix(in srgb, var(--nex-stat-tint) 12%, transparent);
|
||||
color: var(--nex-stat-tint);
|
||||
font-size: 17px;
|
||||
}
|
||||
html[data-theme='dark'] .nex-stat-mark {
|
||||
background: color-mix(in srgb, var(--nex-stat-tint) 18%, transparent);
|
||||
}
|
||||
|
||||
/* ── 只读回显(Info = antd Descriptions):R16.3 ──────────────────────────────
|
||||
症状(用户截图:模型卡里「资源地址 / 参考」那只灰盒):回显写成灰底圆角盒 +
|
||||
label 在上,外面再描一圈边,看着就是一只禁用输入框;而它旁边真有输入框时,
|
||||
两者分不清哪个能填。
|
||||
做法:容器换成 antd 为详情回显准备的 Descriptions,皮肤只调三件事——
|
||||
① label 列降一档字号并用 text-tertiary,值列用正文色:主从一眼分得开;
|
||||
② label 列给一个最小宽度(可用 --nex-info-label-w 覆盖),
|
||||
两列/三列并排时列宽不随字数跳动,扫读才有列感;
|
||||
③ 值列 overflow-wrap:anywhere——长地址、长密钥不许把表格顶宽。
|
||||
底纹(label 列的 colorFillAlter)、圆角、分隔线全部沿用 antd,明暗两档自动跟主题。
|
||||
为什么写在 app.css:页面不准 import antd(R8),`.ant-*` 也只准出现在这一层;
|
||||
组件级皮肤集中在这里,19 个页面共用一把尺子。 */
|
||||
.nex-info.ant-descriptions { width: 100%; min-width: 0 }
|
||||
.nex-info .ant-descriptions-item-label,
|
||||
.nex-info .ant-descriptions-item-content {
|
||||
padding-block: var(--ant-padding-xxs);
|
||||
padding-inline: var(--ant-padding-sm);
|
||||
}
|
||||
.nex-info .ant-descriptions-item-label {
|
||||
width: var(--nex-info-label-w, auto);
|
||||
min-width: 5.5em;
|
||||
color: var(--ant-color-text-tertiary);
|
||||
font-size: var(--ant-font-size-sm);
|
||||
font-weight: 400;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.nex-info .ant-descriptions-item-content {
|
||||
color: var(--ant-color-text);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
/* 深色档:antd 的 colorFillAlter 只有 4% 白,压不出「这一列是标签」的分界,抬到 7% */
|
||||
html[data-theme='dark'] .nex-info .ant-descriptions-item-label {
|
||||
background: color-mix(in srgb, var(--ant-color-text) 7%, transparent);
|
||||
}
|
||||
/* 卡内的回显表:卡本身已有描边,表格再描一圈就成了双层框,只留内部网格线 */
|
||||
.nex-info-in-card.ant-descriptions .ant-descriptions-view { border: 0; border-radius: 0 }
|
||||
.nex-info-in-card.ant-descriptions .ant-descriptions-item-label,
|
||||
.nex-info-in-card.ant-descriptions .ant-descriptions-item-content { border-color: var(--ant-color-fill-secondary) }
|
||||
.nex-info.ant-descriptions .ant-descriptions-header { margin-block-end: var(--ant-margin-xs) }
|
||||
.nex-info.ant-descriptions .ant-descriptions-title { font-size: var(--ant-font-size); font-weight: 600 }
|
||||
|
||||
/* ── 正文纵向节奏(PageStack):块与块之间的距离只由父级 gap 给一把尺子 ──────
|
||||
症状(2026-11 第五轮 · 用户第 3 条「组件之间的上下、左右边距要合理」):
|
||||
同一列里页头自带 mb-5(20)、统计卡自带 mb-4(16)、提示条自带 mb-4(16),
|
||||
外层容器又要么不排间距、要么再排一次。实测量出来同一屏里同时存在
|
||||
0 / 8 / 16 / 20 / 36 五种值:用户管理的统计卡与下面的表格卡贴成一块
|
||||
(gap 0),质检页页头与下面的计数工具条之间空出 36px 的大空洞。
|
||||
做法:正文列一律走 <PageStack>(antd Flex vertical gap=16),这一条把
|
||||
**直接子块**自带的下边距归零——父级 gap 成为这一列唯一的纵向尺子。
|
||||
只管直接子级:块内部(表单、卡身、手册正文)的间距仍归各自的栅格与 Form.Item。
|
||||
为什么用 CSS 而不是从每个页面上删掉 mb-*:同一块内容还要在抽屉、手册正文里复用,
|
||||
那些地方没有 gap;「间距归容器」这件事由容器自己声明才收得干净。 */
|
||||
.nex-stack > * { margin-block-end: 0 }
|
||||
/* 页签条自带 16px 下边距(antd .ant-tabs-nav):它在 PageStack 里就是「和下一块的距离」,
|
||||
与父级 gap 重复会空出 32px。归零之后页签与正文之间仍是站内那一档 16。 */
|
||||
.nex-stack > .ant-tabs > .ant-tabs-nav { margin-block-end: 0 }
|
||||
|
|
|
|||
Loading…
Reference in New Issue