Repository navigation
Expand file tree
/
Copy pathtailwind.css
More file actions
164 lines (146 loc) · 7.48 KB
/
Copy pathtailwind.css
File metadata and controls
164 lines (146 loc) · 7.48 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
/*
* Tailwind CSS v4(CSS 优先配置,取代 tailwind.config.js;umi 经 @tailwindcss/webpack 编译本文件)
*
* 1. 不引入 preflight:基础 reset 交给 antd 的 reset.css 独占,避免压平全局标题样式。
* 2. utilities 刻意不放进 @layer:v4 默认把工具类放进原生级联层,而 antd CSS-in-JS、antd reset、
* CSS Modules 与第三方样式(xgplayer/ol/FullCalendar 等)都不在层内——未分层样式恒胜分层样式,
* 工具类会在任何冲突上落败(如顶栏 Divider 的 mx-5 h-7 被 antd 自身的 margin/height 覆盖)。
* 不分层即保持 v3 的层叠语义:按选择器特异性与出现顺序决胜。
* 3. 扫描范围与 v3 content 一致:只扫 src 下 ts/tsx,排除 umi 生成物。
*/
@import 'tailwindcss/theme.css' layer(theme);
@import 'tailwindcss/utilities.css' source(none);
@source './src/**/*.{ts,tsx}';
@source not './src/.umi';
@source not './src/.umi-production';
/* D3 等代码里以字符串字面量出现的词会被误判为类名(曾产出 .visible/.table 等死规则),直接拦截 */
@source not inline('{visible,table,italic,outline,resize}');
/*
* antd CSS 变量桥接(antd 6 默认就会把 token 注入成 CSS 变量;本项目没有、也不需要显式配置
* cssVar):变量不在 :root 上,而是挂在 antd 组件根的 .css-var-* 作用域内(umi 用 antd <App>
* 包裹整个应用,其容器也带该类,弹层根节点各自带)。
* 必须用 inline:否则工具类引用的是在 :root 上求值的 --color-*,那里 --ant-* 尚未定义。
* 这些 token 类只在 antd 组件树内生效;切换暗色时 antd 重算变量,token 类自动跟随。
*/
@theme inline {
--color-text: var(--ant-color-text);
--color-text-secondary: var(--ant-color-text-secondary);
--color-text-tertiary: var(--ant-color-text-tertiary);
--color-fill-tertiary: var(--ant-color-fill-tertiary);
--color-success: var(--ant-color-success);
--color-warning: var(--ant-color-warning);
--color-error: var(--ant-color-error);
--color-bg-container: var(--ant-color-bg-container);
--color-bg-layout: var(--ant-color-bg-layout);
}
/* 登录页卡片的「落地」:视口够高时贴到与左下角文案块同一条地平线;
矮屏回到垂直居中,避免顶穿 header。见 Login/index.tsx */
@media (width >= 1024px) and (height >= 880px) {
.lg-self-end-tall {
align-self: flex-end;
}
}
/*
* preflight 已去掉,但 border 系工具类依赖 preflight 的边框基线:
* .border 只设 border-width,缺了 border-style: solid 时边框根本不显示。
* 这里只补回 preflight 中与边框相关的两条;放在原生 base 层,任何未分层样式(含 antd)都能覆盖它。
* 边框默认色沿用 v3 的 gray-200(v4 默认改为 currentColor),以 rgb 写出(原因见下方注释)。
*/
@layer base {
*,
::before,
::after {
border-width: 0;
border-style: solid;
/* 写死 rgb 而不是引用 --color-gray-200:v4 的调色板是 oklch(),html2canvas 1.x 解析不了,
截图页与 PDF 报告会整体失败(它会读取每个元素的计算样式) */
border-color: rgb(229 231 235);
}
/* 上面把 border-width 归零后,hr 需要恢复顶边线(同 preflight) */
hr {
height: 0;
color: inherit;
border-top-width: 1px;
}
}
/*
* 无障碍(Q5):两处第三方组件把「主色」当文字色用。主色必须同时满足「白字压其上」(要求够深)
* 与「深色主题下当文字」(要求够浅),两个方向无法用同一个 token 满足,所以只在这两个具体位置
* 改接到链接色 / 说明文字色(它们同样是主题感知的 --ant-* 变量,浅色深档、深色亮档)。
* 选择器带元素名(0,1,1)以压过组件自身的单类规则(0,1,0),避免依赖 CSS-in-JS 的注入顺序。
*/
a.ant-pro-query-filter-collapse-button {
/* pro-components 查询表单的「展开 / 收起」:color: token.colorPrimary,暗色主题下 #1668dc 在
#141414 上只有 3.55:1(axe color-contrast serious) */
color: var(--ant-color-link);
}
div.ant-spin-description {
/* antd 6 Spin 的 section 用 colorPrimary 当文字色,说明文字在暗色卡片上只有 3.06:1 */
color: var(--ant-color-text-description, var(--ant-color-text));
}
/*
* 顶栏右侧按钮的 hover / 菜单展开反馈:antd 6 文本按钮默认铺 fill-tertiary
* (浅色 4% 黑 / 深色 8% 白),在顶栏底色上几乎不可见;统一升到 fill-secondary。
* 选择器特异性 (0,3,1) 压过组件自身的 (0,2,1) hover 规则;变量挂在按钮自身的
* .css-var-* 作用域上,浅深主题各自取值。作用域类 admin-header-actions 见 RightContent.tsx。
*/
.admin-header-actions .ant-btn-text:not(:disabled):hover,
.admin-header-actions .ant-btn-text.ant-dropdown-open {
background-color: var(--ant-color-fill-secondary);
}
/*
* 头像字母居中的度量补偿(4x 截图像素级实测,墨迹包围盒中心 vs 圆环中心):
* antd Avatar 的基线摆放让两种文字的墨迹都整体上偏约 1.4px(拉丁 −1.46 / 汉字 −1.40),
* 水平方向拉丁字母右偏约 0.5px、汉字(全宽 advance)水平居中。
* 补偿值经两步实测标定(1.5→残差−0.46、2.5→残差+0.51,近似 1:1 生效),2.0px 时双语言残差均为 0。
* 用 margin 而非 transform:antd 给 .ant-avatar-string 设了内联 transform(scale),CSS transform 会被压。
*/
.admin-header-actions .ant-avatar-string {
margin-top: 2px;
margin-left: -0.4px;
}
:lang(zh) .admin-header-actions .ant-avatar-string {
margin-left: 0;
}
/*
* 页面切换微动效(P2):路由变化时内容区 150ms 淡入上浮,只做「存在感」提示不做位移叙事;
* prefers-reduced-motion 下禁用(与 GuideTour/ParticleField 的 motion 纪律一致)。
* key 由 PageTransition 以 pathname 提供,切换即重挂载触发动画。
*/
@keyframes page-fade-in {
from {
opacity: 0;
transform: translateY(2px);
}
to {
opacity: 1;
transform: none;
}
}
.page-fade {
animation: page-fade-in 0.15s ease-out;
}
@media (prefers-reduced-motion: reduce) {
.page-fade {
animation: none;
}
}
/*
* 组内导航条要全出血(贴顶栏、左右 1280 全宽)。ProLayout 的内容区 main.ant-pro-layout-content
* 默认带 padding: 32px 40px,PageContainer 挂载后才加 has-page-container 类把它归零——首次访问
* 页面时路由 chunk 懒编译会有一帧「有 GroupNav、无 PageContainer」,导航条被这层 padding 内缩
* (88,40),下一帧弹回 (56,0),就是「进页面时二级菜单跳一下」。GroupNav 在场时内容区一律零内边距:
* 稳态本来就是这个值,这里只是把首帧拉齐;页面自身留白一直由 PageContainer 的 padding 提供。
*/
main.ant-pro-layout-content:has([data-tour='groupnav']) {
padding: 0 !important;
}
/*
* ProLayout 在 fixedHeader(及 mix 布局)下会在真正的顶栏前插一个空的透明 <header> 占位撑开 56px,
* 它和顶栏都是页面级 <header>,读屏器的地标列表里多出一个空「横幅」(axe landmark-no-duplicate-banner /
* landmark-unique)。组件没有给占位传属性的口子:visibility: hidden 把它移出无障碍树,而盒子高度照旧
* 占位(visibility 不影响布局);它本来就是透明空元素,视觉无变化。
*/
header.ant-layout-header:has(+ header[data-testid='pro-layout-header']) {
visibility: hidden;
}