Skip to content

Commit a6863f0

Browse files
committed
Merge branch 'develop'
2 parents c16cd73 + 1782122 commit a6863f0

File tree

14 files changed

+352
-126
lines changed

14 files changed

+352
-126
lines changed

.github/ISSUE_TEMPLATE.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
为了更好的定位以及解决问题,在提交 ISSUE 时,我希望你
2+
3+
1. 标明 `mp-colorui` 的版本号
4+
2. 标明 `Taro` 的版本号
5+
3. 贴出关于这次问题的相关代码或截图

.idea/workspace.xml

+16-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

@types/grid.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ export interface IProps {
66
*
77
* 默认值 `3`
88
*/
9-
col: number;
9+
col: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
1010
/**
11-
* 类型,目前仅为一种选项
11+
* 类型
1212
*
1313
* 默认值 `normal`
1414
*
1515
* 可选类型 `square`, `normal`
1616
*/
17-
mode?: 'square';
17+
mode?: 'normal' | 'square';
1818
children?: any;
1919
}
2020

@types/swiper.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export interface IProps {
5555
* 可选参数 `card`, `screen`
5656
*/
5757
type?: TType;
58+
/**
59+
* 是否自动轮播
60+
*
61+
* 默认值 `false`
62+
*/
63+
autoplay?: boolean;
5864
/**
5965
* 每个点的形状
6066
*

@types/text.d.ts

+18
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ export interface IProps {
1616
* 可选类型 `xsmall`, `small`, `normal`, `large`, `xlarge`, `xxlarge`, `slarge`, `xslarge`
1717
*/
1818
size?: extendSizeType;
19+
/**
20+
* 行间距
21+
*
22+
* 默认值 `none`
23+
*/
24+
lineSpacing?: 'none' | 'small' | 'normal' | 'large' | number;
25+
/**
26+
* 字间距
27+
*
28+
* 默认值 `none`
29+
*/
30+
fontSpacing?: 'none' | 'small' | 'normal' | 'large' | number;
1931
/**
2032
* 文字颜色,可选类型请查看 默认色-标准色
2133
*/
@@ -56,6 +68,12 @@ export interface IProps {
5668
* 文字
5769
*/
5870
text?: string;
71+
/**
72+
* 字体粗细
73+
*
74+
* 默认值 `normal`
75+
*/
76+
fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | number;
5977
children?: any;
6078
}
6179

config/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ const path = require('path');
22

33
const config = {
44
projectName: 'mp-colorui',
5+
alias:{
6+
'@/components': path.resolve(__dirname, '..', 'src/components'),
7+
'@/': path.resolve(__dirname, '..', 'src/'),
8+
'@types': path.resolve(__dirname, '..', '@types')
9+
},
510
date: '2018-10-30',
611
designWidth: 750,
712
deviceRatio: {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mp-colorui",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "MP ColorUI 是一款基于 Taro 框架并且联合 Color-UI CSS 库开发的多端 UI 组件库(支持小程序端和H5端)",
55
"keywords": [
66
"taro",

src/components/avatar/index.tsx

+81-64
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,111 @@
1-
import { Text, View } from '@tarojs/components'
2-
import Taro, { pxTransform, useEffect, useState } from '@tarojs/taro'
3-
import { isNumber, generateId } from '../utils'
4-
import { BG_COLOR_LIST } from '../utils/model'
5-
import { IProps, THeaderArray } from '../../../@types/avatar'
1+
import { Text, View, Image } from '@tarojs/components';
2+
import Taro, { pxTransform, useEffect, useState } from '@tarojs/taro';
3+
import { isNumber, generateId } from '../utils';
4+
import { BG_COLOR_LIST } from '../utils/model';
5+
import { IProps, THeaderArray } from '../../../@types/avatar';
66

77
function ClAvatar(props: IProps) {
8-
const [headList, setHeadList] = useState(props.headerArray)
8+
const [headList, setHeadList] = useState(props.headerArray);
99
useEffect(() => {
10-
const list = props.headerArray || []
11-
setHeadList(list.map((item: any) => {
12-
item.cu_avatar_id = generateId()
13-
return item
14-
}))
15-
}, [props.headerArray])
10+
const list = props.headerArray || [];
11+
setHeadList(
12+
list.map((item: any) => {
13+
item.cu_avatar_id = generateId();
14+
return item;
15+
})
16+
);
17+
}, [props.headerArray]);
1618
const onClick = () => {
17-
props.onClick && props.onClick()
18-
}
19+
props.onClick && props.onClick();
20+
};
1921
const customSize = {
20-
'small': 48,
21-
'normal': 64,
22-
'large': 96,
23-
'xlarge': 128
24-
}
25-
const width = isNumber(props.size) ? pxTransform(props.size) : pxTransform(customSize[props.size || 'normal'])
26-
const height = isNumber(props.size) ? pxTransform(props.size) : pxTransform(customSize[props.size || 'normal'])
27-
const em = isNumber(props.size) ? props.size / 48 : customSize[props.size || 'normal'] / 48
28-
const avatarArray = headList ? (
29-
headList.map(((item: any) => (
30-
<View
31-
key={item.cu_avatar_id}
32-
className={`${props.shape} ${BG_COLOR_LIST[item.bgColor || 'black']} ${
33-
props.shadow ? 'shadow' : ''
34-
} cu-avatar`}
35-
style={item.url ? {
36-
backgroundImage: `url(${item.url})`,
22+
small: 48,
23+
normal: 64,
24+
large: 96,
25+
xlarge: 128
26+
};
27+
const width = isNumber(props.size)
28+
? pxTransform(props.size as number)
29+
: pxTransform(customSize[props.size || 'normal']);
30+
const height = isNumber(props.size)
31+
? pxTransform(props.size as number)
32+
: pxTransform(customSize[props.size || 'normal']);
33+
const em = isNumber(props.size)
34+
? (props.size as number) / 48
35+
: customSize[props.size || 'normal'] / 48;
36+
const avatarArray = (headList as THeaderArray[]).map((item: any) => (
37+
<View
38+
key={item.cu_avatar_id}
39+
className={`${props.shape} ${BG_COLOR_LIST[item.bgColor || 'black']} ${
40+
props.shadow ? 'shadow' : ''
41+
} cu-avatar`}
42+
style={{
43+
width,
44+
height,
45+
fontSize: `${em}em`
46+
}}
47+
>
48+
<Image
49+
className={`${props.shape}`}
50+
src={item.url}
51+
style={{
3752
width,
3853
height,
39-
fontSize: `${em}em`
40-
} : { width, height, fontSize: `${em}em` }}
41-
>
42-
<Text className={`cuIcon-${item.icon}`}>
43-
{item.text ? item.text.slice(0, 1) : ''}
44-
</Text>
45-
{item.tag ? (
46-
<View
47-
className={`cu-tag badge cuIcon-${item.tag} ${
48-
item.tagColor ? BG_COLOR_LIST[item.tagColor] : ''
49-
}`}
50-
/>
51-
) : (
52-
''
53-
)}
54-
</View>
55-
))
56-
) : (
57-
<View />
58-
)
54+
position: 'absolute',
55+
left: 0,
56+
right: 0,
57+
bottom: 0,
58+
top: 0
59+
}}
60+
mode='aspectFill'
61+
/>
62+
<Text className={`cuIcon-${item.icon}`}>
63+
{item.text ? item.text.slice(0, 1) : ''}
64+
</Text>
65+
{item.tag ? (
66+
<View
67+
className={`cu-tag badge cuIcon-${item.tag} ${
68+
item.tagColor ? BG_COLOR_LIST[item.tagColor] : ''
69+
}`}
70+
/>
71+
) : (
72+
''
73+
)}
74+
</View>
75+
));
5976
const avatarArrayComponent = (
6077
<View
6178
className='cu-avatar-group'
6279
onClick={() => {
63-
onClick()
80+
onClick();
6481
}}
6582
>
6683
{avatarArray}
6784
</View>
68-
)
85+
);
6986
return props.headerArray && props.headerArray.length > 1 ? (
7087
avatarArrayComponent
7188
) : (
72-
<View
73-
onClick={() => {
74-
onClick()
75-
}}
76-
>
77-
{avatarArray}
78-
</View>
79-
)
89+
<View
90+
onClick={() => {
91+
onClick();
92+
}}
93+
>
94+
{avatarArray}
95+
</View>
96+
);
8097
}
8198

