Skip to content

Commit

Permalink
Merge pull request #838 from thundersdata-frontend/rn-issue
Browse files Browse the repository at this point in the history
feat: 弹窗Modal的几个方法的title属性支持传入自定义组件
  • Loading branch information
chj-damon authored Mar 6, 2024
2 parents 8ee4d23 + dd79cf8 commit c65ab8b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-melons-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/react-native': patch
---

feat: Modal的几个方法的title属性支持传入自定义组件
10 changes: 7 additions & 3 deletions packages/react-native/src/modal/alert/AlertContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ const AlertContainer: FC<
{!!icon && <Flex justifyContent="center">{icon}</Flex>}
{!!title && (
<Flex justifyContent="center" marginVertical="x2">
<Text variant="h1" color="text">
{title}
</Text>
{typeof title === 'string' ? (
<Text variant="h1" color="text">
{title}
</Text>
) : (
title
)}
</Flex>
)}
{typeof content === 'string' ? (
Expand Down
10 changes: 7 additions & 3 deletions packages/react-native/src/modal/confirm/ConfirmContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ const ConfirmContainer: FC<
<Box marginBottom="x2">
{!!icon && <Flex justifyContent="center">{icon}</Flex>}
<Flex flexDirection="column" justifyContent="center" marginVertical="x2">
<Text variant="h1" color="text">
{title}
</Text>
{typeof title === 'string' ? (
<Text variant="h1" color="text">
{title}
</Text>
) : (
title
)}
</Flex>
{typeof content === 'string' ? (
<Flex justifyContent="center">
Expand Down
10 changes: 7 additions & 3 deletions packages/react-native/src/modal/prompt/PromptContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ const PromptContainer: FC<
<Box marginBottom="x2">
<Flex flexDirection="column" justifyContent="center" marginBottom="x2">
<Flex justifyContent="center" marginVertical="x2">
<Text variant="h1" color="text">
{title}
</Text>
{typeof title === 'string' ? (
<Text variant="h1" color="text">
{title}
</Text>
) : (
title
)}
</Flex>
{typeof content === 'string' ? (
<Text variant="p1" color="text">
Expand Down
10 changes: 7 additions & 3 deletions packages/react-native/src/modal/tip/TipContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ const TipContainer: FC<
<Box marginBottom="x2">
{!!title && (
<Flex justifyContent="center" marginVertical="x2">
<Text variant="h1" color="text">
{title}
</Text>
{typeof title === 'string' ? (
<Text variant="h1" color="text">
{title}
</Text>
) : (
title
)}
</Flex>
)}
{typeof content === 'string' ? (
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/src/modal/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface AlertProps {
/** 警示性图标 */
icon?: ReactNode;
/** 标题 */
title: string;
title: ReactNode;
/** 内容 */
content?: ReactNode;
/** 按钮文本 */
Expand Down

0 comments on commit c65ab8b

Please sign in to comment.