@particle-network/ui-shared 0.0.1 → 0.0.3

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.
Files changed (2) hide show
  1. package/README.md +258 -0
  2. package/package.json +5 -2
package/README.md ADDED
@@ -0,0 +1,258 @@
1
+ # @particle-network/ui-shared
2
+
3
+ <div align="center">
4
+ <p align="center">
5
+ <strong>UniversalX Design System - 共享工具库</strong>
6
+ </p>
7
+
8
+ <p align="center">
9
+ 为 UI 组件库提供统一的主题系统、工具函数和设计令牌
10
+ </p>
11
+
12
+ <p align="center">
13
+ <img src="https://img.shields.io/badge/internal-package-orange.svg" alt="internal package" />
14
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license" />
15
+ </p>
16
+ </div>
17
+
18
+ ## 📦 关于
19
+
20
+ 这是 UniversalX Design System 的内部共享包,为 `@particle-network/ui-react` 和 `@particle-network/ui-native` 提供:
21
+
22
+ - 🎨 **设计令牌** - 统一的颜色、间距、圆角等设计变量
23
+ - 🔧 **工具函数** - 共享的实用工具函数
24
+ - 🎯 **类型定义** - 通用的 TypeScript 类型
25
+ - 🌈 **主题系统** - 跨平台的主题配置
26
+
27
+ ## 🚀 使用方法
28
+
29
+ > ⚠️ 注意:这是一个内部包,通常不需要直接安装。它会作为 UI 组件库的依赖自动安装。
30
+
31
+ ### 在组件库中使用
32
+
33
+ ```tsx
34
+ import { colors, spacing, radius } from '@particle-network/ui-shared';
35
+ import { Theme, Size, Color } from '@particle-network/ui-shared';
36
+
37
+ // 使用设计令牌
38
+ const buttonStyles = {
39
+ padding: spacing.md,
40
+ borderRadius: radius.md,
41
+ backgroundColor: colors.primary,
42
+ };
43
+
44
+ // 使用类型定义
45
+ interface ButtonProps {
46
+ size?: Size;
47
+ color?: Color;
48
+ }
49
+ ```
50
+
51
+ ## 📚 导出内容
52
+
53
+ ### 设计令牌
54
+
55
+ #### 颜色系统 (`color.ts`)
56
+
57
+ ```typescript
58
+ export const colors = {
59
+ // 主题色
60
+ primary: '#1890ff',
61
+ secondary: '#52c41a',
62
+ success: '#52c41a',
63
+ warning: '#faad14',
64
+ danger: '#ff4d4f',
65
+ info: '#1890ff',
66
+
67
+ // 中性色
68
+ white: '#ffffff',
69
+ black: '#000000',
70
+ gray: {
71
+ 50: '#fafafa',
72
+ 100: '#f5f5f5',
73
+ 200: '#e5e5e5',
74
+ 300: '#d4d4d4',
75
+ 400: '#a3a3a3',
76
+ 500: '#737373',
77
+ 600: '#525252',
78
+ 700: '#404040',
79
+ 800: '#262626',
80
+ 900: '#171717',
81
+ },
82
+ };
83
+ ```
84
+
85
+ #### 间距系统 (`spacing.ts`)
86
+
87
+ ```typescript
88
+ export const spacing = {
89
+ xs: 4,
90
+ sm: 8,
91
+ md: 16,
92
+ lg: 24,
93
+ xl: 32,
94
+ '2xl': 48,
95
+ '3xl': 64,
96
+ };
97
+ ```
98
+
99
+ #### 圆角系统 (`radius.ts`)
100
+
101
+ ```typescript
102
+ export const radius = {
103
+ none: 0,
104
+ sm: 4,
105
+ md: 8,
106
+ lg: 12,
107
+ xl: 16,
108
+ '2xl': 24,
109
+ full: 9999,
110
+ };
111
+ ```
112
+
113
+ #### 尺寸定义 (`size.ts`)
114
+
115
+ ```typescript
116
+ export const sizes = {
117
+ xs: 'xs',
118
+ sm: 'sm',
119
+ md: 'md',
120
+ lg: 'lg',
121
+ xl: 'xl',
122
+ } as const;
123
+
124
+ export type Size = keyof typeof sizes;
125
+ ```
126
+
127
+ ### 主题系统 (`theme.ts`)
128
+
129
+ ```typescript
130
+ export interface Theme {
131
+ colors: typeof colors;
132
+ spacing: typeof spacing;
133
+ radius: typeof radius;
134
+ sizes: typeof sizes;
135
+ }
136
+
137
+ export const defaultTheme: Theme = {
138
+ colors,
139
+ spacing,
140
+ radius,
141
+ sizes,
142
+ };
143
+
144
+ // 主题创建工具
145
+ export function createTheme(overrides: DeepPartial<Theme>): Theme {
146
+ return deepMerge(defaultTheme, overrides);
147
+ }
148
+ ```
149
+
150
+ ### 工具函数
151
+
152
+ ```typescript
153
+ // 类型工具
154
+ export type DeepPartial<T> = {
155
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
156
+ };
157
+
158
+ // 合并工具
159
+ export function deepMerge<T>(target: T, source: DeepPartial<T>): T;
160
+
161
+ // 样式工具
162
+ export function cn(...classes: (string | undefined | null | false)[]): string;
163
+ ```
164
+
165
+ ## 🔧 开发
166
+
167
+ ### 构建
168
+
169
+ ```bash
170
+ # 构建包
171
+ yarn build
172
+
173
+ # 开发模式(监听文件变化)
174
+ yarn dev
175
+ ```
176
+
177
+ ### 项目结构
178
+
179
+ ```
180
+ packages/shared/
181
+ ├── src/
182
+ │ ├── color.ts # 颜色定义
183
+ │ ├── spacing.ts # 间距定义
184
+ │ ├── radius.ts # 圆角定义
185
+ │ ├── size.ts # 尺寸定义
186
+ │ ├── theme.ts # 主题系统
187
+ │ └── index.ts # 导出入口
188
+ ├── dist/ # 构建输出
189
+ └── package.json
190
+ ```
191
+
192
+ ## 🎨 设计原则
193
+
194
+ ### 一致性
195
+
196
+ 所有设计令牌在 Web 和 Native 平台保持一致,确保跨平台的视觉统一性。
197
+
198
+ ### 可扩展性
199
+
200
+ 主题系统支持深度定制,可以轻松覆盖默认值:
201
+
202
+ ```typescript
203
+ import { createTheme } from '@particle-network/ui-shared';
204
+
205
+ const customTheme = createTheme({
206
+ colors: {
207
+ primary: '#ff6b6b',
208
+ secondary: '#4ecdc4',
209
+ },
210
+ spacing: {
211
+ md: 20, // 覆盖默认的 16
212
+ },
213
+ });
214
+ ```
215
+
216
+ ### 类型安全
217
+
218
+ 所有导出都包含完整的 TypeScript 类型定义,提供良好的开发体验。
219
+
220
+ ## 🔄 版本管理
221
+
222
+ 作为内部包,版本更新会自动触发依赖它的组件库更新。使用 Changesets 管理版本:
223
+
224
+ ```bash
225
+ # 创建变更记录
226
+ yarn changeset
227
+
228
+ # 更新版本
229
+ yarn changeset:version
230
+
231
+ # 发布(通过 CI/CD)
232
+ yarn changeset:release
233
+ ```
234
+
235
+ ## 🤝 贡献
236
+
237
+ 修改共享包时请注意:
238
+
239
+ 1. **向后兼容** - 避免破坏性更改
240
+ 2. **同步更新** - 确保 Web 和 Native 组件库都能正常工作
241
+ 3. **文档更新** - 更新相关文档和类型定义
242
+ 4. **测试覆盖** - 添加相应的测试用例
243
+
244
+ ## 📄 许可证
245
+
246
+ MIT © [UniversalX Team](https://github.com/particle-network)
247
+
248
+ ## 🔗 相关链接
249
+
250
+ - [主项目仓库](https://gitlab.minijoy.work/frontend/ux-design)
251
+ - [React 组件库](../ui-react)
252
+ - [React Native 组件库](../ui-react-native)
253
+
254
+ ---
255
+
256
+ <div align="center">
257
+ Made with ❤️ by UniversalX Team
258
+ </div>
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@particle-network/ui-shared",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
+ "main": "./dist/index.js",
6
+ "react-native": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
5
9
  "exports": {
6
10
  ".": {
7
11
  "types": "./dist/index.d.ts",
@@ -9,7 +13,6 @@
9
13
  },
10
14
  "./tailwind-preset": "./tailwind-preset.js"
11
15
  },
12
- "types": "./dist/index.d.ts",
13
16
  "files": [
14
17
  "dist"
15
18
  ],