Skip to content

Commit 88462db

Browse files
committed
feat: 合并3.x 分支
2 parents 3cbfe75 + f1c8cd9 commit 88462db

File tree

9 files changed

+77
-29
lines changed

9 files changed

+77
-29
lines changed

src/packages/badge/badge.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
}
5959

6060
&-number {
61-
font-family: 'JD';
61+
font-family: 'JDZH-Regular';
6262
}
6363

6464
&-one {

src/packages/col/col.taro.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, {
44
useContext,
55
useEffect,
66
useState,
7+
useMemo,
78
} from 'react'
89
import classNames from 'classnames'
910
import { View } from '@tarojs/components'
@@ -27,19 +28,16 @@ export const Col: FunctionComponent<Partial<TaroColProps>> = (props) => {
2728
...defaultProps,
2829
...props,
2930
}
30-
const [colName, setColName] = useState('')
31-
const [colStyle, setColStyle] = useState({})
3231
const { gutter } = useContext(DataContext) as any
3332

34-
const classs = () => {
35-
// 定义col的class类
33+
const classs = useMemo(() => {
3634
const prefixCls = 'nut-col'
3735
return `${prefixCls} ${prefixCls}-${span} ${
3836
gutter ? `${prefixCls}-gutter` : ''
3937
} ${prefixCls}-offset-${offset}`
40-
}
41-
const getStyle = () => {
42-
// 定义col的style类
38+
}, [offset, span, gutter])
39+
40+
const getStyle = useMemo(() => {
4341
const style: CSSProperties = {}
4442
if (!isFirst) {
4543
style.paddingLeft = pxTransform((gutter as number) / 2)
@@ -48,11 +46,15 @@ export const Col: FunctionComponent<Partial<TaroColProps>> = (props) => {
4846
style.paddingRight = pxTransform((gutter as number) / 2)
4947
}
5048
return style
51-
}
49+
}, [isFirst, isLast, gutter])
50+
51+
const [colName, setColName] = useState(classs)
52+
const [colStyle, setColStyle] = useState(getStyle)
53+
5254
useEffect(() => {
5355
setColName(classs)
5456
setColStyle(getStyle)
55-
}, [span, offset, gutter])
57+
}, [classs, getStyle])
5658

5759
return (
5860
<View

src/packages/col/col.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, {
44
useContext,
55
useEffect,
66
useState,
7+
useMemo,
78
} from 'react'
89
import classNames from 'classnames'
910
import { DataContext } from '@/packages/row/context'
@@ -27,19 +28,16 @@ export const Col: FunctionComponent<
2728
...defaultProps,
2829
...props,
2930
}
30-
const [colName, setColName] = useState('')
31-
const [colStyle, setColStyle] = useState({})
3231
const { gutter } = useContext(DataContext) as any
3332

34-
const classs = () => {
35-
// 定义col的class类
33+
const classs = useMemo(() => {
3634
const prefixCls = 'nut-col'
3735
return `${prefixCls} ${prefixCls}-${span} ${
3836
gutter ? `${prefixCls}-gutter` : ''
3937
} ${prefixCls}-offset-${offset}`
40-
}
41-
const getStyle = () => {
42-
// 定义col的style类
38+
}, [offset, span, gutter])
39+
40+
const getStyle = useMemo(() => {
4341
const style: CSSProperties = {}
4442
if (!isFirst) {
4543
style.paddingLeft = `${(gutter as number) / 2}px`
@@ -48,11 +46,15 @@ export const Col: FunctionComponent<
4846
style.paddingRight = `${(gutter as number) / 2}px`
4947
}
5048
return style
51-
}
49+
}, [isFirst, isLast, gutter])
50+
51+
const [colName, setColName] = useState(classs)
52+
const [colStyle, setColStyle] = useState(getStyle)
53+
5254
useEffect(() => {
5355
setColName(classs)
5456
setColStyle(getStyle)
55-
}, [span, offset, gutter])
57+
}, [classs, getStyle])
5658

5759
return (
5860
<div

src/packages/countdown/countdown.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
font-weight: $coutdown-font-weight;
1717
font-size: $countdown-font-size;
1818
line-height: calc($countdown-font-size + 2px);
19-
font-family: 'JD';
19+
font-family: 'JDZH-Regular';
2020
}
2121
&-number,
2222
&-number-primary {

src/packages/price/price.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
&-integer,
1010
&-decimal {
1111
color: $price-color;
12-
font-family: 'JD';
12+
font-family: 'JDZH-Bold';
1313
line-height: 1;
1414
}
1515

@@ -18,7 +18,7 @@
1818
&-symbol,
1919
&-integer,
2020
&-decimal {
21-
font-family: 'JD-Bold';
21+
font-family: 'JDZH-Bold';
2222
color: $price-darkgray-color;
2323
}
2424
}
@@ -29,7 +29,7 @@
2929
&-symbol,
3030
&-integer,
3131
&-decimal {
32-
font-family: 'JD-Bold';
32+
font-family: 'JDZH-Bold';
3333
color: $price-primary-color;
3434
}
3535
}

src/packages/rate/rate.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
display: inline-flex;
101101
align-items: center;
102102
color: $rate-font-color;
103-
font-family: 'JD';
103+
font-family: 'JDZH-Regular';
104104
line-height: 1;
105105

106106
&-normal {

src/packages/uploader/__tests__/uploader.spec.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,50 @@ test('should render base uploader other props', () => {
9393
expect(fileItemClick).toBeCalled()
9494
})
9595

96+
test('should render no-image file uploader list', () => {
97+
const App = () => {
98+
const defaultFileList: FileItem[] = [
99+
{
100+
name: '文件1.txt',
101+
url: 'https://m.360buyimg.com/babel/jfs/t1/164410/22/25162/93384/616eac6cE6c711350/0cac53c1b82e1b05.gif',
102+
status: 'success',
103+
message: '上传成功',
104+
type: 'list',
105+
uid: '123',
106+
},
107+
{
108+
name: '文件2.ppt',
109+
url: 'https://m.360buyimg.com/babel/jfs/t1/164410/22/25162/93384/616eac6cE6c711350/0cac53c1b82e1b05.gif',
110+
status: 'error',
111+
message: '上传失败',
112+
type: 'list',
113+
uid: '124',
114+
},
115+
{
116+
name: '文件3.cpp',
117+
url: 'https://m.360buyimg.com/babel/jfs/t1/164410/22/25162/93384/616eac6cE6c711350/0cac53c1b82e1b05.gif',
118+
status: 'uploading',
119+
message: '上传中...',
120+
type: 'list',
121+
uid: '125',
122+
},
123+
]
124+
125+
return (
126+
<Uploader
127+
defaultValue={defaultFileList}
128+
uploadIcon="dongdong"
129+
previewType="list"
130+
/>
131+
)
132+
}
133+
134+
const { container } = render(<App />)
135+
const toast1 = container.querySelectorAll('.list')
136+
expect(toast1).toBeTruthy()
137+
expect(toast1.length).toBe(3)
138+
})
139+
96140
test('should render base uploader list', () => {
97141
const App = () => {
98142
const defaultFileList: FileItem[] = [

src/packages/uploader/uploader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ const InternalUploader: ForwardRefRenderFunction<
183183
name: file.name,
184184
type: file.type,
185185
}
186-
if (preview && file.type?.includes('image')) {
186+
if (preview) {
187187
const reader = new FileReader()
188188
reader.onload = (event: ProgressEvent<FileReader>) => {
189189
fileListRef.current = [

src/styles/jd-font.scss

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)