react-tech-ui 1.0.0 → 1.0.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/README.md +477 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
- 🎨 **科技风格设计** — 深色主题 + 霓虹光效 + 扫描线动画,打造沉浸式科技感
|
|
8
8
|
- 📺 **大屏适配** — 内置 ScreenAdapter 组件,支持等比缩放、宽度缩放、全屏三种适配模式
|
|
9
9
|
- ✨ **丰富动画** — 脉冲发光、扫描线、渐变流动、数字翻牌等多种科技风动画
|
|
10
|
-
- 📦 **开箱即用** —
|
|
10
|
+
- 📦 **开箱即用** — 20 大核心组件,覆盖大屏开发常见场景
|
|
11
11
|
- 🔧 **TypeScript** — 完整类型定义,开发体验友好
|
|
12
|
-
- 🎯
|
|
12
|
+
- 🎯 **按需引入** — 支持 ESM/CJS 双格式,可按组件单独引入
|
|
13
|
+
- 🎭 **7 套预设主题** — 赛博蓝、霓虹绿、极光紫、落日橙、赤焰红、鎏金、暗黑深渊
|
|
14
|
+
- 🌈 **CSS 变量驱动** — 轻松自定义颜色和风格
|
|
13
15
|
|
|
14
16
|
## 快速开始
|
|
15
17
|
|
|
@@ -45,6 +47,13 @@ function App() {
|
|
|
45
47
|
}
|
|
46
48
|
```
|
|
47
49
|
|
|
50
|
+
### 按需引入
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { ScreenAdapter } from 'react-tech-ui/ScreenAdapter';
|
|
54
|
+
import 'react-tech-ui/ScreenAdapter/style.css';
|
|
55
|
+
```
|
|
56
|
+
|
|
48
57
|
## 本地开发
|
|
49
58
|
|
|
50
59
|
### 环境要求
|
|
@@ -72,10 +81,13 @@ npm run build:lib
|
|
|
72
81
|
```
|
|
73
82
|
|
|
74
83
|
构建产物:
|
|
75
|
-
- `dist/index.
|
|
76
|
-
- `dist/index.cjs
|
|
84
|
+
- `dist/index/index.js` — ES Module 格式(主入口)
|
|
85
|
+
- `dist/index/index.cjs` — CommonJS 格式(主入口)
|
|
86
|
+
- `dist/index/style.css` — 合并样式文件(包含所有组件样式)
|
|
77
87
|
- `dist/index.d.ts` — TypeScript 类型声明
|
|
78
|
-
- `dist/
|
|
88
|
+
- `dist/[Component]/index.js` — 单组件 ES Module
|
|
89
|
+
- `dist/[Component]/index.cjs` — 单组件 CommonJS
|
|
90
|
+
- `dist/[Component]/style.css` — 单组件样式
|
|
79
91
|
|
|
80
92
|
### 其他命令
|
|
81
93
|
|
|
@@ -340,6 +352,396 @@ const columns = [
|
|
|
340
352
|
|
|
341
353
|
---
|
|
342
354
|
|
|
355
|
+
### Modal — 模态对话框
|
|
356
|
+
|
|
357
|
+
科技风格模态框,支持 3 种变体,ESC 键关闭。
|
|
358
|
+
|
|
359
|
+
```tsx
|
|
360
|
+
<Modal
|
|
361
|
+
open={visible}
|
|
362
|
+
onClose={() => setVisible(false)}
|
|
363
|
+
title="系统提示"
|
|
364
|
+
variant="neon"
|
|
365
|
+
footer={<TechButton variant="primary" onClick={handleConfirm}>确认</TechButton>}
|
|
366
|
+
>
|
|
367
|
+
<p>确定要执行此操作吗?</p>
|
|
368
|
+
</Modal>
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
372
|
+
|------|------|------|--------|
|
|
373
|
+
| open | 是否显示 | `boolean` | - |
|
|
374
|
+
| onClose | 关闭回调 | `() => void` | - |
|
|
375
|
+
| title | 标题 | `ReactNode` | - |
|
|
376
|
+
| footer | 底部内容 | `ReactNode` | - |
|
|
377
|
+
| width | 宽度(px) | `number` | `520` |
|
|
378
|
+
| variant | 样式变体 | `'default' \| 'neon' \| 'scan'` | `'default'` |
|
|
379
|
+
| maskClosable | 点击遮罩关闭 | `boolean` | `true` |
|
|
380
|
+
| closable | 显示关闭按钮 | `boolean` | `true` |
|
|
381
|
+
| animate | 入场动画 | `boolean` | `true` |
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
### Drawer — 抽屉
|
|
386
|
+
|
|
387
|
+
从屏幕边缘滑出的面板,支持四个方向。
|
|
388
|
+
|
|
389
|
+
```tsx
|
|
390
|
+
<Drawer
|
|
391
|
+
open={visible}
|
|
392
|
+
onClose={() => setVisible(false)}
|
|
393
|
+
title="详情面板"
|
|
394
|
+
placement="right"
|
|
395
|
+
variant="neon"
|
|
396
|
+
width={400}
|
|
397
|
+
>
|
|
398
|
+
<p>抽屉内容</p>
|
|
399
|
+
</Drawer>
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
403
|
+
|------|------|------|--------|
|
|
404
|
+
| open | 是否显示 | `boolean` | - |
|
|
405
|
+
| onClose | 关闭回调 | `() => void` | - |
|
|
406
|
+
| title | 标题 | `ReactNode` | - |
|
|
407
|
+
| footer | 底部内容 | `ReactNode` | - |
|
|
408
|
+
| width | 宽度/高度 | `number \| string` | `400` |
|
|
409
|
+
| placement | 弹出方向 | `'left' \| 'right' \| 'top' \| 'bottom'` | `'right'` |
|
|
410
|
+
| variant | 样式变体 | `'default' \| 'neon' \| 'scan'` | `'default'` |
|
|
411
|
+
| maskClosable | 点击遮罩关闭 | `boolean` | `true` |
|
|
412
|
+
| closable | 显示关闭按钮 | `boolean` | `true` |
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
### Toast — 轻提示
|
|
417
|
+
|
|
418
|
+
全局提示组件,支持 5 种类型,命令式调用。
|
|
419
|
+
|
|
420
|
+
```tsx
|
|
421
|
+
import { Toast } from 'react-tech-ui';
|
|
422
|
+
|
|
423
|
+
// 在 App 根组件中挂载容器
|
|
424
|
+
function App() {
|
|
425
|
+
return (
|
|
426
|
+
<>
|
|
427
|
+
<YourRoutes />
|
|
428
|
+
<Toast.Container />
|
|
429
|
+
</>
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// 在任意地方调用
|
|
434
|
+
Toast.success('操作成功');
|
|
435
|
+
Toast.error('操作失败');
|
|
436
|
+
Toast.warning('请注意风险');
|
|
437
|
+
Toast.info('系统提示');
|
|
438
|
+
Toast.loading('加载中...');
|
|
439
|
+
Toast.close(id);
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
| 方法 | 说明 | 参数 |
|
|
443
|
+
|------|------|------|
|
|
444
|
+
| `Toast.info(content, config?)` | 信息提示 | `ReactNode, ToastConfig?` |
|
|
445
|
+
| `Toast.success(content, config?)` | 成功提示 | `ReactNode, ToastConfig?` |
|
|
446
|
+
| `Toast.warning(content, config?)` | 警告提示 | `ReactNode, ToastConfig?` |
|
|
447
|
+
| `Toast.error(content, config?)` | 错误提示 | `ReactNode, ToastConfig?` |
|
|
448
|
+
| `Toast.loading(content, config?)` | 加载提示(不自动关闭) | `ReactNode, ToastConfig?` |
|
|
449
|
+
| `Toast.custom(config)` | 自定义提示 | `ToastConfig` |
|
|
450
|
+
| `Toast.close(id)` | 关闭指定提示 | `string` |
|
|
451
|
+
|
|
452
|
+
**ToastConfig:**
|
|
453
|
+
|
|
454
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
455
|
+
|------|------|------|--------|
|
|
456
|
+
| content | 提示内容 | `ReactNode` | - |
|
|
457
|
+
| type | 类型 | `'info' \| 'success' \| 'warning' \| 'error' \| 'loading'` | `'info'` |
|
|
458
|
+
| duration | 自动关闭时间(ms),0 不关闭 | `number` | `3000` |
|
|
459
|
+
| closable | 显示关闭按钮 | `boolean` | `false` |
|
|
460
|
+
| icon | 自定义图标 | `ReactNode` | - |
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
### Popconfirm — 气泡确认框
|
|
465
|
+
|
|
466
|
+
点击元素弹出确认气泡,支持 4 个方向。
|
|
467
|
+
|
|
468
|
+
```tsx
|
|
469
|
+
<Popconfirm
|
|
470
|
+
title="确认删除"
|
|
471
|
+
content="删除后数据将无法恢复"
|
|
472
|
+
onConfirm={handleDelete}
|
|
473
|
+
onCancel={() => {}}
|
|
474
|
+
placement="top"
|
|
475
|
+
>
|
|
476
|
+
<TechButton variant="outline">删除</TechButton>
|
|
477
|
+
</Popconfirm>
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
481
|
+
|------|------|------|--------|
|
|
482
|
+
| content | 确认内容 | `ReactNode` | - |
|
|
483
|
+
| title | 标题 | `ReactNode` | - |
|
|
484
|
+
| onConfirm | 确认回调 | `() => void` | - |
|
|
485
|
+
| onCancel | 取消回调 | `() => void` | - |
|
|
486
|
+
| confirmText | 确认按钮文字 | `string` | `'确认'` |
|
|
487
|
+
| cancelText | 取消按钮文字 | `string` | `'取消'` |
|
|
488
|
+
| placement | 弹出方向 | `'top' \| 'bottom' \| 'left' \| 'right'` | `'top'` |
|
|
489
|
+
| variant | 样式变体 | `'default' \| 'neon' \| 'scan'` | `'default'` |
|
|
490
|
+
| trigger | 触发方式 | `'click' \| 'hover'` | `'click'` |
|
|
491
|
+
| disabled | 是否禁用 | `boolean` | `false` |
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
### FlowLight — 流光背景
|
|
496
|
+
|
|
497
|
+
4 种流光动画背景效果,可叠加内容。
|
|
498
|
+
|
|
499
|
+
```tsx
|
|
500
|
+
<FlowLight variant="aurora" speed={1.5} intensity="high">
|
|
501
|
+
<div style={{ padding: 40 }}>叠加在流光上的内容</div>
|
|
502
|
+
</FlowLight>
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
506
|
+
|------|------|------|--------|
|
|
507
|
+
| variant | 流光变体 | `'aurora' \| 'grid' \| 'particle' \| 'wave'` | `'aurora'` |
|
|
508
|
+
| color | 流光颜色 | `string` | `--tech-primary` |
|
|
509
|
+
| speed | 动画速度 | `number` | `1` |
|
|
510
|
+
| opacity | 透明度 | `number` | `0.6` |
|
|
511
|
+
| intensity | 强度 | `'low' \| 'medium' \| 'high'` | `'medium'` |
|
|
512
|
+
|
|
513
|
+
**变体说明:**
|
|
514
|
+
- `aurora`:极光效果,多层渐变流动
|
|
515
|
+
- `grid`:网格效果
|
|
516
|
+
- `particle`:粒子效果
|
|
517
|
+
- `wave`:波浪效果
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
### ThemeProvider — 主题提供者
|
|
522
|
+
|
|
523
|
+
7 套预设主题,支持运行时切换,通过 CSS 变量全局生效。
|
|
524
|
+
|
|
525
|
+
```tsx
|
|
526
|
+
import { ThemeProvider, useTheme } from 'react-tech-ui';
|
|
527
|
+
|
|
528
|
+
function App() {
|
|
529
|
+
return (
|
|
530
|
+
<ThemeProvider defaultTheme="cyber-blue">
|
|
531
|
+
<YourContent />
|
|
532
|
+
</ThemeProvider>
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// 在子组件中切换主题
|
|
537
|
+
function ThemeSwitcher() {
|
|
538
|
+
const { themeName, setTheme, presetThemes, themeLabels } = useTheme();
|
|
539
|
+
|
|
540
|
+
return (
|
|
541
|
+
<select value={themeName} onChange={(e) => setTheme(e.target.value)}>
|
|
542
|
+
{Object.entries(themeLabels).map(([key, label]) => (
|
|
543
|
+
<option key={key} value={key}>{label}</option>
|
|
544
|
+
))}
|
|
545
|
+
</select>
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
551
|
+
|------|------|------|--------|
|
|
552
|
+
| defaultTheme | 默认主题名 | `string` | `'cyber-blue'` |
|
|
553
|
+
| children | 子元素 | `ReactNode` | - |
|
|
554
|
+
|
|
555
|
+
**预设主题:**
|
|
556
|
+
|
|
557
|
+
| 主题名 | 中文名 | 主色调 |
|
|
558
|
+
|--------|--------|--------|
|
|
559
|
+
| `cyber-blue` | 赛博蓝 | `#00d4ff` |
|
|
560
|
+
| `neon-green` | 霓虹绿 | `#0affb0` |
|
|
561
|
+
| `aurora-purple` | 极光紫 | `#a855f7` |
|
|
562
|
+
| `sunset-orange` | 落日橙 | `#ff6b35` |
|
|
563
|
+
| `crimson-red` | 赤焰红 | `#ff4757` |
|
|
564
|
+
| `gold-luxury` | 鎏金 | `#fbbf24` |
|
|
565
|
+
| `dark-abyss` | 暗黑深渊 | `#64748b` |
|
|
566
|
+
|
|
567
|
+
**useTheme() 返回值:**
|
|
568
|
+
|
|
569
|
+
| 属性 | 说明 | 类型 |
|
|
570
|
+
|------|------|------|
|
|
571
|
+
| themeName | 当前主题名 | `string` |
|
|
572
|
+
| themeVars | 当前主题变量 | `PartialTechThemeVars` |
|
|
573
|
+
| setTheme | 切换主题 | `(name: string, vars?: PartialTechThemeVars) => void` |
|
|
574
|
+
| presetThemes | 所有预设主题 | `Record<string, PartialTechThemeVars>` |
|
|
575
|
+
| themeLabels | 主题中文名映射 | `Record<string, string>` |
|
|
576
|
+
|
|
577
|
+
---
|
|
578
|
+
|
|
579
|
+
### Skeleton — 骨架屏
|
|
580
|
+
|
|
581
|
+
数据加载时的占位骨架,支持 4 种变体和 loading 状态控制。
|
|
582
|
+
|
|
583
|
+
```tsx
|
|
584
|
+
<Skeleton variant="text" rows={3} loading={isLoading}>
|
|
585
|
+
<DataCard title="数据" value={data} />
|
|
586
|
+
</Skeleton>
|
|
587
|
+
|
|
588
|
+
<Skeleton variant="circle" width={48} />
|
|
589
|
+
<Skeleton variant="card" />
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
593
|
+
|------|------|------|--------|
|
|
594
|
+
| variant | 骨架变体 | `'text' \| 'rect' \| 'circle' \| 'card'` | `'text'` |
|
|
595
|
+
| width | 宽度 | `number \| string` | - |
|
|
596
|
+
| height | 高度 | `number \| string` | - |
|
|
597
|
+
| rows | 行数(text 模式) | `number` | `1` |
|
|
598
|
+
| rowsGap | 行间距(px) | `number` | `12` |
|
|
599
|
+
| animate | 闪烁动画 | `boolean` | `true` |
|
|
600
|
+
| loading | 加载状态,false 时显示 children | `boolean` | - |
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
604
|
+
### QRCode — 二维码
|
|
605
|
+
|
|
606
|
+
科技风格二维码,支持扫描线动画和中心图标。
|
|
607
|
+
|
|
608
|
+
```tsx
|
|
609
|
+
<QRCode
|
|
610
|
+
value="https://example.com"
|
|
611
|
+
size={200}
|
|
612
|
+
variant="neon"
|
|
613
|
+
title="扫码访问"
|
|
614
|
+
description="请使用手机扫描"
|
|
615
|
+
/>
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
619
|
+
|------|------|------|--------|
|
|
620
|
+
| value | 二维码内容 | `string` | - |
|
|
621
|
+
| size | 尺寸(px) | `number` | `200` |
|
|
622
|
+
| variant | 样式变体 | `'default' \| 'neon' \| 'scan'` | `'default'` |
|
|
623
|
+
| color | 前景色 | `string` | `--tech-primary` |
|
|
624
|
+
| bgColor | 背景色 | `string` | `--tech-bg-medium` |
|
|
625
|
+
| level | 容错等级 | `'L' \| 'M' \| 'Q' \| 'H'` | `'M'` |
|
|
626
|
+
| includeMargin | 是否包含边距 | `boolean` | `false` |
|
|
627
|
+
| icon | 中心图标 URL | `string` | - |
|
|
628
|
+
| iconSize | 中心图标尺寸(px) | `number` | `40` |
|
|
629
|
+
| title | 标题 | `ReactNode` | - |
|
|
630
|
+
| description | 描述 | `ReactNode` | - |
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
### Icon — 图标
|
|
635
|
+
|
|
636
|
+
内置 80+ 科技风格 SVG 图标,支持发光和旋转效果。
|
|
637
|
+
|
|
638
|
+
```tsx
|
|
639
|
+
import { Icon } from 'react-tech-ui';
|
|
640
|
+
|
|
641
|
+
<Icon name="home" size={24} />
|
|
642
|
+
<Icon name="setting" variant="neon" />
|
|
643
|
+
<Icon name="loading" spin />
|
|
644
|
+
<Icon name="arrow-right" color="#0affb0" />
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
648
|
+
|------|------|------|--------|
|
|
649
|
+
| name | 图标名称 | `IconName` | - |
|
|
650
|
+
| size | 尺寸 | `number \| string` | `20` |
|
|
651
|
+
| color | 颜色 | `string` | `--tech-primary` |
|
|
652
|
+
| variant | 样式变体 | `'default' \| 'neon' \| 'glow'` | `'default'` |
|
|
653
|
+
| spin | 旋转动画 | `boolean` | `false` |
|
|
654
|
+
| onClick | 点击回调 | `MouseEventHandler` | - |
|
|
655
|
+
|
|
656
|
+
**图标名称分类:**
|
|
657
|
+
|
|
658
|
+
| 分类 | 图标 |
|
|
659
|
+
|------|------|
|
|
660
|
+
| 导航 | `home`, `menu`, `compass`, `location`, `target`, `scan` |
|
|
661
|
+
| 用户 | `user`, `team`, `lock`, `unlock` |
|
|
662
|
+
| 操作 | `add`, `minus`, `close`, `check`, `edit`, `delete`, `copy`, `paste`, `search`, `filter`, `sort`, `refresh`, `sync`, `swap`, `share`, `link` |
|
|
663
|
+
| 方向 | `arrow-up`, `arrow-down`, `arrow-left`, `arrow-right`, `chevron-up`, `chevron-down`, `chevron-left`, `chevron-right`, `expand`, `collapse`, `fullscreen`, `fullscreen-exit` |
|
|
664
|
+
| 状态 | `info`, `question`, `warning`, `error`, `success`, `loading`, `notification` |
|
|
665
|
+
| 数据 | `chart`, `dashboard`, `data`, `database` |
|
|
666
|
+
| 设备 | `server`, `cloud`, `network`, `shield`, `terminal`, `code`, `bug`, `api` |
|
|
667
|
+
| 媒体 | `camera`, `image`, `file`, `folder`, `play`, `pause`, `stop`, `forward` |
|
|
668
|
+
| 通信 | `message`, `email`, `phone` |
|
|
669
|
+
| 时间 | `calendar`, `clock`, `timer`, `history` |
|
|
670
|
+
| 文件 | `download`, `upload`, `export`, `import` |
|
|
671
|
+
| 其他 | `sun`, `moon`, `star`, `flash`, `power`, `signal`, `wifi`, `bluetooth`, `more`, `ellipsis`, `drag`, `eye`, `eye-off` |
|
|
672
|
+
|
|
673
|
+
---
|
|
674
|
+
|
|
675
|
+
### Masonry — 瀑布流布局
|
|
676
|
+
|
|
677
|
+
科技风格瀑布流布局,自动按高度分配列。
|
|
678
|
+
|
|
679
|
+
```tsx
|
|
680
|
+
const items = [
|
|
681
|
+
{ id: 1, height: 200, title: '卡片1' },
|
|
682
|
+
{ id: 2, height: 300, title: '卡片2' },
|
|
683
|
+
{ id: 3, height: 150, title: '卡片3' },
|
|
684
|
+
];
|
|
685
|
+
|
|
686
|
+
<Masonry
|
|
687
|
+
items={items}
|
|
688
|
+
columns={3}
|
|
689
|
+
gap={12}
|
|
690
|
+
variant="neon"
|
|
691
|
+
renderItem={(item) => <div>{item.title}</div>}
|
|
692
|
+
/>
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
696
|
+
|------|------|------|--------|
|
|
697
|
+
| items | 数据源 | `MasonryItem[]` | - |
|
|
698
|
+
| columns | 列数 | `number` | `3` |
|
|
699
|
+
| gap | 间距(px) | `number` | `12` |
|
|
700
|
+
| columnWidth | 列宽 | `number \| string` | - |
|
|
701
|
+
| variant | 样式变体 | `'default' \| 'neon' \| 'scan' \| 'glass'` | `'default'` |
|
|
702
|
+
| renderItem | 渲染项函数 | `(item: T, index: number) => ReactNode` | - |
|
|
703
|
+
| keyExtractor | 自定义 key | `(item: T, index: number) => string \| number` | - |
|
|
704
|
+
|
|
705
|
+
**MasonryItem:**
|
|
706
|
+
|
|
707
|
+
| 属性 | 说明 | 类型 | 必填 |
|
|
708
|
+
|------|------|------|------|
|
|
709
|
+
| id | 唯一标识 | `string \| number` | 是 |
|
|
710
|
+
| height | 项高度(px) | `number` | 否,默认 `200` |
|
|
711
|
+
|
|
712
|
+
---
|
|
713
|
+
|
|
714
|
+
### FloatingButton — 浮动按钮
|
|
715
|
+
|
|
716
|
+
可拖拽的浮动操作按钮,支持边缘吸附。
|
|
717
|
+
|
|
718
|
+
```tsx
|
|
719
|
+
<FloatingButton
|
|
720
|
+
icon={<Icon name="setting" size={20} />}
|
|
721
|
+
variant="neon"
|
|
722
|
+
draggable
|
|
723
|
+
edgeSnap
|
|
724
|
+
onClick={() => console.log('clicked')}
|
|
725
|
+
>
|
|
726
|
+
设置
|
|
727
|
+
</FloatingButton>
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
731
|
+
|------|------|------|--------|
|
|
732
|
+
| icon | 图标 | `ReactNode` | - |
|
|
733
|
+
| children | 文字标签 | `ReactNode` | - |
|
|
734
|
+
| variant | 样式变体 | `'default' \| 'neon' \| 'glow' \| 'glass'` | `'default'` |
|
|
735
|
+
| size | 尺寸(px) | `number` | `48` |
|
|
736
|
+
| draggable | 是否可拖拽 | `boolean` | `false` |
|
|
737
|
+
| initialPosition | 初始位置 | `{ x?: number, y?: number }` | 右下角 |
|
|
738
|
+
| edgeSnap | 边缘吸附 | `boolean` | `true` |
|
|
739
|
+
| snapThreshold | 吸附距离(px) | `number` | `60` |
|
|
740
|
+
| onClick | 点击回调 | `(e: MouseEvent) => void` | - |
|
|
741
|
+
| onDragEnd | 拖拽结束回调 | `(position: { x: number, y: number }) => void` | - |
|
|
742
|
+
|
|
743
|
+
---
|
|
744
|
+
|
|
343
745
|
## 主题定制
|
|
344
746
|
|
|
345
747
|
组件库使用 CSS 变量驱动主题,可通过覆盖变量自定义风格:
|
|
@@ -358,7 +760,17 @@ const columns = [
|
|
|
358
760
|
}
|
|
359
761
|
```
|
|
360
762
|
|
|
361
|
-
|
|
763
|
+
也可使用 ThemeProvider 运行时切换主题:
|
|
764
|
+
|
|
765
|
+
```tsx
|
|
766
|
+
import { ThemeProvider, useTheme } from 'react-tech-ui';
|
|
767
|
+
|
|
768
|
+
<ThemeProvider defaultTheme="aurora-purple">
|
|
769
|
+
<App />
|
|
770
|
+
</ThemeProvider>
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
或在 JavaScript 中获取主题对象:
|
|
362
774
|
|
|
363
775
|
```tsx
|
|
364
776
|
import { techTheme } from 'react-tech-ui';
|
|
@@ -385,12 +797,23 @@ src/
|
|
|
385
797
|
│ ├── ScrollTable/ # 滚动表格
|
|
386
798
|
│ ├── StatusIndicator/ # 状态指示器
|
|
387
799
|
│ ├── DecorationLine/ # 装饰线条
|
|
388
|
-
│
|
|
800
|
+
│ ├── TechButton/ # 科技按钮
|
|
801
|
+
│ ├── Modal/ # 模态对话框
|
|
802
|
+
│ ├── Drawer/ # 抽屉
|
|
803
|
+
│ ├── Toast/ # 轻提示
|
|
804
|
+
│ ├── Popconfirm/ # 气泡确认框
|
|
805
|
+
│ ├── FlowLight/ # 流光背景
|
|
806
|
+
│ ├── ThemeProvider/ # 主题提供者
|
|
807
|
+
│ ├── Skeleton/ # 骨架屏
|
|
808
|
+
│ ├── QRCode/ # 二维码
|
|
809
|
+
│ ├── Icon/ # 图标
|
|
810
|
+
│ ├── Masonry/ # 瀑布流布局
|
|
811
|
+
│ └── FloatingButton/ # 浮动按钮
|
|
389
812
|
└── index.ts # 统一导出入口
|
|
390
813
|
|
|
391
814
|
demo/
|
|
392
815
|
├── main.tsx # Demo 入口
|
|
393
|
-
└──
|
|
816
|
+
└── pages/ # 各组件演示页面
|
|
394
817
|
```
|
|
395
818
|
|
|
396
819
|
## 技术栈
|
|
@@ -400,6 +823,52 @@ demo/
|
|
|
400
823
|
- Vite 5
|
|
401
824
|
- CSS Variables(主题系统)
|
|
402
825
|
|
|
826
|
+
## 发布到 npm
|
|
827
|
+
|
|
828
|
+
### 首次发布
|
|
829
|
+
|
|
830
|
+
```bash
|
|
831
|
+
# 1. 构建组件库
|
|
832
|
+
npm run build:lib
|
|
833
|
+
|
|
834
|
+
# 2. 登录 npm(首次需要)
|
|
835
|
+
npm login
|
|
836
|
+
|
|
837
|
+
# 3. 发布
|
|
838
|
+
npm publish
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
### 更新版本发布
|
|
842
|
+
|
|
843
|
+
```bash
|
|
844
|
+
# 1. 更新版本号
|
|
845
|
+
npm version patch # 1.0.0 → 1.0.1(修 bug)
|
|
846
|
+
npm version minor # 1.0.0 → 1.1.0(新功能)
|
|
847
|
+
npm version major # 1.0.0 → 2.0.0(破坏性变更)
|
|
848
|
+
|
|
849
|
+
# 2. 构建
|
|
850
|
+
npm run build:lib
|
|
851
|
+
|
|
852
|
+
# 3. 发布
|
|
853
|
+
npm publish
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
> ⚠️ 注意:每次发布版本号必须比上次高,npm 不允许重复发布同一版本号。
|
|
857
|
+
|
|
858
|
+
### 开启双因素认证(2FA)时的发布方式
|
|
859
|
+
|
|
860
|
+
如果 npm 账号开启了 2FA,需要使用以下方式之一:
|
|
861
|
+
|
|
862
|
+
**方式一:OTP 验证码**
|
|
863
|
+
```bash
|
|
864
|
+
npm publish --otp=你的6位验证码
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
**方式二:Granular Access Token**
|
|
868
|
+
1. 在 npm 网站创建 Granular Access Token,勾选 **Allow publishing with 2FA bypass**
|
|
869
|
+
2. 设置 Token:`npm config set //registry.npmjs.org/:_authToken 你的Token`
|
|
870
|
+
3. 执行:`npm publish`
|
|
871
|
+
|
|
403
872
|
## 参与贡献
|
|
404
873
|
|
|
405
874
|
1. Fork 本仓库
|