Skip to content

Commit 526dc88

Browse files
committed
Merge branch '3.0' into dev-harmony-badge
2 parents 7151d2b + a4f2168 commit 526dc88

File tree

19 files changed

+262
-235
lines changed

19 files changed

+262
-235
lines changed

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@
873873
"author": "Ymm0008"
874874
},
875875
{
876-
"version": "2.0.0",
876+
"version": "3.0.0",
877877
"name": "Toast",
878878
"type": "component",
879879
"tarodoc": true,
@@ -1207,7 +1207,7 @@
12071207
"author": "zhaoqian16"
12081208
},
12091209
{
1210-
"version": "2.0.0",
1210+
"version": "3.0.0",
12111211
"name": "TrendArrow",
12121212
"type": "component",
12131213
"cName": "趋势箭头",

src/packages/overlay/overlay.harmony.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
.nut-overlay {
2+
/* #ifdef rn */
23
position: absolute;
4+
/* #endif */
5+
/* #ifndef rn */
6+
position: fixed;
7+
/* #endif */
38
top: 0;
49
left: 0;
510
bottom: 0;
@@ -19,9 +24,6 @@
1924
.nut-overflow-hidden {
2025
overflow: hidden !important;
2126
}
22-
.nut-overflow-hidden .taro_page {
23-
overflow: hidden !important;
24-
}
2527

2628
@keyframes nut-fade-in {
2729
0% {

src/packages/toast/Notification.tsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
22
import classNames from 'classnames'
3-
import { Check, Loading, Failure, Tips } from '@nutui/icons-react'
3+
import { Success, Loading, Failure, Tips } from '@nutui/icons-react'
44
import { render, unmount } from '@/utils/render'
55
import Overlay from '@/packages/overlay/index'
66
import { BasicComponent } from '@/utils/typings'
@@ -83,23 +83,12 @@ export default class Notification extends React.PureComponent<
8383
renderIcon() {
8484
const { icon } = this.props
8585
if (typeof icon === 'string') {
86-
let iconNode = null
87-
switch (icon) {
88-
case 'success':
89-
iconNode = <Check />
90-
break
91-
case 'loading':
92-
iconNode = <Loading className="nut-icon-loading" />
93-
break
94-
case 'fail':
95-
iconNode = <Failure />
96-
break
97-
case 'warn':
98-
iconNode = <Tips />
99-
break
100-
default:
101-
break
102-
}
86+
const iconNode = {
87+
success: <Success />,
88+
fail: <Failure />,
89+
warn: <Tips />,
90+
loading: <Loading className="nut-icon-loading" />,
91+
}[icon]
10392
return <p className={`${classPrefix}-icon-wrapper`}>{iconNode}</p>
10493
}
10594
return icon
@@ -134,7 +123,6 @@ export default class Notification extends React.PureComponent<
134123

135124
const classes = classNames({
136125
'nut-toast-has-icon': icon,
137-
[`nut-toast-${size}`]: true,
138126
})
139127
return (
140128
<>
@@ -150,14 +138,20 @@ export default class Notification extends React.PureComponent<
150138
>
151139
<div className={`${classPrefix} ${classes}`} id={`toast-${id}`}>
152140
<div
153-
className={`${classPrefix}-inner ${classPrefix}-${position} ${contentClassName} ${wordBreak}`}
154-
style={contentStyle}
141+
className={`${classPrefix}-inner ${classPrefix}-${position} ${contentClassName} ${classPrefix}-inner-${size} ${classPrefix}-inner-${wordBreak}`}
142+
style={{
143+
...contentStyle,
144+
}}
155145
>
156146
{this.renderIcon()}
157147
{title ? (
158148
<div className={`${classPrefix}-title`}>{title}</div>
159149
) : null}
160-
<span className={`${classPrefix}-text`}>{content}</span>
150+
<span
151+
className={`${classPrefix}-text ${content ? '' : `${classPrefix}-text-empty`}`}
152+
>
153+
{content}
154+
</span>
161155
</div>
162156
</div>
163157
</Overlay>

src/packages/toast/__test__/toast.spec.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ test('test toast props', async () => {
6262
fireEvent.click(getByTestId('emit-click'))
6363
expect(onClickToast).toBeCalled()
6464
expect(document.querySelector('.nut-toast-text')?.innerHTML).toBe('文案')
65-
expect(document.querySelector('.nut-toast')).toHaveClass('nut-toast-small')
65+
expect(document.querySelector('.nut-toast-inner')).toHaveClass(
66+
'nut-toast-inner-small'
67+
)
6668
expect(document.querySelector('.nut-toast')).toHaveClass(
6769
'nut-toast-has-icon'
6870
)
@@ -83,7 +85,9 @@ test('event show-success-toast', async () => {
8385
await waitFor(() => {
8486
fireEvent.click(getByTestId('emit-click'))
8587
expect(onClickToast).toBeCalled()
86-
expect(document.querySelector('.nut-icon')).toHaveClass('nut-icon-Check')
88+
expect(document.querySelector('.nut-icon')).toHaveClass(
89+
'nut-icon nut-icon-Success'
90+
)
8791
expect(document.querySelector('.nut-toast-text')?.innerHTML).toBe('success')
8892
})
8993
})

src/packages/toast/demo.taro.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
2-
import { Toast } from '@nutui/nutui-react-taro'
32
import { ScrollView, View } from '@tarojs/components'
3+
import { Toast } from '@nutui/nutui-react-taro'
44
import Header from '@/sites/components/header'
55
import { useTranslate } from '@/sites/assets/locale/taro'
66
import Demo1 from './demos/taro/demo1'
@@ -32,20 +32,10 @@ const ToastDemo = () => {
3232
},
3333
})
3434

35-
function demoClass() {
36-
if (web()) {
37-
return 'web'
38-
}
39-
if (!harmonyAndRn()) {
40-
return 'full'
41-
}
42-
return ''
43-
}
44-
4535
return (
4636
<>
4737
<Header />
48-
<ScrollView className={`demo ${demoClass()}`}>
38+
<ScrollView className={`demo ${web() ? 'web' : ''}`}>
4939
<View className="h2">{translated.basic}</View>
5040
<Demo1 />
5141
<View className="h2">{translated.toastFunction}</View>
@@ -55,8 +45,13 @@ const ToastDemo = () => {
5545
<Demo3 />
5646
<View className="h2">{translated.toastCustomIcon}</View>
5747
<Demo4 />
58-
<View className="h2">{translated.toastWordBreak}</View>
59-
<Demo5 />
48+
{/* rn和 鸿蒙不支持 break-all */}
49+
{harmonyAndRn() ? null : (
50+
<>
51+
<View className="h2">{translated.toastWordBreak}</View>
52+
<Demo5 />
53+
</>
54+
)}
6055
</ScrollView>
6156
</>
6257
)

src/packages/toast/demos/h5/demo1.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const Demo1 = () => {
1313
title="成功提示"
1414
onClick={() =>
1515
Toast.show({
16-
content: '成功提示',
16+
title: '成功提示',
17+
content: '成功提示成功提示成功提示',
1718
icon: 'success',
1819
})
1920
}

src/packages/toast/demos/h5/demo5.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const Demo5 = () => {
66
Toast.show({
77
content: `Let's try ABCDEFGHIJKLMN here.`,
88
wordBreak: mode,
9+
contentStyle: { width: '200px' },
910
})
1011
}
1112
return (

src/packages/toast/demos/taro/demo1.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ const Demo1 = () => {
4141
}}
4242
/>
4343
<Cell
44-
title="Text文字提示"
44+
title="文字提示"
4545
onClick={() => {
4646
openToast('text', '网络失败,请稍后再试~')
4747
setShowToast(true)
4848
}}
4949
/>
5050
<Cell
51-
title="Toast 标题提示"
51+
title="标题提示"
5252
onClick={() => {
5353
openToast(
5454
'text',
@@ -61,30 +61,30 @@ const Demo1 = () => {
6161
}}
6262
/>
6363
<Cell
64-
title="Success 成功提示"
64+
title="成功提示"
6565
onClick={() => {
66-
openToast('success', '成功提示')
66+
openToast('success', '成功提示成功提示成功提示')
6767
setShowToast(true)
6868
}}
6969
/>
7070
<Cell
71-
title="Error 失败提示"
71+
title="失败提示"
7272
onClick={() => {
7373
openToast('fail', '失败提示')
7474
setShowToast(true)
7575
}}
7676
/>
7777
<Cell
78-
title=" Warning 警告提示"
78+
title="警告提示"
7979
onClick={() => {
8080
openToast('warn', '警告提示')
8181
setShowToast(true)
8282
}}
8383
/>
8484
<Cell
85-
title=" Loading 加载提示"
85+
title="加载提示"
8686
onClick={() => {
87-
openToast('loading', '加载中')
87+
openToast('loading', '加载提示')
8888
setShowToast(true)
8989
}}
9090
/>

src/packages/toast/demos/taro/demo2.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const Demo5 = () => {
99
title="函数调用"
1010
onClick={() => {
1111
Toast.show('test', {
12-
title: '函数调用',
13-
content: '函数调用',
12+
title: '函数调用函数调用',
13+
content: '函数调用函数调用函数调用函数调用函数',
1414
type: 'fail',
1515
duration: 2,
1616
position: 'center',

0 commit comments

Comments
 (0)