@ticatec/uniface-element 0.3.17 → 0.3.19
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/CHANGELOG.md +43 -0
- package/COMPONENT_GUIDE.md +441 -0
- package/COMPONENT_GUIDE_CN.md +465 -0
- package/COMPONENT_SELECTION_PROMPTS.md +568 -0
- package/CONTRIBUTING.md +217 -0
- package/README.md +19 -9
- package/dist/attachment-files/README.md +169 -0
- package/dist/attachment-files/README_CN.md +169 -0
- package/dist/color-picker/README.md +184 -0
- package/dist/color-picker/README_CN.md +185 -0
- package/dist/form-field/README.md +193 -0
- package/dist/form-field/README_CN.md +193 -0
- package/dist/form-panel/flex-form/FlexForm.svelte +1 -1
- package/dist/inline-cell-editor/README.md +116 -0
- package/dist/inline-cell-editor/README_CN.md +116 -0
- package/dist/lib/TreeNode_README.md +32 -57
- package/dist/lib/TreeNode_README_CN.md +25 -43
- package/dist/lib/TreeNodes.d.ts +49 -98
- package/dist/lib/TreeNodes.js +97 -86
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +2 -0
- package/dist/nav-menu/MenuItem.d.ts +2 -2
- package/dist/navigator/README.md +377 -0
- package/dist/navigator/README_CN.md +377 -0
- package/dist/separator/README.md +105 -0
- package/dist/separator/README_CN.md +105 -0
- package/dist/split/README.md +240 -0
- package/dist/split/README_CN.md +240 -0
- package/dist/tree-view/README.md +48 -36
- package/dist/tree-view/README_CN.md +45 -9
- package/dist/tree-view/TreeNodeView.svelte +3 -9
- package/dist/tree-view/TreeView.svelte +4 -6
- package/dist/tree-view/Types.d.ts +2 -2
- package/package.json +16 -9
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Navigator 导航器
|
|
2
|
+
|
|
3
|
+
一个步骤/向导导航组件,引导用户完成多步骤流程。可视化进度并允许用户在带有清晰状态指示器的步骤之间导航。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- **步骤可视化**: 向导步骤的可视化表示
|
|
8
|
+
- **状态指示器**: 已完成、警告和未开始状态
|
|
9
|
+
- **活动跟踪**: 高亮显示当前活动步骤
|
|
10
|
+
- **项目高亮**: 高亮显示需要注意的特定项目
|
|
11
|
+
- **点击导航**: 点击以在步骤之间导航
|
|
12
|
+
- **自定义样式**: 灵活的样式选项
|
|
13
|
+
- **动态项目**: 支持动态步骤列表
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @ticatec/uniface-element
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import Navigator, { NavItemStatus } from '@ticatec/uniface-element/Navigator';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 基本用法
|
|
26
|
+
|
|
27
|
+
```svelte
|
|
28
|
+
<script>
|
|
29
|
+
import Navigator, { NavItemStatus } from '@ticatec/uniface-element/Navigator';
|
|
30
|
+
|
|
31
|
+
let activeItem = 0;
|
|
32
|
+
let items = [
|
|
33
|
+
{ text: '第1步' },
|
|
34
|
+
{ text: '第2步' },
|
|
35
|
+
{ text: '第3步' },
|
|
36
|
+
{ text: '第4步' }
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
function getStatus(item) {
|
|
40
|
+
const index = items.indexOf(item);
|
|
41
|
+
if (index < activeItem) return NavItemStatus.Completed;
|
|
42
|
+
if (index === activeItem) return NavItemStatus.Completed;
|
|
43
|
+
return NavItemStatus.NotStart;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function handleClick(item) {
|
|
47
|
+
activeItem = items.indexOf(item);
|
|
48
|
+
console.log('导航到:', item.text);
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<Navigator
|
|
53
|
+
{items}
|
|
54
|
+
activeItem={items[activeItem]}
|
|
55
|
+
retrieveStatus={getStatus}
|
|
56
|
+
itemClickHandler={handleClick}
|
|
57
|
+
/>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 属性
|
|
61
|
+
|
|
62
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
63
|
+
|------|------|---------|-------------|
|
|
64
|
+
| `items` | `Array<any>` | 必填 | 导航项目数组(必须有 `text` 属性) |
|
|
65
|
+
| `activeItem` | `any` | `null` | 当前活动项目 |
|
|
66
|
+
| `highlights` | `Array<any>` | `[]` | 需要注意的高亮项目 |
|
|
67
|
+
| `itemClickHandler` | `(item: any) => void` | 必填 | 项目被点击时的回调 |
|
|
68
|
+
| `retrieveStatus` | `(item: any) => NavItemStatus` | 必填 | 获取项目状态的函数 |
|
|
69
|
+
| `style` | `string` | `''` | 自定义CSS样式 |
|
|
70
|
+
|
|
71
|
+
## NavItemStatus 枚举
|
|
72
|
+
|
|
73
|
+
| 状态 | 值 | 说明 |
|
|
74
|
+
|------|------|-------------|
|
|
75
|
+
| `NavItemStatus.Completed` | `'nav-completed'` | 步骤已完成 |
|
|
76
|
+
| `NavItemStatus.Warning` | `'nav-warning'` | 步骤有警告 |
|
|
77
|
+
| `NavItemStatus.NotStart` | `'nav-not-start'` | 步骤未开始 |
|
|
78
|
+
|
|
79
|
+
## 示例
|
|
80
|
+
|
|
81
|
+
### 基本向导导航
|
|
82
|
+
|
|
83
|
+
```svelte
|
|
84
|
+
<script>
|
|
85
|
+
import Navigator, { NavItemStatus } from '@ticatec/uniface-element/Navigator';
|
|
86
|
+
|
|
87
|
+
let currentStep = 0;
|
|
88
|
+
|
|
89
|
+
const steps = [
|
|
90
|
+
{ text: '个人信息' },
|
|
91
|
+
{ text: '联系方式' },
|
|
92
|
+
{ text: '偏好设置' },
|
|
93
|
+
{ text: '确认' }
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
function getStepStatus(step) {
|
|
97
|
+
const index = steps.indexOf(step);
|
|
98
|
+
if (index < currentStep) return NavItemStatus.Completed;
|
|
99
|
+
if (index === currentStep) return NavItemStatus.Completed;
|
|
100
|
+
return NavItemStatus.NotStart;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function handleStepClick(step) {
|
|
104
|
+
const index = steps.indexOf(step);
|
|
105
|
+
if (index <= currentStep) {
|
|
106
|
+
currentStep = index;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function nextStep() {
|
|
111
|
+
if (currentStep < steps.length - 1) {
|
|
112
|
+
currentStep++;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function prevStep() {
|
|
117
|
+
if (currentStep > 0) {
|
|
118
|
+
currentStep--;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<Navigator
|
|
124
|
+
items={steps}
|
|
125
|
+
activeItem={steps[currentStep]}
|
|
126
|
+
retrieveStatus={getStepStatus}
|
|
127
|
+
itemClickHandler={handleStepClick}
|
|
128
|
+
/>
|
|
129
|
+
|
|
130
|
+
<div style="margin-top: 32px; padding: 24px; border: 1px solid #ddd;">
|
|
131
|
+
<h2>{steps[currentStep].text}</h2>
|
|
132
|
+
<p>步骤 {currentStep + 1} 的内容</p>
|
|
133
|
+
|
|
134
|
+
<div style="margin-top: 16px; display: flex; gap: 8px;">
|
|
135
|
+
<button disabled={currentStep === 0} on:click={prevStep}>上一步</button>
|
|
136
|
+
<button disabled={currentStep === steps.length - 1} on:click={nextStep}>下一步</button>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 带警告状态
|
|
142
|
+
|
|
143
|
+
```svelte
|
|
144
|
+
<script>
|
|
145
|
+
import Navigator, { NavItemStatus } from '@ticatec/uniface-element/Navigator';
|
|
146
|
+
|
|
147
|
+
let currentStep = 2;
|
|
148
|
+
const warningSteps = [1];
|
|
149
|
+
|
|
150
|
+
const steps = [
|
|
151
|
+
{ text: '账户' },
|
|
152
|
+
{ text: '资料' },
|
|
153
|
+
{ text: '设置' },
|
|
154
|
+
{ text: '确认' }
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
function getStepStatus(step) {
|
|
158
|
+
const index = steps.indexOf(step);
|
|
159
|
+
if (warningSteps.includes(index)) return NavItemStatus.Warning;
|
|
160
|
+
if (index <= currentStep) return NavItemStatus.Completed;
|
|
161
|
+
return NavItemStatus.NotStart;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function handleStepClick(step) {
|
|
165
|
+
const index = steps.indexOf(step);
|
|
166
|
+
if (index <= currentStep) {
|
|
167
|
+
currentStep = index;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
</script>
|
|
171
|
+
|
|
172
|
+
<Navigator
|
|
173
|
+
items={steps}
|
|
174
|
+
activeItem={steps[currentStep]}
|
|
175
|
+
retrieveStatus={getStepStatus}
|
|
176
|
+
itemClickHandler={handleStepClick}
|
|
177
|
+
/>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 带高亮
|
|
181
|
+
|
|
182
|
+
```svelte
|
|
183
|
+
<script>
|
|
184
|
+
import Navigator, { NavItemStatus } from '@ticatec/uniface-element/Navigator';
|
|
185
|
+
|
|
186
|
+
let currentStep = 1;
|
|
187
|
+
let highlightedSteps = [2, 3];
|
|
188
|
+
|
|
189
|
+
const steps = [
|
|
190
|
+
{ text: '上传' },
|
|
191
|
+
{ text: '处理' },
|
|
192
|
+
{ text: '验证' },
|
|
193
|
+
{ text: '完成' }
|
|
194
|
+
];
|
|
195
|
+
|
|
196
|
+
function getStepStatus(step) {
|
|
197
|
+
const index = steps.indexOf(step);
|
|
198
|
+
if (index < currentStep) return NavItemStatus.Completed;
|
|
199
|
+
if (index === currentStep) return NavItemStatus.Completed;
|
|
200
|
+
return NavItemStatus.NotStart;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function handleStepClick(step) {
|
|
204
|
+
const index = steps.indexOf(step);
|
|
205
|
+
if (index <= currentStep) {
|
|
206
|
+
currentStep = index;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
<Navigator
|
|
212
|
+
items={steps}
|
|
213
|
+
activeItem={steps[currentStep]}
|
|
214
|
+
highlights={highlightedSteps.map(i => steps[i])}
|
|
215
|
+
retrieveStatus={getStepStatus}
|
|
216
|
+
itemClickHandler={handleStepClick}
|
|
217
|
+
/>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 自定义样式
|
|
221
|
+
|
|
222
|
+
```svelte
|
|
223
|
+
<script>
|
|
224
|
+
import Navigator, { NavItemStatus } from '@ticatec/uniface-element/Navigator';
|
|
225
|
+
|
|
226
|
+
const steps = [
|
|
227
|
+
{ text: '①' },
|
|
228
|
+
{ text: '②' },
|
|
229
|
+
{ text: '③' },
|
|
230
|
+
{ text: '④' }
|
|
231
|
+
];
|
|
232
|
+
|
|
233
|
+
function getStepStatus(step) {
|
|
234
|
+
return NavItemStatus.NotStart;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function handleStepClick(step) {
|
|
238
|
+
console.log('点击:', step.text);
|
|
239
|
+
}
|
|
240
|
+
</script>
|
|
241
|
+
|
|
242
|
+
<Navigator
|
|
243
|
+
items={steps}
|
|
244
|
+
activeItem={steps[0]}
|
|
245
|
+
retrieveStatus={getStepStatus}
|
|
246
|
+
itemClickHandler={handleStepClick}
|
|
247
|
+
style="background: #f5f5f5; padding: 16px; border-radius: 8px;"
|
|
248
|
+
/>
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### 完整表单向导
|
|
252
|
+
|
|
253
|
+
```svelte
|
|
254
|
+
<script>
|
|
255
|
+
import Navigator, { NavItemStatus } from '@ticatec/uniface-element/Navigator';
|
|
256
|
+
import Button from '@ticatec/uniface-element/Button';
|
|
257
|
+
|
|
258
|
+
let currentStep = 0;
|
|
259
|
+
let formData = {
|
|
260
|
+
name: '',
|
|
261
|
+
email: '',
|
|
262
|
+
phone: '',
|
|
263
|
+
address: ''
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const wizardSteps = [
|
|
267
|
+
{ text: '个人' },
|
|
268
|
+
{ text: '联系' },
|
|
269
|
+
{ text: '位置' },
|
|
270
|
+
{ text: '审查' }
|
|
271
|
+
];
|
|
272
|
+
|
|
273
|
+
function getStepStatus(step) {
|
|
274
|
+
const index = wizardSteps.indexOf(step);
|
|
275
|
+
if (index < currentStep) return NavItemStatus.Completed;
|
|
276
|
+
if (index === currentStep) return NavItemStatus.Completed;
|
|
277
|
+
return NavItemStatus.NotStart;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function handleStepClick(step) {
|
|
281
|
+
const index = wizardSteps.indexOf(step);
|
|
282
|
+
if (index <= currentStep) {
|
|
283
|
+
currentStep = index;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function canProceed() {
|
|
288
|
+
switch(currentStep) {
|
|
289
|
+
case 0: return formData.name.length > 0;
|
|
290
|
+
case 1: return formData.email.length > 0;
|
|
291
|
+
case 2: return formData.address.length > 0;
|
|
292
|
+
default: return true;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
</script>
|
|
296
|
+
|
|
297
|
+
<div style="max-width: 800px; margin: 0 auto; padding: 24px;">
|
|
298
|
+
<Navigator
|
|
299
|
+
items={wizardSteps}
|
|
300
|
+
activeItem={wizardSteps[currentStep]}
|
|
301
|
+
retrieveStatus={getStepStatus}
|
|
302
|
+
itemClickHandler={handleStepClick}
|
|
303
|
+
/>
|
|
304
|
+
|
|
305
|
+
<div style="margin-top: 32px; padding: 24px; border: 1px solid #ddd; border-radius: 8px;">
|
|
306
|
+
{#if currentStep === 0}
|
|
307
|
+
<h2>个人信息</h2>
|
|
308
|
+
<label>
|
|
309
|
+
姓名:
|
|
310
|
+
<input type="text" bind:value={formData.name} placeholder="请输入姓名" />
|
|
311
|
+
</label>
|
|
312
|
+
{:else if currentStep === 1}
|
|
313
|
+
<h2>联系信息</h2>
|
|
314
|
+
<label>
|
|
315
|
+
邮箱:
|
|
316
|
+
<input type="email" bind:value={formData.email} placeholder="your@email.com" />
|
|
317
|
+
</label>
|
|
318
|
+
{:else if currentStep === 2}
|
|
319
|
+
<h2>位置</h2>
|
|
320
|
+
<label>
|
|
321
|
+
地址:
|
|
322
|
+
<input type="text" bind:value={formData.address} placeholder="您的地址" />
|
|
323
|
+
</label>
|
|
324
|
+
{:else}
|
|
325
|
+
<h2>审查您的信息</h2>
|
|
326
|
+
<pre>{JSON.stringify(formData, null, 2)}</pre>
|
|
327
|
+
{/if}
|
|
328
|
+
|
|
329
|
+
<div style="margin-top: 24px; display: flex; justify-content: space-between;">
|
|
330
|
+
<Button
|
|
331
|
+
disabled={currentStep === 0}
|
|
332
|
+
onclick={() => currentStep--}
|
|
333
|
+
>
|
|
334
|
+
上一步
|
|
335
|
+
</Button>
|
|
336
|
+
|
|
337
|
+
{#if currentStep < wizardSteps.length - 1}
|
|
338
|
+
<Button
|
|
339
|
+
type="primary"
|
|
340
|
+
disabled={!canProceed()}
|
|
341
|
+
onclick={() => currentStep++}
|
|
342
|
+
>
|
|
343
|
+
下一步
|
|
344
|
+
</Button>
|
|
345
|
+
{:else}
|
|
346
|
+
<Button type="primary" onclick={() => console.log('提交:', formData)}>
|
|
347
|
+
提交
|
|
348
|
+
</Button>
|
|
349
|
+
{/if}
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
</div>
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## 最佳实践
|
|
356
|
+
|
|
357
|
+
1. **清晰的步骤**: 为每个步骤使用简洁、描述性的文本
|
|
358
|
+
2. **状态逻辑**: 根据工作流程实现清晰的状态逻辑
|
|
359
|
+
3. **导航控制**: 根据进度控制哪些步骤可点击
|
|
360
|
+
4. **视觉反馈**: 使用警告指示问题或需要注意的事项
|
|
361
|
+
5. **验证**: 如果当前步骤未完成,阻止继续
|
|
362
|
+
6. **进度指示**: 清楚地显示哪个步骤是活动的
|
|
363
|
+
|
|
364
|
+
## 使用场景
|
|
365
|
+
|
|
366
|
+
- **多步骤表单**: 将复杂的表单分解为可管理的步骤
|
|
367
|
+
- **向导**: 引导用户完成复杂流程
|
|
368
|
+
- **入门引导**: 分步用户引导流程
|
|
369
|
+
- **结账**: 电子商务结账流程
|
|
370
|
+
- **配置**: 多阶段配置工作流
|
|
371
|
+
|
|
372
|
+
## 无障碍访问
|
|
373
|
+
|
|
374
|
+
- 键盘导航支持
|
|
375
|
+
- 当前步骤的清晰视觉指示器
|
|
376
|
+
- 语义化HTML结构
|
|
377
|
+
- 屏幕阅读器的ARIA属性
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Separator
|
|
2
|
+
|
|
3
|
+
A simple horizontal separator component for visually dividing content sections.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Customizable Height**: Set custom height for the separator
|
|
8
|
+
- **Custom Styling**: Apply custom CSS styles
|
|
9
|
+
- **Lightweight**: Minimal implementation with maximum flexibility
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @ticatec/uniface-element
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script>
|
|
25
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div>
|
|
29
|
+
<h2>Section 1</h2>
|
|
30
|
+
<p>Content for section 1</p>
|
|
31
|
+
|
|
32
|
+
<Separator />
|
|
33
|
+
|
|
34
|
+
<h2>Section 2</h2>
|
|
35
|
+
<p>Content for section 2</p>
|
|
36
|
+
</div>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Props
|
|
40
|
+
|
|
41
|
+
| Prop | Type | Default | Description |
|
|
42
|
+
|------|------|---------|-------------|
|
|
43
|
+
| `height` | `string` | `'24px'` | Height of the separator |
|
|
44
|
+
| `style` | `string` | `''` | Additional CSS styles |
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
### Custom Height
|
|
49
|
+
|
|
50
|
+
```svelte
|
|
51
|
+
<script>
|
|
52
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<!-- Thin separator -->
|
|
56
|
+
<Separator height="8px" />
|
|
57
|
+
|
|
58
|
+
<!-- Default height -->
|
|
59
|
+
<Separator height="24px" />
|
|
60
|
+
|
|
61
|
+
<!-- Thick separator -->
|
|
62
|
+
<Separator height="48px" />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Custom Styling
|
|
66
|
+
|
|
67
|
+
```svelte
|
|
68
|
+
<script>
|
|
69
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<Separator
|
|
73
|
+
height="2px"
|
|
74
|
+
style="background: linear-gradient(90deg, transparent, #ccc, transparent);"
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Multiple Separators
|
|
79
|
+
|
|
80
|
+
```svelte
|
|
81
|
+
<script>
|
|
82
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<div class="content">
|
|
86
|
+
<h3>Header</h3>
|
|
87
|
+
<p>Content here</p>
|
|
88
|
+
|
|
89
|
+
<Separator height="16px" />
|
|
90
|
+
|
|
91
|
+
<h3>Subsection</h3>
|
|
92
|
+
<p>More content</p>
|
|
93
|
+
|
|
94
|
+
<Separator height="32px" style="background-color: #007acc;" />
|
|
95
|
+
|
|
96
|
+
<h3>Footer Section</h3>
|
|
97
|
+
</div>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Best Practices
|
|
101
|
+
|
|
102
|
+
1. **Visual Hierarchy**: Use separator heights to establish visual hierarchy
|
|
103
|
+
2. **Spacing**: Adjust height to control whitespace between sections
|
|
104
|
+
3. **Consistency**: Maintain consistent separator styles across your application
|
|
105
|
+
4. **Minimal Design**: Keep separators subtle to avoid dominating the layout
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Separator 分隔线
|
|
2
|
+
|
|
3
|
+
一个简单的水平分隔线组件,用于视觉上分割内容区域。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- **自定义高度**: 可设置分隔线的高度
|
|
8
|
+
- **自定义样式**: 可应用自定义CSS样式
|
|
9
|
+
- **轻量级**: 最小化实现,最大化灵活性
|
|
10
|
+
|
|
11
|
+
## 安装
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @ticatec/uniface-element
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 基本用法
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<script>
|
|
25
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div>
|
|
29
|
+
<h2>第1节</h2>
|
|
30
|
+
<p>第1节的内容</p>
|
|
31
|
+
|
|
32
|
+
<Separator />
|
|
33
|
+
|
|
34
|
+
<h2>第2节</h2>
|
|
35
|
+
<p>第2节的内容</p>
|
|
36
|
+
</div>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 属性
|
|
40
|
+
|
|
41
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
42
|
+
|------|------|---------|-------------|
|
|
43
|
+
| `height` | `string` | `'24px'` | 分隔线的高度 |
|
|
44
|
+
| `style` | `string` | `''` | 附加CSS样式 |
|
|
45
|
+
|
|
46
|
+
## 示例
|
|
47
|
+
|
|
48
|
+
### 自定义高度
|
|
49
|
+
|
|
50
|
+
```svelte
|
|
51
|
+
<script>
|
|
52
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<!-- 细分隔线 -->
|
|
56
|
+
<Separator height="8px" />
|
|
57
|
+
|
|
58
|
+
<!-- 默认高度 -->
|
|
59
|
+
<Separator height="24px" />
|
|
60
|
+
|
|
61
|
+
<!-- 粗分隔线 -->
|
|
62
|
+
<Separator height="48px" />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 自定义样式
|
|
66
|
+
|
|
67
|
+
```svelte
|
|
68
|
+
<script>
|
|
69
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<Separator
|
|
73
|
+
height="2px"
|
|
74
|
+
style="background: linear-gradient(90deg, transparent, #ccc, transparent);"
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 多个分隔线
|
|
79
|
+
|
|
80
|
+
```svelte
|
|
81
|
+
<script>
|
|
82
|
+
import Separator from '@ticatec/uniface-element/Separator';
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<div class="content">
|
|
86
|
+
<h3>标题</h3>
|
|
87
|
+
<p>内容在这里</p>
|
|
88
|
+
|
|
89
|
+
<Separator height="16px" />
|
|
90
|
+
|
|
91
|
+
<h3>小节</h3>
|
|
92
|
+
<p>更多内容</p>
|
|
93
|
+
|
|
94
|
+
<Separator height="32px" style="background-color: #007acc;" />
|
|
95
|
+
|
|
96
|
+
<h3>页脚节</h3>
|
|
97
|
+
</div>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 最佳实践
|
|
101
|
+
|
|
102
|
+
1. **视觉层次**: 使用分隔线高度建立视觉层次
|
|
103
|
+
2. **间距**: 调整高度来控制区域之间的空白
|
|
104
|
+
3. **一致性**: 在整个应用中保持分隔线样式一致
|
|
105
|
+
4. **简约设计**: 保持分隔线微妙,避免主导布局
|