Skip to content

Commit 3c23a5d

Browse files
refactor: seperated dialog components into three components
1 parent 27974f0 commit 3c23a5d

File tree

4 files changed

+63
-20
lines changed

4 files changed

+63
-20
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ReactNode } from "react"
2+
import { Modal } from "../Modal"
3+
4+
type TDialogFooterProps = {
5+
className?: string;
6+
children: ReactNode
7+
}
8+
9+
export const DialogFooter = ({ className, children }: TDialogFooterProps) => {
10+
return (
11+
<Modal.Footer hideBorder className={className}>
12+
{children}
13+
</Modal.Footer>
14+
)
15+
}

lib/components/Dialog/DialogBody.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { ReactNode } from "react"
2+
import { Modal } from "../Modal"
3+
4+
type TDialogBodyProps = {
5+
children: ReactNode;
6+
className?: string;
7+
}
8+
9+
export const DialogBody = ({ children, className }: TDialogBodyProps) => {
10+
return (
11+
<Modal.Body className={className}>
12+
{children}
13+
</Modal.Body>
14+
)
15+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ReactNode } from "react"
2+
import { Modal } from "../Modal"
3+
import { Text } from "../Text"
4+
5+
type TDialogHeaderProps = {
6+
className?: string;
7+
hideCloseIcon?: boolean;
8+
title?: ReactNode;
9+
textClassName?: string
10+
}
11+
12+
export const DialogHeader = ({ className, hideCloseIcon = true, title, textClassName }: TDialogHeaderProps) => {
13+
return (
14+
<Modal.Header hideBorder hideCloseIcon={hideCloseIcon} className={className}>
15+
<Text as='div' weight='bold' className={textClassName}>
16+
{title}
17+
</Text>
18+
</Modal.Header>
19+
)
20+
}

lib/components/Dialog/index.tsx

+13-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
1-
import React, { ComponentProps, ReactNode } from "react"
1+
import React, { ReactNode } from "react"
22
import { Modal } from "../Modal"
3-
import { Text } from "../Text"
3+
import { DialogHeader } from "./DialogHeader"
4+
import { DialogBody } from "./DialogBody"
5+
import { DialogFooter } from "./DIalogFooter"
46
import "./Dialog.scss"
57

6-
type TDialogProps = ComponentProps<typeof Modal> & {
7-
body: ReactNode;
8+
type TDialogProps = {
9+
bodyChildren:ReactNode
810
header?: string;
9-
primaryButton: ReactNode;
10-
secondaryButton?: ReactNode;
11+
footerChildren:ReactNode;
12+
title?: ReactNode;
1113
}
1214

13-
export const Dialog = ({ body, header, primaryButton, secondaryButton,...rest }: TDialogProps) => {
15+
export const Dialog = ({ bodyChildren,footerChildren,header,title,...rest }: TDialogProps) => {
1416
return (
15-
<Modal className={"deriv-dialog"} ariaHideApp={false} {...rest}>
16-
<Modal.Header hideBorder={true} >
17-
<Text as='div' weight='bold' className='deriv-modal__header-title'>
18-
{header}
19-
</Text>
20-
</Modal.Header>
21-
<Modal.Body>
22-
{body}
23-
</Modal.Body>
24-
<Modal.Footer hideBorder={true}>
25-
{primaryButton}
26-
{secondaryButton}
27-
</Modal.Footer>
17+
<Modal className={"deriv-dialog"} ariaHideApp={false} isOpen {...rest}>
18+
<DialogHeader title={title} />
19+
<DialogBody children={bodyChildren}/>
20+
<DialogFooter children={footerChildren}/>
2821
</Modal>
2922
)
3023
}

0 commit comments

Comments
 (0)