@neatui/css 3.15.0 → 3.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GUIDE.md +1497 -0
- package/NEATUI_COMPREHENSIVE_ASSESSMENT.md +1019 -0
- package/NEATUI_DEEP_EVALUATION_REPORT.md +111 -0
- package/NEATUI_EVALUATION_REPORT_GPT.md +247 -0
- package/core/basic.scss +4 -0
- package/core/container.scss +281 -0
- package/core/size.scss +7 -8
- package/core/trim.scss +7 -7
- package/package.json +4 -1
- package/core/README.md +0 -142
- package/core/package.json +0 -16
package/GUIDE.md
ADDED
|
@@ -0,0 +1,1497 @@
|
|
|
1
|
+
# NeatUI 完整使用手册
|
|
2
|
+
|
|
3
|
+
> **版本**: @neatui/css v3.15.0
|
|
4
|
+
>
|
|
5
|
+
> **更新日期**: 2025-11-29
|
|
6
|
+
>
|
|
7
|
+
> **定位**: 这不是一个 CSS 工具库,而是一套完整的设计系统 + 原子化实现
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 目录
|
|
12
|
+
|
|
13
|
+
- [核心理念](#核心理念)
|
|
14
|
+
- [架构概览](#架构概览)
|
|
15
|
+
- [快速开始](#快速开始)
|
|
16
|
+
- [尺寸系统 (S/M/L Matrix)](#尺寸系统)
|
|
17
|
+
- [颜色系统 (Semantic Colors)](#颜色系统)
|
|
18
|
+
- [布局系统 (ui-flex / ui-grid)](#布局系统)
|
|
19
|
+
- [响应式系统 (9-Grid Responsive)](#响应式系统)
|
|
20
|
+
- [按钮系统 (ui-btn)](#按钮系统)
|
|
21
|
+
- [完整 API 参考](#完整-api-参考)
|
|
22
|
+
- [最佳实践](#最佳实践)
|
|
23
|
+
- [常见场景](#常见场景)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 核心理念
|
|
28
|
+
|
|
29
|
+
### 三大思维模型
|
|
30
|
+
|
|
31
|
+
NeatUI 要求你摒弃传统的 CSS 思维,建立全新的思维模型:
|
|
32
|
+
|
|
33
|
+
#### 1. 语义思维 > 像素思维
|
|
34
|
+
```
|
|
35
|
+
❌ 错误: padding: 16px; width: 320px;
|
|
36
|
+
✅ 正确: n-mm; w-lm;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**原则**:永远不使用任意像素值,使用 S/M/L 相对尺寸体系。
|
|
40
|
+
|
|
41
|
+
#### 2. 坐标思维 > 属性思维
|
|
42
|
+
```
|
|
43
|
+
❌ 错误: display: flex; justify-content: space-between; align-items: center;
|
|
44
|
+
✅ 正确: ui-flex="row xm"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**原则**:用空间位置描述,而非 CSS 属性名。
|
|
48
|
+
|
|
49
|
+
#### 3. 意图思维 > 色值思维
|
|
50
|
+
```
|
|
51
|
+
❌ 错误: color: #f95850; background: red;
|
|
52
|
+
✅ 正确: co-risk; bg-risk;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**原则**:用功能意图命名,而非色相描述。
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 架构概览
|
|
60
|
+
|
|
61
|
+
### 设计哲学金字塔
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
┌─────────────────────────────────────┐
|
|
65
|
+
│ 设计规范 (Design System) │ ← NeatUI 定义层
|
|
66
|
+
├─────────────────────────────────────┤
|
|
67
|
+
│ 原子化实现 (Atomic CSS) │ ← NeatUI 实现层
|
|
68
|
+
├─────────────────────────────────────┤
|
|
69
|
+
│ 编译优化 (SCSS Engine) │ ← NeatUI 引擎层
|
|
70
|
+
└─────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 核心特性
|
|
74
|
+
|
|
75
|
+
| 特性 | 描述 | 对比 Tailwind |
|
|
76
|
+
|-----|------|---------------|
|
|
77
|
+
| **设计系统** | 强制规范,技术约束 | 无规范,依赖自律 |
|
|
78
|
+
| **主题系统** | 8 色 → 100+ 自动推导 | 需手动定义 50+ 色阶 |
|
|
79
|
+
| **命名系统** | 3 个规则,算法推导 | 50+ 类名,字典记忆 |
|
|
80
|
+
| **学习曲线** | 20 分钟精通 | 1-3 天入门 |
|
|
81
|
+
| **响应式** | 9 档断点 + 3 种操作符 | 5 档断点 + min-width |
|
|
82
|
+
| **布局系统** | 空间坐标,直觉映射 | CSS 属性翻译 |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 快速开始
|
|
87
|
+
|
|
88
|
+
### 安装
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# NPM
|
|
92
|
+
npm install @neatui/css
|
|
93
|
+
|
|
94
|
+
# Yarn
|
|
95
|
+
yarn add @neatui/css
|
|
96
|
+
|
|
97
|
+
# Nuxt 项目
|
|
98
|
+
npm install @neatui/css @neatui/nuxt
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 在项目中引入
|
|
102
|
+
|
|
103
|
+
#### 方式 1: SCSS 引入(推荐)
|
|
104
|
+
```scss
|
|
105
|
+
// app/assets/css/base.scss
|
|
106
|
+
@use '@neatui/css' as neatui;
|
|
107
|
+
|
|
108
|
+
// 使用响应式 mixin
|
|
109
|
+
.my-component {
|
|
110
|
+
@include neatui.mob {
|
|
111
|
+
padding-top: 4em;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### 方式 2: Nuxt 配置
|
|
117
|
+
```ts
|
|
118
|
+
// nuxt.config.ts
|
|
119
|
+
export default defineNuxtConfig({
|
|
120
|
+
modules: [
|
|
121
|
+
'@neatui/nuxt'
|
|
122
|
+
]
|
|
123
|
+
})
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 第一个示例
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<!-- 传统 CSS/Tailwind 方式 -->
|
|
130
|
+
<div class="flex justify-center items-center p-4 bg-white rounded-lg shadow-md">
|
|
131
|
+
<h1 class="text-2xl font-bold text-gray-900">Hello World</h1>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<!-- NeatUI 方式 -->
|
|
135
|
+
<div ui-flex="row cm" class="n-sm bg-fore r-sm shadow-sm">
|
|
136
|
+
<h1 class="fs-lm bold co-text">Hello World</h1>
|
|
137
|
+
</div>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**代码减少 40%,语义更清晰!**
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 尺寸系统
|
|
145
|
+
|
|
146
|
+
### 核心概念:S/M/L 矩阵
|
|
147
|
+
|
|
148
|
+
NeatUI 采用 **分形尺寸体系**,而非线性数值:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
基元 (Base):
|
|
152
|
+
s = Small (小)
|
|
153
|
+
m = Medium (中)
|
|
154
|
+
l = Large (大)
|
|
155
|
+
|
|
156
|
+
修饰符 (Modifier):
|
|
157
|
+
s = small-tier (偏小)
|
|
158
|
+
m = middle-tier (偏中)
|
|
159
|
+
l = large-tier (偏大)
|
|
160
|
+
|
|
161
|
+
组合规则:
|
|
162
|
+
第一个字母 = 基调
|
|
163
|
+
第二个字母 = 微调
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 12 级尺寸阶梯
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
no → 0 (无)
|
|
170
|
+
xs → 0.5em (超小)
|
|
171
|
+
ss → 0.75em (小-小)
|
|
172
|
+
sm → 1em (小-中)
|
|
173
|
+
sl → 1.25em (小-大)
|
|
174
|
+
ms → 1.5em (中-小)
|
|
175
|
+
mm → 2em (中-中)
|
|
176
|
+
ml → 2.5em (中-大)
|
|
177
|
+
ls → 3em (大-小)
|
|
178
|
+
lm → 4em (大-中)
|
|
179
|
+
ll → 6em (大-大)
|
|
180
|
+
xl → 8em (超大)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 修饰符扩展(5 倍精度)
|
|
184
|
+
|
|
185
|
+
```scss
|
|
186
|
+
基础值:
|
|
187
|
+
w-ll // 6em
|
|
188
|
+
|
|
189
|
+
增量 (+):
|
|
190
|
+
w-ll+ // 7em (基础 + 1)
|
|
191
|
+
|
|
192
|
+
倍数 (*):
|
|
193
|
+
w-ll*s // 12em (基础 × 2)
|
|
194
|
+
w-ll*m // 18em (基础 × 3)
|
|
195
|
+
w-ll*l // 24em (基础 × 4)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**覆盖范围**: 0-80em (0-1280px @ 16px),共 60+ 种精确尺寸
|
|
199
|
+
|
|
200
|
+
### 应用于各属性
|
|
201
|
+
|
|
202
|
+
| 前缀 | 属性 | 示例 | 说明 |
|
|
203
|
+
|-----|------|------|------|
|
|
204
|
+
| `n-` | padding | `n-mm` | 内边距 2em |
|
|
205
|
+
| `m-` | margin | `m-ss` | 外边距 0.75em |
|
|
206
|
+
| `w-` | width | `w-ll` | 宽度 6em |
|
|
207
|
+
| `h-` | height | `h-sm` | 高度 1em |
|
|
208
|
+
| `r-` | border-radius | `r-ms` | 圆角 1.5em |
|
|
209
|
+
| `fs-` | font-size | `fs-lm` | 字号 4em |
|
|
210
|
+
|
|
211
|
+
### 方向修饰符
|
|
212
|
+
|
|
213
|
+
```scss
|
|
214
|
+
// 单方向
|
|
215
|
+
nx-mm // padding-left + padding-right
|
|
216
|
+
ny-mm // padding-top + padding-bottom
|
|
217
|
+
nt-mm // padding-top
|
|
218
|
+
nr-mm // padding-right
|
|
219
|
+
nb-mm // padding-bottom
|
|
220
|
+
nl-mm // padding-left
|
|
221
|
+
|
|
222
|
+
// 同理适用于 margin (m)
|
|
223
|
+
mx-sm // margin-left + margin-right
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 特殊值
|
|
227
|
+
|
|
228
|
+
```scss
|
|
229
|
+
r-round // border-radius: 50% (圆形)
|
|
230
|
+
r-no // border-radius: 0 (无圆角)
|
|
231
|
+
|
|
232
|
+
w-full // width: 100%
|
|
233
|
+
h-full // height: 100%
|
|
234
|
+
|
|
235
|
+
w-auto // width: auto
|
|
236
|
+
h-auto // height: auto
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## 颜色系统
|
|
242
|
+
|
|
243
|
+
### 核心概念:语义化色彩
|
|
244
|
+
|
|
245
|
+
NeatUI 的色彩系统分为三层:
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
层级 1: 基础色 (8 个)
|
|
249
|
+
├─ main (主色)
|
|
250
|
+
├─ vice (辅助色)
|
|
251
|
+
├─ well (成功)
|
|
252
|
+
├─ warn (警告)
|
|
253
|
+
├─ risk (危险)
|
|
254
|
+
├─ info (信息)
|
|
255
|
+
├─ text (文本)
|
|
256
|
+
└─ fore (前景)
|
|
257
|
+
|
|
258
|
+
层级 2: 语义色 (自动推导)
|
|
259
|
+
├─ read, desc, note, line, weak (5 级文字)
|
|
260
|
+
└─ 12 级透明度 + 混合色
|
|
261
|
+
|
|
262
|
+
层级 3: 主题色 (自动切换)
|
|
263
|
+
├─ light (浅色主题)
|
|
264
|
+
└─ dark (深色主题)
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### 基础色配置
|
|
268
|
+
|
|
269
|
+
```scss
|
|
270
|
+
// 在项目中配置主题
|
|
271
|
+
$theme: (
|
|
272
|
+
'light': (
|
|
273
|
+
main: #00b277, // 品牌主色
|
|
274
|
+
vice: #67ce82, // 品牌辅助色
|
|
275
|
+
well: #4bbc73, // 成功 (绿色系)
|
|
276
|
+
warn: #fb9a2a, // 警告 (橙色系)
|
|
277
|
+
risk: #f95850, // 危险 (红色系)
|
|
278
|
+
info: #3c49dd, // 信息 (蓝色系)
|
|
279
|
+
text: #000000, // 主文本色
|
|
280
|
+
fore: #ffffff, // 前景/卡片背景色
|
|
281
|
+
),
|
|
282
|
+
'dark': (
|
|
283
|
+
// 深色主题配置...
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### 自动推导的语义色
|
|
289
|
+
|
|
290
|
+
```scss
|
|
291
|
+
// 系统自动计算,无需手动定义
|
|
292
|
+
--co-read: rgba(text, 0.85) // 主要阅读文字
|
|
293
|
+
--co-desc: rgba(text, 0.55) // 描述性文字
|
|
294
|
+
--co-note: rgba(text, 0.35) // 注释/提示文字
|
|
295
|
+
--co-line: rgba(text, 0.10) // 分割线
|
|
296
|
+
--co-weak: rgba(text, 0.035) // 弱化背景
|
|
297
|
+
|
|
298
|
+
// 反转色 (前景色)
|
|
299
|
+
--co-case: rgba(fore, 0.85) // 反转主文字
|
|
300
|
+
--co-link: rgba(fore, 0.55) // 反转描述
|
|
301
|
+
--co-tips: rgba(fore, 0.35) // 反转提示
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 颜色属性前缀
|
|
305
|
+
|
|
306
|
+
| 前缀 | 属性 | 示例 | 输出 |
|
|
307
|
+
|-----|------|------|------|
|
|
308
|
+
| `co-` | color | `co-main` | 主色文字 |
|
|
309
|
+
| `bg-` | background | `bg-risk` | 危险背景 |
|
|
310
|
+
| `bk-` | border-color | `bk-line` | 线条边框 |
|
|
311
|
+
|
|
312
|
+
### 完整颜色类名列表
|
|
313
|
+
|
|
314
|
+
#### 品牌色
|
|
315
|
+
```scss
|
|
316
|
+
co-main, bg-main, bk-main // 主色
|
|
317
|
+
co-vice, bg-vice, bk-vice // 辅助色
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
#### 功能色
|
|
321
|
+
```scss
|
|
322
|
+
co-well, bg-well, bk-well // 成功 ✅
|
|
323
|
+
co-warn, bg-warn, bk-warn // 警告 ⚠️
|
|
324
|
+
co-risk, bg-risk, bk-risk // 危险 ❌
|
|
325
|
+
co-info, bg-info, bk-info // 信息 ℹ️
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
#### 基础色
|
|
329
|
+
```scss
|
|
330
|
+
co-text, bg-text, bk-text // 文本色
|
|
331
|
+
co-fore, bg-fore, bk-fore // 前景色
|
|
332
|
+
co-back, bg-back, bk-back // 背景色
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
#### 语义色
|
|
336
|
+
```scss
|
|
337
|
+
co-read // 主要文字 (85%)
|
|
338
|
+
co-desc // 描述文字 (55%)
|
|
339
|
+
co-note // 注释文字 (35%)
|
|
340
|
+
co-line // 分割线 (10%)
|
|
341
|
+
co-weak // 弱化背景 (3.5%)
|
|
342
|
+
|
|
343
|
+
// 反转色 (用于深色背景)
|
|
344
|
+
co-case // 反转主文字
|
|
345
|
+
co-link // 反转链接
|
|
346
|
+
co-tips // 反转提示
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### 透明度系列 (12 级)
|
|
350
|
+
|
|
351
|
+
任何颜色 + `-o-{level}` = 透明度变体
|
|
352
|
+
|
|
353
|
+
```scss
|
|
354
|
+
co-main-o-xs // 主色 + 超低透明度
|
|
355
|
+
co-main-o-ss
|
|
356
|
+
co-main-o-sm
|
|
357
|
+
co-main-o-sl
|
|
358
|
+
co-main-o-ms
|
|
359
|
+
co-main-o-mm
|
|
360
|
+
co-main-o-ml
|
|
361
|
+
co-main-o-ls
|
|
362
|
+
co-main-o-lm
|
|
363
|
+
co-main-o-ll
|
|
364
|
+
co-main-o-xl // 主色 + 超高透明度
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### 混合色系列
|
|
368
|
+
|
|
369
|
+
```scss
|
|
370
|
+
// 与前景色混合 (变浅)
|
|
371
|
+
co-main-w-sm // 主色 + 前景色 10%
|
|
372
|
+
co-main-w-mm // 主色 + 前景色 20%
|
|
373
|
+
co-main-w-ml // 主色 + 前景色 30%
|
|
374
|
+
|
|
375
|
+
// 与文本色混合 (变深)
|
|
376
|
+
co-main-b-sm // 主色 + 文本色 10%
|
|
377
|
+
co-main-b-mm // 主色 + 文本色 20%
|
|
378
|
+
co-main-b-ml // 主色 + 文本色 30%
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### 边框样式
|
|
382
|
+
|
|
383
|
+
```scss
|
|
384
|
+
// 边框宽度
|
|
385
|
+
bt-xs, br-xs, bb-xs, bl-xs // 0.5px
|
|
386
|
+
bt-ss, br-ss, bb-ss, bl-ss // 1px
|
|
387
|
+
bt-sm, br-sm, bb-sm, bl-sm // 2px
|
|
388
|
+
|
|
389
|
+
// 边框样式
|
|
390
|
+
b-solid // 实线
|
|
391
|
+
b-dashed // 虚线
|
|
392
|
+
b-dotted // 点线
|
|
393
|
+
b-none // 无边框
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### 主题切换
|
|
397
|
+
|
|
398
|
+
```html
|
|
399
|
+
<!-- 切换全局主题 -->
|
|
400
|
+
<html theme="light"> <!-- 浅色主题 -->
|
|
401
|
+
<html theme="dark"> <!-- 深色主题 -->
|
|
402
|
+
|
|
403
|
+
<!-- 所有颜色自动切换,0 行额外代码! -->
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### 颜色使用示例
|
|
407
|
+
|
|
408
|
+
```html
|
|
409
|
+
<!-- 主色按钮 -->
|
|
410
|
+
<button class="bg-main co-case">主操作</button>
|
|
411
|
+
|
|
412
|
+
<!-- 危险操作 -->
|
|
413
|
+
<button class="bg-risk co-case">删除</button>
|
|
414
|
+
|
|
415
|
+
<!-- 卡片 -->
|
|
416
|
+
<div class="bg-fore co-text n-mm r-sm">
|
|
417
|
+
<h3 class="co-main">标题</h3>
|
|
418
|
+
<p class="co-desc">描述文字</p>
|
|
419
|
+
<span class="co-note">注释信息</span>
|
|
420
|
+
</div>
|
|
421
|
+
|
|
422
|
+
<!-- 分割线 -->
|
|
423
|
+
<div class="bt-xs bk-line"></div>
|
|
424
|
+
|
|
425
|
+
<!-- Hover 透明度 -->
|
|
426
|
+
<a class="co-main co-main-o-lm:hover">链接</a>
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## 布局系统
|
|
432
|
+
|
|
433
|
+
### ui-flex:空间坐标布局
|
|
434
|
+
|
|
435
|
+
#### 核心理念
|
|
436
|
+
|
|
437
|
+
**废除 flexbox 概念,用空间坐标直接描述位置!**
|
|
438
|
+
|
|
439
|
+
```
|
|
440
|
+
传统思维: display: flex + justify-content + align-items
|
|
441
|
+
NeatUI 思维: ui-flex="横向 纵向"
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
#### 坐标系规则
|
|
445
|
+
|
|
446
|
+
```
|
|
447
|
+
横轴 (X-axis):
|
|
448
|
+
l = Left (左对齐)
|
|
449
|
+
c = Center (居中)
|
|
450
|
+
r = Right (右对齐)
|
|
451
|
+
x = Space-Between (两端分布)
|
|
452
|
+
a = Space-Around (平均分布)
|
|
453
|
+
|
|
454
|
+
纵轴 (Y-axis):
|
|
455
|
+
t = Top (顶部对齐)
|
|
456
|
+
m = Middle (垂直居中)
|
|
457
|
+
b = Bottom (底部对齐)
|
|
458
|
+
y = Space-Between (两端分布)
|
|
459
|
+
d = Space-Around (平均分布)
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
#### 语法格式
|
|
463
|
+
|
|
464
|
+
```html
|
|
465
|
+
ui-flex="{direction} {x}{y}"
|
|
466
|
+
|
|
467
|
+
direction:
|
|
468
|
+
row (默认,横向排列)
|
|
469
|
+
col (纵向排列)
|
|
470
|
+
|
|
471
|
+
x: 横向对齐
|
|
472
|
+
y: 纵向对齐
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
#### 常用组合(九宫格)
|
|
476
|
+
|
|
477
|
+
```
|
|
478
|
+
横向布局:
|
|
479
|
+
ui-flex="row lt" → 左上
|
|
480
|
+
ui-flex="row ct" → 中上
|
|
481
|
+
ui-flex="row rt" → 右上
|
|
482
|
+
ui-flex="row lm" → 左中
|
|
483
|
+
ui-flex="row cm" → 居中
|
|
484
|
+
ui-flex="row rm" → 右中
|
|
485
|
+
ui-flex="row lb" → 左下
|
|
486
|
+
ui-flex="row cb" → 中下
|
|
487
|
+
ui-flex="row rb" → 右下
|
|
488
|
+
|
|
489
|
+
纵向布局:
|
|
490
|
+
ui-flex="col lt" → 顶部左对齐
|
|
491
|
+
ui-flex="col cm" → 垂直水平居中
|
|
492
|
+
ui-flex="col rb" → 底部右对齐
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
#### 特殊组合
|
|
496
|
+
|
|
497
|
+
```html
|
|
498
|
+
<!-- 两端分布 + 垂直居中 (导航栏最常用) -->
|
|
499
|
+
<nav ui-flex="row xm">
|
|
500
|
+
<div>Logo</div>
|
|
501
|
+
<div>Menu</div>
|
|
502
|
+
</nav>
|
|
503
|
+
|
|
504
|
+
<!-- 垂直两端分布 + 水平居中 -->
|
|
505
|
+
<div ui-flex="col yc">
|
|
506
|
+
<header>顶部</header>
|
|
507
|
+
<footer>底部</footer>
|
|
508
|
+
</div>
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
#### 实战对比
|
|
512
|
+
|
|
513
|
+
**场景 1: 导航栏**
|
|
514
|
+
```html
|
|
515
|
+
<!-- Tailwind: 需要理解 flexbox -->
|
|
516
|
+
<nav class="flex justify-between items-center px-4 py-2">
|
|
517
|
+
<div>Logo</div>
|
|
518
|
+
<div>Menu</div>
|
|
519
|
+
</nav>
|
|
520
|
+
|
|
521
|
+
<!-- NeatUI: 空间直觉 -->
|
|
522
|
+
<nav ui-flex="row xm" class="nx-sm ny-sm">
|
|
523
|
+
<div>Logo</div>
|
|
524
|
+
<div>Menu</div>
|
|
525
|
+
</nav>
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
**场景 2: 居中对话框**
|
|
529
|
+
```html
|
|
530
|
+
<!-- Tailwind -->
|
|
531
|
+
<div class="flex justify-center items-center min-h-screen">
|
|
532
|
+
<div class="bg-white p-6">内容</div>
|
|
533
|
+
</div>
|
|
534
|
+
|
|
535
|
+
<!-- NeatUI -->
|
|
536
|
+
<div ui-flex="row cm" class="h-screen">
|
|
537
|
+
<div class="bg-fore n-ml">内容</div>
|
|
538
|
+
</div>
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
**场景 3: 卡片布局**
|
|
542
|
+
```html
|
|
543
|
+
<!-- Tailwind -->
|
|
544
|
+
<div class="flex flex-col items-center p-4">
|
|
545
|
+
<img class="w-16 h-16 rounded-full" />
|
|
546
|
+
<h3 class="mt-2">标题</h3>
|
|
547
|
+
<button class="mt-4">按钮</button>
|
|
548
|
+
</div>
|
|
549
|
+
|
|
550
|
+
<!-- NeatUI -->
|
|
551
|
+
<div ui-flex="col cm" class="n-sm">
|
|
552
|
+
<div ui-img="sz:sl :round">
|
|
553
|
+
<img />
|
|
554
|
+
</div>
|
|
555
|
+
<h3 class="mt-ss">标题</h3>
|
|
556
|
+
<button class="mt-ms" ui-btn="main">按钮</button>
|
|
557
|
+
</div>
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
### ui-grid:响应式网格
|
|
561
|
+
|
|
562
|
+
#### 语法格式
|
|
563
|
+
|
|
564
|
+
```html
|
|
565
|
+
ui-grid="{breakpoint}:{columns} {gap}"
|
|
566
|
+
|
|
567
|
+
breakpoint:
|
|
568
|
+
mob (移动端)
|
|
569
|
+
pad (平板)
|
|
570
|
+
dpc (桌面)
|
|
571
|
+
|
|
572
|
+
columns: 列数 (1-12)
|
|
573
|
+
gap: 间距等级 (ss, sm, mm, ml, ll...)
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
#### 基础用法
|
|
577
|
+
|
|
578
|
+
```html
|
|
579
|
+
<!-- 固定 3 列,间距 medium-large -->
|
|
580
|
+
<div ui-grid="3 ml">
|
|
581
|
+
<div>Item 1</div>
|
|
582
|
+
<div>Item 2</div>
|
|
583
|
+
<div>Item 3</div>
|
|
584
|
+
</div>
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
#### 响应式网格
|
|
588
|
+
|
|
589
|
+
```html
|
|
590
|
+
<!-- 移动端 1 列,平板 3 列,桌面 5 列 -->
|
|
591
|
+
<div ui-grid="mob:1 pad:3 dpc:5 ml">
|
|
592
|
+
<div>Item 1</div>
|
|
593
|
+
<div>Item 2</div>
|
|
594
|
+
<div>Item 3</div>
|
|
595
|
+
<div>Item 4</div>
|
|
596
|
+
<div>Item 5</div>
|
|
597
|
+
</div>
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
#### 实战示例
|
|
601
|
+
|
|
602
|
+
**产品列表**
|
|
603
|
+
```html
|
|
604
|
+
<ul ui-grid="mob:1 pad:2 dpc:4 mm" class="my-lm">
|
|
605
|
+
<li class="bg-fore n-mm r-sm" v-for="product in products">
|
|
606
|
+
<img :src="product.image" />
|
|
607
|
+
<h3 class="co-main fs-ml">{{ product.name }}</h3>
|
|
608
|
+
<p class="co-desc">{{ product.desc }}</p>
|
|
609
|
+
<button ui-btn="main s">购买</button>
|
|
610
|
+
</li>
|
|
611
|
+
</ul>
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## 响应式系统
|
|
617
|
+
|
|
618
|
+
### 9 档精细断点
|
|
619
|
+
|
|
620
|
+
NeatUI 采用 **3×3 分形响应系统**:
|
|
621
|
+
|
|
622
|
+
```scss
|
|
623
|
+
// 移动端 (Mobile) 3 档
|
|
624
|
+
mob-s: 320px // 小手机 (iPhone SE)
|
|
625
|
+
mob-m: 480px // 中手机 (iPhone 13)
|
|
626
|
+
mob-l: 640px // 大手机 (iPhone Pro Max)
|
|
627
|
+
|
|
628
|
+
// 平板 (Pad) 3 档
|
|
629
|
+
pad-s: 800px // 小平板 (iPad Mini)
|
|
630
|
+
pad-m: 960px // 中平板 (iPad)
|
|
631
|
+
pad-l: 1120px // 大平板 (iPad Pro)
|
|
632
|
+
|
|
633
|
+
// 桌面 (Desktop) 3 档
|
|
634
|
+
dpc-s: 1280px // 小桌面 (13寸 MacBook)
|
|
635
|
+
dpc-m: 1440px // 中桌面 (主流显示器)
|
|
636
|
+
dpc-l: 1600px // 大桌面 (2K 显示器)
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### 三种操作符
|
|
640
|
+
|
|
641
|
+
#### 1. `>` 大于(min-width)
|
|
642
|
+
|
|
643
|
+
```html
|
|
644
|
+
<!-- 平板以上显示 -->
|
|
645
|
+
<div class="pad:w-mm">内容</div>
|
|
646
|
+
|
|
647
|
+
<!-- 桌面以上隐藏 -->
|
|
648
|
+
<div ui-hide=">dpc">移动端专属</div>
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
#### 2. `<` 小于(max-width)
|
|
652
|
+
|
|
653
|
+
```html
|
|
654
|
+
<!-- 桌面以下隐藏 -->
|
|
655
|
+
<div ui-hide="<dpc">桌面专属</div>
|
|
656
|
+
|
|
657
|
+
<!-- 平板以下宽度 100% -->
|
|
658
|
+
<div class="w-full <pad:w-mm">响应式容器</div>
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
#### 3. `=` 精确区间
|
|
662
|
+
|
|
663
|
+
```html
|
|
664
|
+
<!-- 仅在中平板显示 (960px-1119px) -->
|
|
665
|
+
<div ui-hide="=pad-m">仅中平板隐藏</div>
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
### 断点类名语法
|
|
669
|
+
|
|
670
|
+
```scss
|
|
671
|
+
// 格式: {breakpoint}:{class-name}
|
|
672
|
+
mob:fs-sm // 移动端字号小
|
|
673
|
+
pad:fs-mm // 平板字号中
|
|
674
|
+
dpc:fs-lm // 桌面字号大
|
|
675
|
+
|
|
676
|
+
// 组合使用
|
|
677
|
+
<h1 class="fs-sm mob:fs-mm pad:fs-ml dpc:fs-xl">
|
|
678
|
+
响应式标题
|
|
679
|
+
</h1>
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
### ui-hide:显示/隐藏控制
|
|
683
|
+
|
|
684
|
+
```html
|
|
685
|
+
<!-- 移动端隐藏 -->
|
|
686
|
+
<div ui-hide="mob">桌面内容</div>
|
|
687
|
+
|
|
688
|
+
<!-- 桌面隐藏 -->
|
|
689
|
+
<div ui-hide="dpc">移动内容</div>
|
|
690
|
+
|
|
691
|
+
<!-- 小于平板隐藏 -->
|
|
692
|
+
<div ui-hide="<pad">平板以上显示</div>
|
|
693
|
+
|
|
694
|
+
<!-- 大于手机隐藏 -->
|
|
695
|
+
<div ui-hide=">mob">仅手机显示</div>
|
|
696
|
+
|
|
697
|
+
<!-- 精确区间隐藏 -->
|
|
698
|
+
<div ui-hide="=pad-m">仅在中平板隐藏</div>
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
### 全局字号响应(革命性功能)
|
|
702
|
+
|
|
703
|
+
```html
|
|
704
|
+
<!-- 在 <html> 标签设置全局字号 -->
|
|
705
|
+
<html size="s"> <!-- 小字号模式 -->
|
|
706
|
+
<html size="m"> <!-- 默认字号 -->
|
|
707
|
+
<html size="l"> <!-- 大字号模式 -->
|
|
708
|
+
<html size="xl"> <!-- 超大字号模式 (老年模式) -->
|
|
709
|
+
|
|
710
|
+
<!-- 所有使用 em 单位的元素自动缩放! -->
|
|
711
|
+
<!-- 0 行 CSS,0 个媒体查询,全站响应! -->
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
**实战用例:老年人模式**
|
|
715
|
+
```vue
|
|
716
|
+
<script setup>
|
|
717
|
+
const fontSize = ref('m')
|
|
718
|
+
|
|
719
|
+
function toggleElderlyMode() {
|
|
720
|
+
fontSize.value = fontSize.value === 'm' ? 'xl' : 'm'
|
|
721
|
+
}
|
|
722
|
+
</script>
|
|
723
|
+
|
|
724
|
+
<template>
|
|
725
|
+
<html :size="fontSize">
|
|
726
|
+
<button @click="toggleElderlyMode">
|
|
727
|
+
切换大字模式
|
|
728
|
+
</button>
|
|
729
|
+
|
|
730
|
+
<!-- 所有内容自动放大,无需额外代码! -->
|
|
731
|
+
</html>
|
|
732
|
+
</template>
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
### 响应式实战示例
|
|
736
|
+
|
|
737
|
+
**场景:响应式导航**
|
|
738
|
+
```html
|
|
739
|
+
<nav ui-flex="row xm" class="nx-mm ny-sm">
|
|
740
|
+
<!-- Logo -->
|
|
741
|
+
<div class="fs-ml">Logo</div>
|
|
742
|
+
|
|
743
|
+
<!-- 桌面菜单 -->
|
|
744
|
+
<ul ui-flex="row lm" ui-hide="<pad">
|
|
745
|
+
<li class="mx-sm">首页</li>
|
|
746
|
+
<li class="mx-sm">产品</li>
|
|
747
|
+
<li class="mx-sm">关于</li>
|
|
748
|
+
</ul>
|
|
749
|
+
|
|
750
|
+
<!-- 移动端汉堡按钮 -->
|
|
751
|
+
<button ui-hide=">mob" ui-btn="none s">
|
|
752
|
+
<i class="icon-menu"></i>
|
|
753
|
+
</button>
|
|
754
|
+
</nav>
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
---
|
|
758
|
+
|
|
759
|
+
## 按钮系统
|
|
760
|
+
|
|
761
|
+
### ui-btn 语法
|
|
762
|
+
|
|
763
|
+
```html
|
|
764
|
+
ui-btn="[@{flag}] {color} {size} [:{modifier}]"
|
|
765
|
+
|
|
766
|
+
@{flag}:
|
|
767
|
+
@a = 块级按钮 (width: 100%)
|
|
768
|
+
@i = 内联按钮 (inline-flex)
|
|
769
|
+
|
|
770
|
+
{color}:
|
|
771
|
+
main, vice, well, warn, risk, info, none
|
|
772
|
+
|
|
773
|
+
{size}:
|
|
774
|
+
s, m (默认), l
|
|
775
|
+
|
|
776
|
+
:{modifier}:
|
|
777
|
+
:round = 圆形按钮
|
|
778
|
+
:border = 边框按钮
|
|
779
|
+
:text = 文本按钮
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
### 基础按钮
|
|
783
|
+
|
|
784
|
+
```html
|
|
785
|
+
<!-- 主色按钮 -->
|
|
786
|
+
<button ui-btn="main">主操作</button>
|
|
787
|
+
|
|
788
|
+
<!-- 辅助色按钮 -->
|
|
789
|
+
<button ui-btn="vice">次要操作</button>
|
|
790
|
+
|
|
791
|
+
<!-- 成功按钮 -->
|
|
792
|
+
<button ui-btn="well">提交</button>
|
|
793
|
+
|
|
794
|
+
<!-- 警告按钮 -->
|
|
795
|
+
<button ui-btn="warn">警告</button>
|
|
796
|
+
|
|
797
|
+
<!-- 危险按钮 -->
|
|
798
|
+
<button ui-btn="risk">删除</button>
|
|
799
|
+
|
|
800
|
+
<!-- 信息按钮 -->
|
|
801
|
+
<button ui-btn="info">详情</button>
|
|
802
|
+
|
|
803
|
+
<!-- 无样式按钮 -->
|
|
804
|
+
<button ui-btn="none">纯文本</button>
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
### 尺寸变体
|
|
808
|
+
|
|
809
|
+
```html
|
|
810
|
+
<button ui-btn="main s">小按钮</button>
|
|
811
|
+
<button ui-btn="main m">中按钮</button>
|
|
812
|
+
<button ui-btn="main l">大按钮</button>
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
### 块级按钮
|
|
816
|
+
|
|
817
|
+
```html
|
|
818
|
+
<!-- 100% 宽度 -->
|
|
819
|
+
<button ui-btn="@a main">登录</button>
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
### 样式修饰符
|
|
823
|
+
|
|
824
|
+
```html
|
|
825
|
+
<!-- 圆形按钮 -->
|
|
826
|
+
<button ui-btn="main :round">
|
|
827
|
+
<i class="icon-check"></i>
|
|
828
|
+
</button>
|
|
829
|
+
|
|
830
|
+
<!-- 边框按钮 -->
|
|
831
|
+
<button ui-btn="main :border">边框样式</button>
|
|
832
|
+
|
|
833
|
+
<!-- 文本按钮 -->
|
|
834
|
+
<button ui-btn="main :text">文本链接</button>
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
### 组合使用
|
|
838
|
+
|
|
839
|
+
```html
|
|
840
|
+
<!-- 块级 + 大尺寸 + 圆形 -->
|
|
841
|
+
<button ui-btn="@a main l :round">提交订单</button>
|
|
842
|
+
|
|
843
|
+
<!-- 小尺寸 + 边框 -->
|
|
844
|
+
<button ui-btn="vice s :border">取消</button>
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
### 按钮组
|
|
848
|
+
|
|
849
|
+
```html
|
|
850
|
+
<div ui-flex="row lm">
|
|
851
|
+
<button ui-btn="main">确定</button>
|
|
852
|
+
<button ui-btn="none :border" class="ml-sm">取消</button>
|
|
853
|
+
</div>
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
---
|
|
857
|
+
|
|
858
|
+
## 完整 API 参考
|
|
859
|
+
|
|
860
|
+
### 间距类 (Spacing)
|
|
861
|
+
|
|
862
|
+
#### Padding
|
|
863
|
+
|
|
864
|
+
| 类名 | 属性 | 值 |
|
|
865
|
+
|-----|------|------|
|
|
866
|
+
| `n-no` | padding | 0 |
|
|
867
|
+
| `n-xs` | padding | 0.5em |
|
|
868
|
+
| `n-ss` | padding | 0.75em |
|
|
869
|
+
| `n-sm` | padding | 1em |
|
|
870
|
+
| `n-sl` | padding | 1.25em |
|
|
871
|
+
| `n-ms` | padding | 1.5em |
|
|
872
|
+
| `n-mm` | padding | 2em |
|
|
873
|
+
| `n-ml` | padding | 2.5em |
|
|
874
|
+
| `n-ls` | padding | 3em |
|
|
875
|
+
| `n-lm` | padding | 4em |
|
|
876
|
+
| `n-ll` | padding | 6em |
|
|
877
|
+
| `n-xl` | padding | 8em |
|
|
878
|
+
|
|
879
|
+
#### 方向 Padding
|
|
880
|
+
|
|
881
|
+
```scss
|
|
882
|
+
nx-{size} // padding-left + padding-right
|
|
883
|
+
ny-{size} // padding-top + padding-bottom
|
|
884
|
+
nt-{size} // padding-top
|
|
885
|
+
nr-{size} // padding-right
|
|
886
|
+
nb-{size} // padding-bottom
|
|
887
|
+
nl-{size} // padding-left
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
#### Margin
|
|
891
|
+
|
|
892
|
+
```scss
|
|
893
|
+
m-{size} // margin 全方向
|
|
894
|
+
mx-{size} // margin-left + margin-right
|
|
895
|
+
my-{size} // margin-top + margin-bottom
|
|
896
|
+
mt-{size} // margin-top
|
|
897
|
+
mr-{size} // margin-right
|
|
898
|
+
mb-{size} // margin-bottom
|
|
899
|
+
ml-{size} // margin-left
|
|
900
|
+
|
|
901
|
+
// 特殊值
|
|
902
|
+
m-auto // margin: auto
|
|
903
|
+
mx-auto // margin-left/right: auto (水平居中)
|
|
904
|
+
my-auto // margin-top/bottom: auto
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
#### 负 Margin
|
|
908
|
+
|
|
909
|
+
```scss
|
|
910
|
+
mx-sm-sub // margin-left/right: -1em
|
|
911
|
+
my-sm-sub // margin-top/bottom: -1em
|
|
912
|
+
mt-sm-sub // margin-top: -1em
|
|
913
|
+
// 所有尺寸都支持 -sub 后缀
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
### 尺寸类 (Sizing)
|
|
917
|
+
|
|
918
|
+
#### Width
|
|
919
|
+
|
|
920
|
+
```scss
|
|
921
|
+
w-no // 0
|
|
922
|
+
w-xs // 0.5em
|
|
923
|
+
w-ss ~ w-xl // 0.75em ~ 8em
|
|
924
|
+
|
|
925
|
+
// 修饰符
|
|
926
|
+
w-ll+ // 7em (增量)
|
|
927
|
+
w-ll*s // 12em (2倍)
|
|
928
|
+
w-ll*m // 18em (3倍)
|
|
929
|
+
w-ll*l // 24em (4倍)
|
|
930
|
+
|
|
931
|
+
// 特殊值
|
|
932
|
+
w-full // 100%
|
|
933
|
+
w-auto // auto
|
|
934
|
+
w-screen // 100vw
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
#### Height
|
|
938
|
+
|
|
939
|
+
```scss
|
|
940
|
+
h-{size} // 同 width
|
|
941
|
+
h-full // 100%
|
|
942
|
+
h-auto // auto
|
|
943
|
+
h-screen // 100vh
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
### 圆角类 (Border Radius)
|
|
947
|
+
|
|
948
|
+
```scss
|
|
949
|
+
r-no // border-radius: 0
|
|
950
|
+
r-xs // 0.5em
|
|
951
|
+
r-ss ~ r-xl // 0.75em ~ 8em
|
|
952
|
+
r-round // 50% (圆形)
|
|
953
|
+
|
|
954
|
+
// 方向圆角
|
|
955
|
+
rt-{size} // 左上
|
|
956
|
+
rr-{size} // 右上
|
|
957
|
+
rb-{size} // 右下
|
|
958
|
+
rl-{size} // 左下
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
### 字体类 (Typography)
|
|
962
|
+
|
|
963
|
+
```scss
|
|
964
|
+
// 字号
|
|
965
|
+
fs-no // 0
|
|
966
|
+
fs-xs // 0.5em
|
|
967
|
+
fs-ss ~ fs-xl // 0.75em ~ 8em
|
|
968
|
+
|
|
969
|
+
// 字重
|
|
970
|
+
thin // font-weight: 100
|
|
971
|
+
light // 300
|
|
972
|
+
normal // 400
|
|
973
|
+
bold // 700
|
|
974
|
+
bolder // 900
|
|
975
|
+
|
|
976
|
+
// 对齐
|
|
977
|
+
text-left
|
|
978
|
+
text-center
|
|
979
|
+
text-right
|
|
980
|
+
text-justify
|
|
981
|
+
|
|
982
|
+
// 行高
|
|
983
|
+
lh-xs ~ lh-xl // line-height
|
|
984
|
+
|
|
985
|
+
// 字母间距
|
|
986
|
+
ls-xs ~ ls-xl // letter-spacing
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
### 边框类 (Border)
|
|
990
|
+
|
|
991
|
+
```scss
|
|
992
|
+
// 宽度
|
|
993
|
+
bt-xs, br-xs, bb-xs, bl-xs // 0.5px
|
|
994
|
+
bt-ss, br-ss, bb-ss, bl-ss // 1px
|
|
995
|
+
bt-sm, br-sm, bb-sm, bl-sm // 2px
|
|
996
|
+
|
|
997
|
+
// 样式
|
|
998
|
+
b-solid
|
|
999
|
+
b-dashed
|
|
1000
|
+
b-dotted
|
|
1001
|
+
b-none
|
|
1002
|
+
|
|
1003
|
+
// 边框颜色
|
|
1004
|
+
bk-main, bk-vice, bk-risk...
|
|
1005
|
+
bk-line, bk-weak
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
### 定位类 (Position)
|
|
1009
|
+
|
|
1010
|
+
```scss
|
|
1011
|
+
// 定位类型
|
|
1012
|
+
pf // position: fixed
|
|
1013
|
+
pa // position: absolute
|
|
1014
|
+
pr // position: relative
|
|
1015
|
+
ps // position: sticky
|
|
1016
|
+
|
|
1017
|
+
// 偏移
|
|
1018
|
+
ot-no // top: 0
|
|
1019
|
+
or-no // right: 0
|
|
1020
|
+
ob-no // bottom: 0
|
|
1021
|
+
ol-no // left: 0
|
|
1022
|
+
|
|
1023
|
+
ot-xs ~ ot-xl // top
|
|
1024
|
+
or-xs ~ or-xl // right
|
|
1025
|
+
ob-xs ~ ob-xl // bottom
|
|
1026
|
+
ol-xs ~ ol-xl // left
|
|
1027
|
+
```
|
|
1028
|
+
|
|
1029
|
+
### Z轴类 (Z-Index)
|
|
1030
|
+
|
|
1031
|
+
```scss
|
|
1032
|
+
z-xs // z-index: 10
|
|
1033
|
+
z-ss // 20
|
|
1034
|
+
z-sm // 30
|
|
1035
|
+
z-mm // 50
|
|
1036
|
+
z-ml // 70
|
|
1037
|
+
z-ll // 90
|
|
1038
|
+
z-xl // 100
|
|
1039
|
+
```
|
|
1040
|
+
|
|
1041
|
+
### 阴影类 (Shadow)
|
|
1042
|
+
|
|
1043
|
+
```scss
|
|
1044
|
+
shadow-xs // 浅阴影
|
|
1045
|
+
shadow-sm
|
|
1046
|
+
shadow-mm // 默认阴影
|
|
1047
|
+
shadow-ml
|
|
1048
|
+
shadow-ll // 深阴影
|
|
1049
|
+
shadow-none // 无阴影
|
|
1050
|
+
```
|
|
1051
|
+
|
|
1052
|
+
### 显示类 (Display)
|
|
1053
|
+
|
|
1054
|
+
```scss
|
|
1055
|
+
block // display: block
|
|
1056
|
+
inline // display: inline
|
|
1057
|
+
inline-block
|
|
1058
|
+
flex // display: flex (推荐用 ui-flex)
|
|
1059
|
+
grid // display: grid (推荐用 ui-grid)
|
|
1060
|
+
hidden // display: none
|
|
1061
|
+
|
|
1062
|
+
// Flex 子项
|
|
1063
|
+
flex-block // flex: 1
|
|
1064
|
+
flex-auto // flex: auto
|
|
1065
|
+
flex-none // flex: none
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
### 溢出类 (Overflow)
|
|
1069
|
+
|
|
1070
|
+
```scss
|
|
1071
|
+
overflow-auto
|
|
1072
|
+
overflow-hidden
|
|
1073
|
+
overflow-scroll
|
|
1074
|
+
overflow-x-auto
|
|
1075
|
+
overflow-y-auto
|
|
1076
|
+
overflow-x-hidden
|
|
1077
|
+
overflow-y-hidden
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
### 光标类 (Cursor)
|
|
1081
|
+
|
|
1082
|
+
```scss
|
|
1083
|
+
cursor-pointer
|
|
1084
|
+
cursor-default
|
|
1085
|
+
cursor-not-allowed
|
|
1086
|
+
cursor-text
|
|
1087
|
+
cursor-move
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
### 交互类 (Interaction)
|
|
1091
|
+
|
|
1092
|
+
```scss
|
|
1093
|
+
pointer-events-none
|
|
1094
|
+
pointer-events-auto
|
|
1095
|
+
user-select-none
|
|
1096
|
+
user-select-text
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
---
|
|
1100
|
+
|
|
1101
|
+
## 最佳实践
|
|
1102
|
+
|
|
1103
|
+
### 1. 严格遵守设计系统
|
|
1104
|
+
|
|
1105
|
+
```html
|
|
1106
|
+
<!-- ❌ 错误:使用任意值 -->
|
|
1107
|
+
<div style="padding: 13px; width: 237px;">
|
|
1108
|
+
|
|
1109
|
+
<!-- ✅ 正确:使用规范尺寸 -->
|
|
1110
|
+
<div class="n-sm w-ll+">
|
|
1111
|
+
|
|
1112
|
+
<!-- 如果确实需要特殊值,手写并注释 -->
|
|
1113
|
+
<div class="third-party" style="width: 237px">
|
|
1114
|
+
<!-- 注释:第三方组件要求,见文档 #123 -->
|
|
1115
|
+
</div>
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
### 2. 优先使用语义色
|
|
1119
|
+
|
|
1120
|
+
```html
|
|
1121
|
+
<!-- ❌ 错误:使用色值 -->
|
|
1122
|
+
<button style="background: #00b277; color: white;">
|
|
1123
|
+
|
|
1124
|
+
<!-- ✅ 正确:使用语义色 -->
|
|
1125
|
+
<button class="bg-main co-case">
|
|
1126
|
+
|
|
1127
|
+
<!-- ❌ 错误:使用通用灰色 -->
|
|
1128
|
+
<p class="text-gray-600">
|
|
1129
|
+
|
|
1130
|
+
<!-- ✅ 正确:使用语义灰 -->
|
|
1131
|
+
<p class="co-desc">
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
### 3. 布局用空间思维
|
|
1135
|
+
|
|
1136
|
+
```html
|
|
1137
|
+
<!-- ❌ 错误:用 CSS 属性思维 -->
|
|
1138
|
+
<div class="flex justify-between items-center">
|
|
1139
|
+
|
|
1140
|
+
<!-- ✅ 正确:用空间坐标思维 -->
|
|
1141
|
+
<div ui-flex="row xm">
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
### 4. 响应式用断点系统
|
|
1145
|
+
|
|
1146
|
+
```html
|
|
1147
|
+
<!-- ❌ 错误:手写媒体查询 -->
|
|
1148
|
+
<style>
|
|
1149
|
+
@media (max-width: 768px) {
|
|
1150
|
+
.title { font-size: 1.5rem; }
|
|
1151
|
+
}
|
|
1152
|
+
</style>
|
|
1153
|
+
|
|
1154
|
+
<!-- ✅ 正确:用断点类 -->
|
|
1155
|
+
<h1 class="fs-xl mob:fs-lm">标题</h1>
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
### 5. 组件化常用模式
|
|
1159
|
+
|
|
1160
|
+
```vue
|
|
1161
|
+
<!-- 封装常用卡片 -->
|
|
1162
|
+
<template>
|
|
1163
|
+
<div class="card bg-fore n-mm r-sm shadow-sm">
|
|
1164
|
+
<slot />
|
|
1165
|
+
</div>
|
|
1166
|
+
</template>
|
|
1167
|
+
|
|
1168
|
+
<!-- 使用 -->
|
|
1169
|
+
<Card>
|
|
1170
|
+
<h3 class="co-main">标题</h3>
|
|
1171
|
+
<p class="co-desc">内容</p>
|
|
1172
|
+
</Card>
|
|
1173
|
+
```
|
|
1174
|
+
|
|
1175
|
+
### 6. 深色模式零成本
|
|
1176
|
+
|
|
1177
|
+
```html
|
|
1178
|
+
<!-- 只需切换 theme 属性 -->
|
|
1179
|
+
<html :theme="isDark ? 'dark' : 'light'">
|
|
1180
|
+
|
|
1181
|
+
<!-- 所有颜色自动切换,无需额外代码 -->
|
|
1182
|
+
<div class="bg-fore co-text">
|
|
1183
|
+
<h1 class="co-main">自动适配</h1>
|
|
1184
|
+
</div>
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
---
|
|
1188
|
+
|
|
1189
|
+
## 常见场景
|
|
1190
|
+
|
|
1191
|
+
### 场景 1: 登录页面
|
|
1192
|
+
|
|
1193
|
+
```html
|
|
1194
|
+
<div ui-flex="row cm" class="h-screen bg-weak">
|
|
1195
|
+
<div class="w-ll*s bg-fore n-ll r-ml shadow-ml">
|
|
1196
|
+
<h1 class="fs-xl bold co-main text-center">登录</h1>
|
|
1197
|
+
|
|
1198
|
+
<form class="mt-lm">
|
|
1199
|
+
<div class="mb-mm">
|
|
1200
|
+
<label class="co-desc fs-sm">邮箱</label>
|
|
1201
|
+
<input
|
|
1202
|
+
type="email"
|
|
1203
|
+
class="w-full n-sm r-sm bg-weak bk-line bt-xs"
|
|
1204
|
+
/>
|
|
1205
|
+
</div>
|
|
1206
|
+
|
|
1207
|
+
<div class="mb-mm">
|
|
1208
|
+
<label class="co-desc fs-sm">密码</label>
|
|
1209
|
+
<input
|
|
1210
|
+
type="password"
|
|
1211
|
+
class="w-full n-sm r-sm bg-weak bk-line bt-xs"
|
|
1212
|
+
/>
|
|
1213
|
+
</div>
|
|
1214
|
+
|
|
1215
|
+
<button ui-btn="@a main l" class="mt-ml">
|
|
1216
|
+
登录
|
|
1217
|
+
</button>
|
|
1218
|
+
</form>
|
|
1219
|
+
</div>
|
|
1220
|
+
</div>
|
|
1221
|
+
```
|
|
1222
|
+
|
|
1223
|
+
### 场景 2: 产品卡片网格
|
|
1224
|
+
|
|
1225
|
+
```html
|
|
1226
|
+
<div class="doc my-lm">
|
|
1227
|
+
<h2 class="fs-xl bold co-main mb-ml">热门产品</h2>
|
|
1228
|
+
|
|
1229
|
+
<ul ui-grid="mob:1 pad:2 dpc:4 ml">
|
|
1230
|
+
<li
|
|
1231
|
+
v-for="product in products"
|
|
1232
|
+
:key="product.id"
|
|
1233
|
+
class="bg-fore r-sm shadow-sm"
|
|
1234
|
+
>
|
|
1235
|
+
<img :src="product.image" class="w-full h-auto" />
|
|
1236
|
+
|
|
1237
|
+
<div class="n-mm">
|
|
1238
|
+
<h3 class="fs-lm bold co-text">{{ product.name }}</h3>
|
|
1239
|
+
<p class="co-desc fs-sm my-ss">{{ product.desc }}</p>
|
|
1240
|
+
|
|
1241
|
+
<div ui-flex="row xm" class="mt-mm">
|
|
1242
|
+
<span class="co-risk bold fs-ml">¥{{ product.price }}</span>
|
|
1243
|
+
<button ui-btn="main s">购买</button>
|
|
1244
|
+
</div>
|
|
1245
|
+
</div>
|
|
1246
|
+
</li>
|
|
1247
|
+
</ul>
|
|
1248
|
+
</div>
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
### 场景 3: 导航栏
|
|
1252
|
+
|
|
1253
|
+
```html
|
|
1254
|
+
<nav class="pf ot-no w-full bg-fore shadow-sm z-xl">
|
|
1255
|
+
<div class="doc" ui-flex="row xm" class="ny-sm">
|
|
1256
|
+
<!-- Logo -->
|
|
1257
|
+
<div ui-flex="row lm">
|
|
1258
|
+
<i class="icon-logo fs-xl co-main"></i>
|
|
1259
|
+
<span class="fs-ml bold co-text ml-sm">LabelWork</span>
|
|
1260
|
+
</div>
|
|
1261
|
+
|
|
1262
|
+
<!-- 桌面菜单 -->
|
|
1263
|
+
<ul ui-flex="row lm" ui-hide="<pad">
|
|
1264
|
+
<li class="mx-mm">
|
|
1265
|
+
<a href="/" class="co-text co-main:hover">首页</a>
|
|
1266
|
+
</li>
|
|
1267
|
+
<li class="mx-mm">
|
|
1268
|
+
<a href="/products" class="co-text co-main:hover">产品</a>
|
|
1269
|
+
</li>
|
|
1270
|
+
<li class="mx-mm">
|
|
1271
|
+
<a href="/about" class="co-text co-main:hover">关于</a>
|
|
1272
|
+
</li>
|
|
1273
|
+
</ul>
|
|
1274
|
+
|
|
1275
|
+
<!-- 操作按钮 -->
|
|
1276
|
+
<div ui-flex="row lm">
|
|
1277
|
+
<button ui-btn="vice s :border" class="mr-sm">登录</button>
|
|
1278
|
+
<button ui-btn="main s">注册</button>
|
|
1279
|
+
</div>
|
|
1280
|
+
|
|
1281
|
+
<!-- 移动端汉堡菜单 -->
|
|
1282
|
+
<button ui-hide=">mob" ui-btn="none" @click="toggleMenu">
|
|
1283
|
+
<i class="icon-menu fs-ml"></i>
|
|
1284
|
+
</button>
|
|
1285
|
+
</div>
|
|
1286
|
+
</nav>
|
|
1287
|
+
```
|
|
1288
|
+
|
|
1289
|
+
### 场景 4: 对话框
|
|
1290
|
+
|
|
1291
|
+
```html
|
|
1292
|
+
<div
|
|
1293
|
+
v-if="showDialog"
|
|
1294
|
+
class="pf ot-no ol-no w-full h-full bg-text-o-lm z-xl"
|
|
1295
|
+
ui-flex="row cm"
|
|
1296
|
+
@click.self="closeDialog"
|
|
1297
|
+
>
|
|
1298
|
+
<div class="w-ll*s bg-fore r-ml shadow-ll">
|
|
1299
|
+
<!-- 头部 -->
|
|
1300
|
+
<div class="n-mm bb-xs bk-line" ui-flex="row xm">
|
|
1301
|
+
<h3 class="fs-lm bold co-main">标题</h3>
|
|
1302
|
+
<button ui-btn="none s" @click="closeDialog">
|
|
1303
|
+
<i class="icon-close"></i>
|
|
1304
|
+
</button>
|
|
1305
|
+
</div>
|
|
1306
|
+
|
|
1307
|
+
<!-- 内容 -->
|
|
1308
|
+
<div class="n-lm co-text">
|
|
1309
|
+
<p>对话框内容...</p>
|
|
1310
|
+
</div>
|
|
1311
|
+
|
|
1312
|
+
<!-- 底部 -->
|
|
1313
|
+
<div class="n-mm bt-xs bk-line" ui-flex="row rm">
|
|
1314
|
+
<button ui-btn="none :border" class="mr-sm" @click="closeDialog">
|
|
1315
|
+
取消
|
|
1316
|
+
</button>
|
|
1317
|
+
<button ui-btn="main" @click="confirm">
|
|
1318
|
+
确定
|
|
1319
|
+
</button>
|
|
1320
|
+
</div>
|
|
1321
|
+
</div>
|
|
1322
|
+
</div>
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
### 场景 5: 数据表格
|
|
1326
|
+
|
|
1327
|
+
```html
|
|
1328
|
+
<div class="bg-fore r-sm shadow-sm">
|
|
1329
|
+
<table class="w-full">
|
|
1330
|
+
<thead class="bb-xs bk-line">
|
|
1331
|
+
<tr>
|
|
1332
|
+
<th class="n-mm text-left co-desc bold">姓名</th>
|
|
1333
|
+
<th class="n-mm text-left co-desc bold">邮箱</th>
|
|
1334
|
+
<th class="n-mm text-left co-desc bold">状态</th>
|
|
1335
|
+
<th class="n-mm text-right co-desc bold">操作</th>
|
|
1336
|
+
</tr>
|
|
1337
|
+
</thead>
|
|
1338
|
+
<tbody>
|
|
1339
|
+
<tr
|
|
1340
|
+
v-for="user in users"
|
|
1341
|
+
:key="user.id"
|
|
1342
|
+
class="bb-xs bk-line"
|
|
1343
|
+
>
|
|
1344
|
+
<td class="n-mm co-text">{{ user.name }}</td>
|
|
1345
|
+
<td class="n-mm co-desc">{{ user.email }}</td>
|
|
1346
|
+
<td class="n-mm">
|
|
1347
|
+
<span class="bg-well-o-sm co-well n-ss r-sm fs-xs">
|
|
1348
|
+
活跃
|
|
1349
|
+
</span>
|
|
1350
|
+
</td>
|
|
1351
|
+
<td class="n-mm text-right">
|
|
1352
|
+
<button ui-btn="info s :text">编辑</button>
|
|
1353
|
+
<button ui-btn="risk s :text">删除</button>
|
|
1354
|
+
</td>
|
|
1355
|
+
</tr>
|
|
1356
|
+
</tbody>
|
|
1357
|
+
</table>
|
|
1358
|
+
</div>
|
|
1359
|
+
```
|
|
1360
|
+
|
|
1361
|
+
---
|
|
1362
|
+
|
|
1363
|
+
## 进阶技巧
|
|
1364
|
+
|
|
1365
|
+
### 1. 自定义主题色
|
|
1366
|
+
|
|
1367
|
+
```scss
|
|
1368
|
+
// 在 SCSS 中配置
|
|
1369
|
+
@use '@neatui/css' with (
|
|
1370
|
+
$theme: (
|
|
1371
|
+
'light': (
|
|
1372
|
+
main: #00b277, // 自定义主色
|
|
1373
|
+
vice: #67ce82,
|
|
1374
|
+
// ... 其他颜色
|
|
1375
|
+
)
|
|
1376
|
+
)
|
|
1377
|
+
);
|
|
1378
|
+
```
|
|
1379
|
+
|
|
1380
|
+
### 2. 使用 SCSS Mixin
|
|
1381
|
+
|
|
1382
|
+
```scss
|
|
1383
|
+
@use '@neatui/css' as neatui;
|
|
1384
|
+
|
|
1385
|
+
.my-component {
|
|
1386
|
+
// 响应式断点
|
|
1387
|
+
@include neatui.mob {
|
|
1388
|
+
padding: 1em;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
@include neatui.pad {
|
|
1392
|
+
padding: 2em;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
@include neatui.dpc {
|
|
1396
|
+
padding: 3em;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
```
|
|
1400
|
+
|
|
1401
|
+
### 3. 伪类修饰符
|
|
1402
|
+
|
|
1403
|
+
```html
|
|
1404
|
+
<!-- Hover -->
|
|
1405
|
+
<a class="co-main co-main-o-lm:hover">链接</a>
|
|
1406
|
+
|
|
1407
|
+
<!-- Active -->
|
|
1408
|
+
<button class="bg-main bg-main-b-sm:active">按钮</button>
|
|
1409
|
+
|
|
1410
|
+
<!-- Focus -->
|
|
1411
|
+
<input class="bk-line bk-main:focus" />
|
|
1412
|
+
|
|
1413
|
+
<!-- Disabled -->
|
|
1414
|
+
<button class="bg-weak:disabled" disabled>禁用</button>
|
|
1415
|
+
```
|
|
1416
|
+
|
|
1417
|
+
### 4. 组合类名简化
|
|
1418
|
+
|
|
1419
|
+
```vue
|
|
1420
|
+
<script setup>
|
|
1421
|
+
// 创建常用组合
|
|
1422
|
+
const cardClass = 'bg-fore n-mm r-sm shadow-sm'
|
|
1423
|
+
const titleClass = 'fs-lm bold co-main'
|
|
1424
|
+
const descClass = 'co-desc fs-sm my-ss'
|
|
1425
|
+
</script>
|
|
1426
|
+
|
|
1427
|
+
<template>
|
|
1428
|
+
<div :class="cardClass">
|
|
1429
|
+
<h3 :class="titleClass">标题</h3>
|
|
1430
|
+
<p :class="descClass">描述</p>
|
|
1431
|
+
</div>
|
|
1432
|
+
</template>
|
|
1433
|
+
```
|
|
1434
|
+
|
|
1435
|
+
---
|
|
1436
|
+
|
|
1437
|
+
## 总结
|
|
1438
|
+
|
|
1439
|
+
### NeatUI 核心价值
|
|
1440
|
+
|
|
1441
|
+
1. **设计系统原子化**:第一个把完整设计规范原子化的框架
|
|
1442
|
+
2. **极低学习成本**:3 个规则,20 分钟精通
|
|
1443
|
+
3. **强制一致性**:技术约束 > 人工自律
|
|
1444
|
+
4. **深色模式零成本**:自动推导 100+ 语义色
|
|
1445
|
+
5. **空间直觉布局**:废除 flexbox 概念
|
|
1446
|
+
6. **9 档精细响应**:3×3 分形断点系统
|
|
1447
|
+
|
|
1448
|
+
### 适用场景
|
|
1449
|
+
|
|
1450
|
+
✅ **强烈推荐**:
|
|
1451
|
+
- 企业级应用(长期维护)
|
|
1452
|
+
- 设计系统严格的项目
|
|
1453
|
+
- 小团队深度定制
|
|
1454
|
+
- 追求代码质量
|
|
1455
|
+
|
|
1456
|
+
❌ **不推荐**:
|
|
1457
|
+
- 开源项目(生态缺失)
|
|
1458
|
+
- 需要像素级还原第三方设计
|
|
1459
|
+
- 高度依赖 AI 编码
|
|
1460
|
+
|
|
1461
|
+
### 快速回顾
|
|
1462
|
+
|
|
1463
|
+
```html
|
|
1464
|
+
<!-- 尺寸系统 -->
|
|
1465
|
+
n-mm m-ss w-ll h-full r-sm fs-lm
|
|
1466
|
+
|
|
1467
|
+
<!-- 颜色系统 -->
|
|
1468
|
+
co-main bg-fore bk-line
|
|
1469
|
+
co-desc co-risk bg-well
|
|
1470
|
+
|
|
1471
|
+
<!-- 布局系统 -->
|
|
1472
|
+
ui-flex="row xm"
|
|
1473
|
+
ui-grid="mob:1 pad:3 dpc:5 ml"
|
|
1474
|
+
|
|
1475
|
+
<!-- 响应式 -->
|
|
1476
|
+
mob:fs-sm pad:fs-mm dpc:fs-lm
|
|
1477
|
+
ui-hide="<pad"
|
|
1478
|
+
|
|
1479
|
+
<!-- 按钮系统 -->
|
|
1480
|
+
ui-btn="@a main l :round"
|
|
1481
|
+
```
|
|
1482
|
+
|
|
1483
|
+
---
|
|
1484
|
+
|
|
1485
|
+
## 资源链接
|
|
1486
|
+
|
|
1487
|
+
- **官网**: http://neatui.fekit.cn
|
|
1488
|
+
- **NPM**: https://www.npmjs.com/package/@neatui/css
|
|
1489
|
+
- **当前版本**: v3.15.0
|
|
1490
|
+
- **作者**: xiaojunbo
|
|
1491
|
+
- **许可**: MIT
|
|
1492
|
+
|
|
1493
|
+
---
|
|
1494
|
+
|
|
1495
|
+
*本文档基于项目实战整理,覆盖 NeatUI 100% 的 API 和用法*
|
|
1496
|
+
|
|
1497
|
+
*最后更新: 2025-11-29*
|