Skip to content

Commit 6f4a65e

Browse files
committed
feat: 支持自定义受控 loading 态图标
1 parent 84cf723 commit 6f4a65e

File tree

9 files changed

+15
-4
lines changed

9 files changed

+15
-4
lines changed

src/packages/switch/doc.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import { Switch } from '@nutui/nutui-react'
7777
| disabled | Disabled | `boolean` | `false` |
7878
| activeText | Text description when opening | `ReactNode` | `-` |
7979
| inactiveText | Text description when closed | `ReactNode` | `-` |
80+
| loadingIcon | Controlled loading state icon | `ReactNode` | `<Loading1 />` |
8081
| onChange | Trigger when switching switches | `onChange:(value: boolean, event: Event)` | `-` |
8182

8283
## Theming

src/packages/switch/doc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import { Switch } from '@nutui/nutui-react'
7777
| disabled | 禁用状态 | `boolean` | `false` |
7878
| activeText | 打开时文字描述 | `ReactNode` | `-` |
7979
| inactiveText | 关闭时文字描述 | `ReactNode` | `-` |
80+
| loadingIcon | 受控 loading 态图标 | `ReactNode` | `<Loading1 />` |
8081
| onChange | 切换开关时触发 | `onChange:(value: boolean, event: Event)` | `-` |
8182

8283
## 主题定制

src/packages/switch/doc.taro.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import { Switch } from '@nutui/nutui-react-taro'
7777
| disabled | 禁用状态 | `boolean` | `false` |
7878
| activeText | 打开时文字描述 | `ReactNode` | `-` |
7979
| inactiveText | 关闭时文字描述 | `ReactNode` | `-` |
80+
| loadingIcon | 受控 loading 态图标 | `ReactNode` | `<Loading1 />` |
8081
| onChange | 切换开关时触发 | `onChange:(value: boolean, event: Event)` | `-` |
8182

8283
## 主题定制

src/packages/switch/doc.zh-TW.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import { Switch } from '@nutui/nutui-react'
7777
| disabled | 禁用狀態 | `boolean` | `false` |
7878
| activeText | 打開時文字描述 | `ReactNode` | `-` |
7979
| inactiveText | 關閉時文字描述 | `ReactNode` | `-` |
80+
| loadingIcon | 受控 loading 態圖標 | `ReactNode` | `<Loading1 />` |
8081
| onChange | 切換開關時觸發 | `onChange:(value: boolean, event: Event)` | `-` |
8182

8283
## 主題定製

src/packages/switch/switch.taro.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const defaultProps = {
1313
disabled: false,
1414
activeText: '',
1515
inactiveText: '',
16+
loadingIcon: <Loading1 />,
1617
} as TaroSwitchProps
1718
export const Switch: FunctionComponent<Partial<TaroSwitchProps>> = (props) => {
1819
const {
@@ -21,6 +22,7 @@ export const Switch: FunctionComponent<Partial<TaroSwitchProps>> = (props) => {
2122
disabled,
2223
activeText,
2324
inactiveText,
25+
loadingIcon,
2426
className,
2527
style,
2628
onChange,
@@ -80,8 +82,8 @@ export const Switch: FunctionComponent<Partial<TaroSwitchProps>> = (props) => {
8082
},
8183
])}
8284
>
83-
{changing ? (
84-
<Loading1 />
85+
{changing && loadingIcon ? (
86+
<>{loadingIcon}</>
8587
) : (
8688
<>
8789
{!value && !activeText && (

src/packages/switch/switch.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const defaultProps = {
1111
disabled: false,
1212
activeText: '',
1313
inactiveText: '',
14+
loadingIcon: <Loading1 />,
1415
} as WebSwitchProps
1516
export const Switch: FunctionComponent<Partial<WebSwitchProps>> = (props) => {
1617
const {
@@ -19,6 +20,7 @@ export const Switch: FunctionComponent<Partial<WebSwitchProps>> = (props) => {
1920
disabled,
2021
activeText,
2122
inactiveText,
23+
loadingIcon,
2224
className,
2325
style,
2426
onChange,
@@ -78,8 +80,8 @@ export const Switch: FunctionComponent<Partial<WebSwitchProps>> = (props) => {
7880
},
7981
])}
8082
>
81-
{changing ? (
82-
<Loading1 />
83+
{changing && loadingIcon ? (
84+
<>{loadingIcon}</>
8385
) : (
8486
<>
8587
{!value && !activeText && (

src/sites/sites-react/doc/docs/react/migrate-from-v2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ plugins: [
225225

226226
- `activeText` 属性类型更改为`ReactNode`
227227
- `inactiveText` 属性类型更改为 `ReactNode`
228+
- 新增 `loadingIcon` 属性,受控 loading 态图标
228229

229230
[//]: # '#### Toast'
230231

src/sites/sites-react/doc/docs/taro/migrate-from-v2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ plugins: [
228228

229229
- `activeText` 属性类型更改为`ReactNode`
230230
- `inactiveText` 属性类型更改为 `ReactNode`
231+
- 新增 `loadingIcon` 属性,受控 loading 态图标
231232

232233
[//]: # '#### Toast'
233234

src/types/spec/switch/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export interface BaseSwitch extends BaseProps {
77
disabled: boolean
88
activeText: ReactNode
99
inactiveText: ReactNode
10+
loadingIcon: ReactNode
1011
onChange: (val: boolean) => void
1112
}

0 commit comments

Comments
 (0)