@svton/taro-ui 1.0.0

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 ADDED
@@ -0,0 +1,297 @@
1
+ # @svton/taro-ui
2
+
3
+ Svton Taro UI Components Library - 小程序通用组件库
4
+
5
+ ## 📦 安装
6
+
7
+ ```bash
8
+ # 在 monorepo 中使用
9
+ pnpm add @svton/taro-ui@workspace:*
10
+ ```
11
+
12
+ ## 🎨 主题定制
13
+
14
+ ### 方式一:使用 SCSS 变量覆盖(推荐)
15
+
16
+ 在你的项目中创建自定义主题文件:
17
+
18
+ ```scss
19
+ // apps/mobile/src/styles/custom-theme.scss
20
+
21
+ // 1. 先定义你的自定义变量(会覆盖组件库的默认值)
22
+ $color-primary: #ff6b6b; // 自定义品牌色
23
+ $color-success: #51cf66; // 自定义成功色
24
+ $font-size-base: 28rpx; // 自定义基础字号
25
+ $btn-radius: 16rpx; // 自定义按钮圆角
26
+
27
+ // 2. 再导入组件库样式(!default 让自定义变量优先)
28
+ @import '@svton/taro-ui/src/styles/index.scss';
29
+ ```
30
+
31
+ 在你的组件中使用:
32
+
33
+ ```tsx
34
+ // MyComponent/index.tsx
35
+ import './index.scss'
36
+
37
+ // MyComponent/index.scss
38
+ @import '../../styles/custom-theme.scss'; // 导入你的自定义主题
39
+
40
+ .my-component {
41
+ // 使用主题变量
42
+ color: $color-primary;
43
+ padding: $spacing-md;
44
+ }
45
+ ```
46
+
47
+ ### 方式二:直接使用组件库主题
48
+
49
+ 如果不需要自定义,直接导入组件库样式:
50
+
51
+ ```scss
52
+ // 在组件样式文件中
53
+ @import '@svton/taro-ui/src/styles/index.scss';
54
+
55
+ .my-component {
56
+ color: $color-primary; // 使用默认品牌色 #1890ff
57
+ background: $color-bg-card; // 使用默认卡片背景
58
+ padding: $spacing-md; // 使用默认中等间距
59
+ }
60
+ ```
61
+
62
+ ## 🎯 可自定义的主题变量
63
+
64
+ ### 颜色系统
65
+
66
+ ```scss
67
+ // 品牌色
68
+ $color-primary: #1890ff;
69
+ $color-primary-light: #40a9ff;
70
+ $color-primary-dark: #0077ff;
71
+
72
+ // 功能色
73
+ $color-success: #52c41a;
74
+ $color-warning: #ffa940;
75
+ $color-error: #ff4d4f;
76
+
77
+ // 文字色
78
+ $color-text-primary: #1a1a1a;
79
+ $color-text-regular: #333333;
80
+ $color-text-secondary: #666666;
81
+
82
+ // 背景色
83
+ $color-bg-page: #f7f8fa;
84
+ $color-bg-card: #ffffff;
85
+ ```
86
+
87
+ ### 字体系统
88
+
89
+ ```scss
90
+ $font-size-h1: 36rpx;
91
+ $font-size-base: 26rpx;
92
+ $font-size-sm: 24rpx;
93
+
94
+ $font-weight-bold: 600;
95
+ $font-weight-medium: 500;
96
+ ```
97
+
98
+ ### 间距系统
99
+
100
+ ```scss
101
+ $spacing-xs: 8rpx;
102
+ $spacing-sm: 16rpx;
103
+ $spacing-md: 24rpx;
104
+ $spacing-lg: 32rpx;
105
+ ```
106
+
107
+ ### 圆角系统
108
+
109
+ ```scss
110
+ $radius-sm: 12rpx;
111
+ $radius-md: 24rpx;
112
+ $radius-lg: 32rpx;
113
+ ```
114
+
115
+ ### 组件尺寸
116
+
117
+ ```scss
118
+ // 按钮
119
+ $btn-height-lg: 88rpx;
120
+ $btn-height-md: 80rpx;
121
+ $btn-radius: $radius-md; // 可单独设置按钮圆角
122
+
123
+ // 输入框
124
+ $input-height: 80rpx;
125
+ $input-radius: $radius-sm;
126
+
127
+ // 头像
128
+ $avatar-sm: 64rpx;
129
+ $avatar-md: 96rpx;
130
+ ```
131
+
132
+ 查看完整变量列表:[src/styles/variables.scss](./src/styles/variables.scss)
133
+
134
+ ## 📚 组件使用
135
+
136
+ ### 导航组件
137
+
138
+ ```tsx
139
+ import { NavBar, StatusBar } from '@svton/taro-ui'
140
+
141
+ // 导航栏
142
+ <NavBar
143
+ title="页面标题"
144
+ showBack
145
+ backgroundColor="#1890FF"
146
+ rightContent={<View>操作</View>}
147
+ />
148
+
149
+ // 状态栏占位
150
+ <StatusBar backgroundColor="#1890FF" />
151
+ ```
152
+
153
+ ### Tab 组件
154
+
155
+ ```tsx
156
+ import { TabBar } from '@svton/taro-ui'
157
+
158
+ const tabs = [
159
+ { key: 'all', label: '全部' },
160
+ { key: 'hot', label: '热门' }
161
+ ]
162
+
163
+ <TabBar items={tabs} activeKey={activeTab} onChange={setActiveTab} />
164
+ ```
165
+
166
+ ### 按钮组件
167
+
168
+ ```tsx
169
+ import { Button } from '@svton/taro-ui'
170
+
171
+ <Button type="primary" size="large">主要按钮</Button>
172
+ <Button type="default">默认按钮</Button>
173
+ <Button type="danger" disabled>危险按钮</Button>
174
+ ```
175
+
176
+ ### 图片组件
177
+
178
+ ```tsx
179
+ import { ImageUploader, ImageGrid } from '@svton/taro-ui'
180
+
181
+ // 图片上传
182
+ <ImageUploader
183
+ value={images}
184
+ onChange={setImages}
185
+ maxCount={9}
186
+ />
187
+
188
+ // 图片展示
189
+ <ImageGrid images={images} />
190
+ ```
191
+
192
+ ### 列表组件
193
+
194
+ ```tsx
195
+ import { List } from '@svton/taro-ui';
196
+
197
+ <List
198
+ items={dataList}
199
+ loading={loading}
200
+ hasMore={hasMore}
201
+ onLoadMore={loadMore}
202
+ renderItem={(item) => <View>{item.title}</View>}
203
+ />;
204
+ ```
205
+
206
+ ## 🛠️ 工具函数
207
+
208
+ ```tsx
209
+ import { systemInfoManager } from '@svton/taro-ui';
210
+
211
+ // 获取系统信息
212
+ const info = systemInfoManager.getInfo();
213
+ console.log(info.statusBarHeight); // 状态栏高度
214
+ console.log(info.navBarHeight); // 导航栏总高度
215
+ console.log(info.menuButton); // 胶囊按钮位置
216
+ ```
217
+
218
+ ## 🎨 SCSS Mixins
219
+
220
+ 组件库提供了丰富的 SCSS 混入:
221
+
222
+ ```scss
223
+ @import '@svton/taro-ui/src/styles/index.scss';
224
+
225
+ .my-component {
226
+ // 布局
227
+ @include flex-center; // Flex 居中
228
+ @include flex-between; // Flex 两端对齐
229
+
230
+ // 文本
231
+ @include text-ellipsis; // 单行省略
232
+ @include text-ellipsis-multi(2); // 多行省略
233
+ @include heading(1); // 标题样式
234
+
235
+ // 交互
236
+ @include active-state; // 点击态
237
+ @include disabled-state; // 禁用态
238
+
239
+ // 其他
240
+ @include hide-scrollbar; // 隐藏滚动条
241
+ @include circle(100rpx); // 圆形容器
242
+ }
243
+ ```
244
+
245
+ 查看完整 Mixin 列表:[src/styles/mixins.scss](./src/styles/mixins.scss)
246
+
247
+ ## 🌈 主题示例
248
+
249
+ ### 示例 1:红色主题
250
+
251
+ ```scss
252
+ // red-theme.scss
253
+ $color-primary: #ff4d4f;
254
+ $color-primary-light: #ff7875;
255
+ $color-primary-dark: #cf1322;
256
+
257
+ @import '@svton/taro-ui/src/styles/index.scss';
258
+ ```
259
+
260
+ ### 示例 2:绿色主题
261
+
262
+ ```scss
263
+ // green-theme.scss
264
+ $color-primary: #52c41a;
265
+ $color-primary-light: #73d13d;
266
+ $color-primary-dark: #389e0d;
267
+
268
+ @import '@svton/taro-ui/src/styles/index.scss';
269
+ ```
270
+
271
+ ### 示例 3:深色主题
272
+
273
+ ```scss
274
+ // dark-theme.scss
275
+ $color-bg-page: #141414;
276
+ $color-bg-card: #1f1f1f;
277
+ $color-text-primary: #ffffff;
278
+ $color-text-regular: #e8e8e8;
279
+ $color-text-secondary: #a8a8a8;
280
+ $color-border: #434343;
281
+
282
+ @import '@svton/taro-ui/src/styles/index.scss';
283
+ ```
284
+
285
+ ## 📖 完整文档
286
+
287
+ - [组件库设计文档](../../docs/UI组件库设计文档.md)
288
+ - [组件库命名和迁移总结](../../docs/组件库命名和迁移总结.md)
289
+ - [Taro组件库最佳实践](../../docs/Taro组件库最佳实践.md)
290
+
291
+ ## 🤝 贡献指南
292
+
293
+ 欢迎提交 Issue 和 Pull Request!
294
+
295
+ ## 📄 License
296
+
297
+ MIT