Skip to content

Commit 243a28d

Browse files
feat: added modal props
1 parent dc3300e commit 243a28d

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

src/components/Dialog/Dialog.scss

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.deriv-dialog{
22
min-width:440px;
33
height:auto;
4+
padding: 10px;
45
}

src/components/Dialog/DialogBody.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import { Modal } from "../Modal"
33

4-
export const DialogBody = ({ children, className,...rest }: React.ComponentProps<"div">) => {
4+
export const DialogBody = ({ children, className,...rest }: React.ComponentProps<typeof Modal.Body>) => {
55
return (
66
<Modal.Body className={className} {...rest}>
77
{children}

src/components/Dialog/DialogFooter.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import { Modal } from "../Modal"
33

4-
export const DialogFooter = ({ className, children,...rest }: React.ComponentProps<"div">) => {
4+
export const DialogFooter = ({ className, children,...rest }: React.ComponentProps<typeof Modal.Footer>) => {
55
return (
66
<Modal.Footer hideBorder className={className} {...rest}>
77
{children}

src/components/Dialog/DialogHeader.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import React,{ ReactNode } from "react"
22
import { Modal } from "../Modal"
33
import { Text } from "../Text"
44

5-
type TDialogHeaderProps = React.ComponentProps<"div"> & {
5+
type ExcludedProps ={
6+
hideBorder:boolean
7+
}
8+
9+
type TDialogHeaderProps = Exclude<React.ComponentProps<typeof Modal.Header>,ExcludedProps> & {
610
hideCloseIcon?: boolean;
711
title?: ReactNode;
812
textClassName?: string

src/components/Dialog/__test__/Dialog.spec.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { DialogHeader } from "../DialogHeader";
77
describe("Dialog component", () => {
88
it("should render the basic dialog without header, footer and body", () => {
99
render(
10-
<Dialog>
10+
<Dialog isOpen={true}>
1111
<p>This is some dialog content</p>
1212
</Dialog>,
1313
);
@@ -19,7 +19,7 @@ describe("Dialog component", () => {
1919

2020
it("should render dialog header", () => {
2121
render(
22-
<Dialog>
22+
<Dialog isOpen={true}>
2323
<Dialog.Header hideCloseIcon={false} title={"Dialog Title"} />
2424
</Dialog>,
2525
);
@@ -33,7 +33,7 @@ describe("Dialog component", () => {
3333

3434
it("should render the dialog header without close icon ", () => {
3535
render(
36-
<Dialog>
36+
<Dialog isOpen={true}>
3737
<Dialog.Header hideCloseIcon={true} title={"Dialog Title"} />
3838
</Dialog>,
3939
);
@@ -48,7 +48,7 @@ describe("Dialog component", () => {
4848

4949
it("should render dialog Footer", () => {
5050
render(
51-
<Dialog>
51+
<Dialog isOpen={true}>
5252
<Dialog.Footer>Dialog Footer</Dialog.Footer>
5353
</Dialog>,
5454
);
@@ -60,7 +60,7 @@ it("should render dialog Footer", () => {
6060

6161
it("should close the modal when the close button in header is clicked", async () => {
6262
render(
63-
<Dialog>
63+
<Dialog isOpen={true}>
6464
<DialogHeader title={" Modal Title"} hideCloseIcon={false}></DialogHeader>
6565
<Dialog.Body>
6666
<p>This is some dialog content</p>

src/components/Dialog/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { DialogBody } from "./DialogBody"
55
import { DialogFooter } from "./DialogFooter"
66
import "./Dialog.scss"
77

8-
type TDialogProps = {
8+
type TDialogProps = React.ComponentProps<typeof Modal> &{
99
children: ReactNode
1010
}
1111

12-
export const Dialog = ({ children }: TDialogProps) => {
12+
export const Dialog = ({ children,...rest }: TDialogProps) => {
1313
return (
14-
<Modal className={"deriv-dialog"} isOpen={true} ariaHideApp={false} >
14+
<Modal className={"deriv-dialog"} {...rest}>
1515
{children}
1616
</Modal>
1717
)

stories/Dialog.stories.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const meta = {
1212
tags: ["autodocs"],
1313
args: {
1414
children: <p>This is basic dialog</p>,
15+
isOpen:true
1516
},
1617
argTypes: {
1718
children: {
@@ -29,7 +30,7 @@ export const Default: Story = {
2930
render : ()=>{
3031
return (
3132
<>
32-
<Dialog>
33+
<Dialog isOpen={true}>
3334
<Dialog.Header>title</Dialog.Header>
3435
<Dialog.Body>body</Dialog.Body>
3536
<Dialog.Footer>
@@ -47,7 +48,7 @@ export const HideHeaderCloseIcon: Story = {
4748
render : ()=>{
4849
return (
4950
<>
50-
<Dialog>
51+
<Dialog isOpen={true}>
5152
<Dialog.Header hideCloseIcon >title</Dialog.Header>
5253
<Dialog.Body>body</Dialog.Body>
5354
<Dialog.Footer>
@@ -65,7 +66,7 @@ export const NoHeader: Story = {
6566
render : ()=>{
6667
return (
6768
<>
68-
<Dialog>
69+
<Dialog isOpen={true}>
6970
<Dialog.Body>body</Dialog.Body>
7071
<Dialog.Footer>
7172
<Button color="black">cancel</Button>
@@ -82,7 +83,7 @@ export const NoFooter: Story = {
8283
render : ()=>{
8384
return (
8485
<>
85-
<Dialog>
86+
<Dialog isOpen={true}>
8687
<Dialog.Header>title</Dialog.Header>
8788
<Dialog.Body>body</Dialog.Body>
8889
</Dialog>

0 commit comments

Comments
 (0)