8299
ClAvatar.options = {
83100
addGlobalClass: true
84-
}
101+
};
85102

86103
ClAvatar.defaultProps = {
87104
size: 'normal',
88105
shape: 'radius',
89106
type: 'normal',
90107
headerArray: [],
91108
shadow: true
92-
} as IProps
109+
} as IProps;
93110

94-
export default ClAvatar
111+
export default ClAvatar;

src/components/select/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Picker, View } from '@tarojs/components';
2-
import Taro, { useState } from '@tarojs/taro';
2+
import Taro, { useState, useMemo } from '@tarojs/taro';
33
import { getNowDate } from '../utils/index';
44
import { IProps } from '../../../@types/select';
55
import { getAreaData } from "../utils/area";
@@ -60,6 +60,10 @@ function ClSelect(props: IProps) {
6060
const value: string = getSelectorValue(index);
6161
setSelected(value);
6262
};
63+
useMemo(() => {
64+
props.mode === 'selector' && setSelected(getSelectorValue(selector.value))
65+
props.mode === 'multiSelector' && setMutiSelected(getMutiSelectorValue(mutiSelector.value))
66+
}, [props.selector])
6367
// 多选
6468
const getMutiSelectorValue = mutiIndex => {
6569
const value: any[] = [];

0 commit comments

Comments
 (0)