-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(empty): actions add support for events (#2854)
* fix(empty): actions add support for events * fix: toast in taro environment * fix: types * fix: actions type * fix: actions type * fix: docs type * fix: docs type * fix: docs type
- Loading branch information
1 parent
67e02b5
commit f0c47ec
Showing
12 changed files
with
182 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
import { Empty, Toast } from '@nutui/nutui-react' | ||
|
||
const Demo7 = () => { | ||
return ( | ||
<Empty | ||
status="error" | ||
description="加载失败" | ||
style={{ marginBottom: '20px' }} | ||
actions={[ | ||
{ | ||
text: 'Action', | ||
type: 'info', | ||
onClick: () => { | ||
Toast.show({ title: 'Action Click!' }) | ||
}, | ||
}, | ||
]} | ||
/> | ||
) | ||
} | ||
export default Demo7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import { Empty, Toast } from '@nutui/nutui-react-taro' | ||
|
||
const Demo7 = () => { | ||
return ( | ||
<> | ||
<Toast id="toast-empty" /> | ||
<Empty | ||
status="error" | ||
description="加载失败" | ||
style={{ marginBottom: '20px' }} | ||
actions={[ | ||
{ | ||
text: 'Action', | ||
type: 'info', | ||
onClick: () => { | ||
Toast.show('toast-empty', { title: 'Action Click!' }) | ||
}, | ||
}, | ||
]} | ||
/> | ||
</> | ||
) | ||
} | ||
export default Demo7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import React from 'react' | ||
import { ButtonFill, ButtonSize, ButtonType } from '@/packages/button' | ||
|
||
export interface EmptyAction { | ||
text: string | ||
text: React.ReactNode | ||
className?: string | ||
style?: React.CSSProperties | ||
type?: ButtonType | ||
size?: ButtonSize | ||
fill?: ButtonFill | ||
disabled?: boolean | ||
onClick?: () => void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { EmptyAction } from './types' | ||
|
||
export const getButtonType = (actions: Array<EmptyAction>, index: number) => { | ||
if (!actions || actions.length === 0) return 'default' | ||
const action = actions[index] | ||
if (action.type) return action.type | ||
return actions.length > 1 && index === 0 ? 'default' : 'primary' | ||
} |