Skip to content

Commit c65ab8b

Browse files
authored
Merge pull request #838 from thundersdata-frontend/rn-issue
feat: 弹窗Modal的几个方法的title属性支持传入自定义组件
2 parents 8ee4d23 + dd79cf8 commit c65ab8b

File tree

6 files changed

+34
-13
lines changed

6 files changed

+34
-13
lines changed

.changeset/cool-melons-grab.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/react-native': patch
3+
---
4+
5+
feat: Modal的几个方法的title属性支持传入自定义组件

packages/react-native/src/modal/alert/AlertContainer.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ const AlertContainer: FC<
6969
{!!icon && <Flex justifyContent="center">{icon}</Flex>}
7070
{!!title && (
7171
<Flex justifyContent="center" marginVertical="x2">
72-
<Text variant="h1" color="text">
73-
{title}
74-
</Text>
72+
{typeof title === 'string' ? (
73+
<Text variant="h1" color="text">
74+
{title}
75+
</Text>
76+
) : (
77+
title
78+
)}
7579
</Flex>
7680
)}
7781
{typeof content === 'string' ? (

packages/react-native/src/modal/confirm/ConfirmContainer.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ const ConfirmContainer: FC<
3939
<Box marginBottom="x2">
4040
{!!icon && <Flex justifyContent="center">{icon}</Flex>}
4141
<Flex flexDirection="column" justifyContent="center" marginVertical="x2">
42-
<Text variant="h1" color="text">
43-
{title}
44-
</Text>
42+
{typeof title === 'string' ? (
43+
<Text variant="h1" color="text">
44+
{title}
45+
</Text>
46+
) : (
47+
title
48+
)}
4549
</Flex>
4650
{typeof content === 'string' ? (
4751
<Flex justifyContent="center">

packages/react-native/src/modal/prompt/PromptContainer.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ const PromptContainer: FC<
4646
<Box marginBottom="x2">
4747
<Flex flexDirection="column" justifyContent="center" marginBottom="x2">
4848
<Flex justifyContent="center" marginVertical="x2">
49-
<Text variant="h1" color="text">
50-
{title}
51-
</Text>
49+
{typeof title === 'string' ? (
50+
<Text variant="h1" color="text">
51+
{title}
52+
</Text>
53+
) : (
54+
title
55+
)}
5256
</Flex>
5357
{typeof content === 'string' ? (
5458
<Text variant="p1" color="text">

packages/react-native/src/modal/tip/TipContainer.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ const TipContainer: FC<
5757
<Box marginBottom="x2">
5858
{!!title && (
5959
<Flex justifyContent="center" marginVertical="x2">
60-
<Text variant="h1" color="text">
61-
{title}
62-
</Text>
60+
{typeof title === 'string' ? (
61+
<Text variant="h1" color="text">
62+
{title}
63+
</Text>
64+
) : (
65+
title
66+
)}
6367
</Flex>
6468
)}
6569
{typeof content === 'string' ? (

packages/react-native/src/modal/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface AlertProps {
3434
/** 警示性图标 */
3535
icon?: ReactNode;
3636
/** 标题 */
37-
title: string;
37+
title: ReactNode;
3838
/** 内容 */
3939
content?: ReactNode;
4040
/** 按钮文本 */

0 commit comments

Comments
 (0)