themeConfig.ts
10.6 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
import type { ThemeConfig } from 'antd';
import { control, palette, radius, shadow } from './palette';
// 品牌色板(稳重内敛 · 企业级)
// 说明:brandDeep / brandGradient 原用于 Sider 与工作台欢迎条底;
// 现将两处明度过低的深色底均已弃用(Sider 改由 design.css 的 .uj-sider 垂直 matte 深蓝承接,
// 工作台欢迎条改为浅色卡片 + 品牌色点睛)。这两个色值暂无代码引用,保留作品牌资产备查。
export const brandDeep = palette.brand.deep1; // 墨蓝导航底(深色态,暂未引用)
export const brandGradient = `linear-gradient(160deg, ${palette.brand.deep1} 0%, ${palette.brand.deep2} 100%)`; // 暂未引用
export const brandAccent = palette.brand.primary; // 主操作蓝
/**
* 全站唯一的一份 antd 主题。
*
* 精致度主要在这一层做,而不是在 CSS 里覆盖 .ant-*:
* ConfigProvider 的 component token 是 antd 官方认可的定制入口,几何量(高度、内间距、
* 居中计算)会跟着 token 一起重算;用 CSS 覆盖组件内部盒模型,折叠态/滚动吸顶这类
* 有内部计算的部位一定算歪。design.css 里那段关于 Menu 的注释说的是同一条规矩。
*
* 少数 token 表达不了的(表格填充高度、筛选面板折叠、等宽数字)才落到
* packages/ui/src/styles/ui.css。
*/
export const themeConfig: ThemeConfig = {
cssVar: {},
token: {
colorPrimary: palette.brand.primary,
colorLink: palette.brand.primary,
colorLinkHover: palette.brand.primaryHover,
colorLinkActive: palette.brand.primaryActive,
colorSuccess: palette.semantic.success,
colorWarning: palette.semantic.warning,
colorError: palette.semantic.error,
colorInfo: palette.brand.primary,
colorBgLayout: palette.surface.page,
colorBgContainer: palette.surface.base,
colorBgElevated: palette.surface.base,
colorFillAlter: palette.surface.raised,
controlItemBgHover: palette.surface.hover,
colorText: palette.text.primary,
colorTextHeading: palette.text.primary,
colorTextSecondary: palette.text.secondary,
colorTextTertiary: palette.text.tertiary,
colorTextQuaternary: palette.text.quaternary,
colorTextDescription: palette.text.secondary,
colorTextDisabled: palette.text.quaternary,
colorBorder: palette.line.border,
colorBorderSecondary: palette.line.border,
colorSplit: palette.line.divider,
/**
* 语义色的淡底与淡描边:antd 的 Alert / Tag / Result 取的是这四个 *Bg / *Border 别名,
* 不在这里给,它们就会回退到 antd 自己算的 alpha 淡色 —— 和 CSS 侧 palette.soft 不同源,
* 表现就是「同一个成功态,提示条和标签是两种绿」。
*/
colorSuccessBg: palette.soft.success,
colorSuccessBorder: palette.softBorder.success,
colorWarningBg: palette.soft.warning,
colorWarningBorder: palette.softBorder.warning,
colorErrorBg: palette.soft.error,
colorErrorBorder: palette.softBorder.error,
colorInfoBg: palette.soft.info,
colorInfoBorder: palette.softBorder.info,
borderRadius: radius.md,
borderRadiusSM: radius.sm,
borderRadiusLG: radius.card,
controlHeight: control.height,
// size="small" 的控件(全站只有筛选区的 SearchForm 用):antd 由 controlHeight
// 派生成 27px,比默认高度矮一档后单行输入在密集筛选带里显得「点不中」。
// 这里定为 32px —— 比默认矮 4px、比派生值高 5px,标签左置后整条筛选带只有一行。
controlHeightSM: 32,
fontSize: 14,
fontSizeSM: 12,
fontFamily:
"'PingFang', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif",
// 阴影分三档:卡片静置、hover 抬起、浮层。原来只有一档,卡片和 hover 一样平。
boxShadow: shadow.card,
boxShadowSecondary: shadow.pop,
boxShadowTertiary: '0 4px 12px -6px rgba(16, 24, 40, 0.10)',
wireframe: false,
},
components: {
Layout: {
headerBg: '#FFFFFF',
headerHeight: 60,
headerPadding: '0 20px',
siderBg: 'transparent',
bodyBg: palette.surface.page,
},
Menu: {
// —— 颜色(暗色模式)——
darkItemBg: 'transparent',
darkSubMenuItemBg: 'transparent',
darkItemColor: 'rgba(255,255,255,.62)',
darkItemHoverBg: 'rgba(255,255,255,.06)',
darkItemHoverColor: '#FFFFFF',
darkItemSelectedBg: 'rgba(43,92,230,.22)',
darkItemSelectedColor: '#FFFFFF',
darkGroupTitleColor: 'rgba(255,255,255,.32)',
// 折叠态弹出的子菜单底:与 .uj-sider 中段色一致,避免弹出层露出 antd 默认的深蓝黑
darkPopupBg: '#111B3D',
// —— 几何:全部走 token,不在 design.css 里用 CSS 覆盖组件内部盒模型 ——
// antd 会用 itemMarginInline 参与折叠态居中计算(paddingInline: calc(50% - 图标宽/2 - itemMarginInline)),
// 所以「胶囊左右留白」必须由这个 token 给,不能用 CSS margin 顶替。
itemMarginInline: 10,
itemBorderRadius: 10,
itemHeight: 44,
iconSize: 15,
groupTitleFontSize: 10.5,
// 必须与 <Sider collapsedWidth={68}> 保持一致:Menu 折叠态有自己的 collapsedWidth,
// 两者不等会让菜单比侧栏宽(溢出)或窄(留缝)。
collapsedWidth: 68,
},
Card: {
borderRadiusLG: radius.card,
// 卡片靠「浅底 + 无描边 + 柔影」成立;再叠一圈 #e2e8f0 的实描边是原来越来越「硬」的根因。
colorBorderSecondary: palette.line.divider,
headerBg: 'transparent',
headerHeight: 48,
headerHeightSM: 40,
headerPadding: 14,
headerPaddingSM: 10,
headerFontSize: 15,
headerFontSizeSM: 14,
bodyPadding: 20,
bodyPaddingSM: 16,
actionsBg: palette.surface.raised,
},
Button: {
controlHeight: control.height,
controlHeightSM: control.heightSm,
borderRadius: radius.md,
fontWeight: 500,
primaryShadow: '0 4px 12px -4px rgba(43,92,230,.42)',
defaultShadow: 'none',
defaultBorderColor: palette.line.border,
defaultColor: palette.text.secondary,
contentFontSizeSM: 13,
},
/**
* 表格是三个子应用的信息主体,也是「粗糙」最集中的地方。
* 表头用 raised 底 + 12px 次级字色,正文降到 13px,行高靠 padding 撑而不是靠字号撑,
* 分隔线取 divider(比 border 更淡)—— 这几项合起来就是「密但不挤、清但不硬」。
*/
Table: {
headerBg: palette.surface.raised,
headerColor: palette.text.header,
headerSplitColor: 'transparent',
headerBorderRadius: 8,
borderColor: palette.line.divider,
colorText: palette.text.primary,
// 三档尺寸都给,避免页面里 size 写成 small/large 时字号又跳回 14。
cellFontSize: control.tableFont,
cellFontSizeMD: control.tableFont,
cellFontSizeSM: control.tableFont,
rowHoverBg: palette.surface.raised,
rowSelectedBg: palette.soft.info,
rowSelectedHoverBg: '#E4ECFD',
cellPaddingBlockMD: 11,
// 左右留白取 antd 的 middle 默认值 16,不再追「与卡片 20px 对齐」:
// 20px 会把 90~110px 的窄列挤到内容宽不足 4 个汉字,
// 表头「变更次数」这类四字标题就换行,整行表头被撑成两倍高。
cellPaddingInlineMD: 16,
selectionColumnWidth: 48,
},
Pagination: {
itemBg: 'transparent',
itemSize: 30,
itemSizeSM: 26,
borderRadius: radius.sm,
colorText: palette.text.secondary,
itemActiveBg: palette.brand.primary,
itemActiveColor: '#FFFFFF',
itemActiveColorHover: '#FFFFFF',
fontSize: 13,
},
Tag: {
defaultBg: palette.soft.neutral,
defaultColor: palette.text.secondary,
borderRadiusSM: radius.sm,
fontSizeSM: 12,
},
Alert: {
containerBorderRadius: radius.md,
defaultPadding: '10px 16px',
withDescriptionPadding: '14px 18px',
withDescriptionIconSize: 20,
fontSize: 13,
},
Form: {
itemMarginBottom: 18,
verticalLabelPadding: '0 0 6px',
labelColor: palette.text.secondary,
labelFontSize: 13,
},
Input: {
controlHeight: control.height,
borderRadius: radius.md,
colorBgContainer: palette.surface.base,
hoverBorderColor: palette.brand.primaryHover,
activeBorderColor: palette.brand.primary,
activeShadow: '0 0 0 3px rgba(43,92,230,.12)',
errorActiveShadow: '0 0 0 3px rgba(229,72,77,.12)',
paddingBlock: 6,
},
Select: {
controlHeight: control.height,
borderRadius: radius.md,
optionActiveBg: palette.surface.hover,
optionSelectedBg: palette.soft.info,
optionSelectedColor: palette.brand.primary,
optionSelectedFontWeight: 500,
activeBorderColor: palette.brand.primary,
activeOutlineColor: '0 0 0 3px rgba(43,92,230,.12)',
optionPadding: '8px 12px',
optionHeight: 32,
optionFontSize: 13,
},
Modal: {
borderRadiusLG: radius.card,
titleFontSize: 16,
headerBg: 'transparent',
contentBg: palette.surface.base,
footerBg: 'transparent',
},
Drawer: {
paddingLG: 24,
footerPaddingBlock: 14,
footerPaddingInline: 24,
colorBgElevated: palette.surface.base,
},
Tabs: {
horizontalItemPadding: '7px 16px',
horizontalMargin: '0',
itemColor: palette.text.secondary,
// 滑动药丸风格:激活标签落在主色滑块上,文字反白;hover 只是加深,不走主色。
itemSelectedColor: palette.surface.onPrimary,
itemHoverColor: palette.text.primary,
inkBarColor: palette.brand.primary,
titleFontSize: 14,
cardBg: palette.surface.raised,
},
Descriptions: {
titleColor: palette.text.primary,
labelColor: palette.text.tertiary,
contentColor: palette.text.primary,
itemPaddingBottom: 12,
labelBg: 'transparent',
},
Skeleton: {
paragraphMarginTop: 12,
titleHeight: 18,
blockRadius: radius.sm,
color: palette.surface.hover,
},
Divider: {
colorSplit: palette.line.divider,
},
Empty: {
colorTextDescription: palette.text.tertiary,
},
Tooltip: {
borderRadius: radius.sm,
fontSize: 12,
},
Steps: {
iconSize: 26,
iconSizeSM: 20,
iconFontSize: 13,
titleLineHeight: 22,
},
Switch: {
handleSize: 18,
handleSizeSM: 12,
},
},
};