1- import React , { ReactElement , ReactNode , useContext } from 'react' ;
1+ import React , { ReactElement , ReactNode , useContext , MouseEvent } from 'react' ;
22import { createPortal } from 'react-dom' ;
33
44import './index.scss' ;
@@ -15,12 +15,27 @@ import Label, { LabelTypography, LabelColors } from '../Label';
1515
1616export interface ModalHeaderProps {
1717 titleText : string ;
18+ onCloseClick ?: ( e : MouseEvent < HTMLButtonElement > ) => void ;
1819}
19- export const ModalHeader = ( { titleText } : ModalHeaderProps ) : ReactElement => (
20+ export const ModalHeader = ( { titleText, onCloseClick } : ModalHeaderProps ) : ReactElement => (
2021 < div className = "sendbird-modal__header" >
2122 < Label type = { LabelTypography . H_1 } color = { LabelColors . ONBACKGROUND_1 } >
2223 { titleText }
2324 </ Label >
25+ < div className = "sendbird-modal__close" >
26+ < IconButton
27+ width = "32px"
28+ height = "32px"
29+ onClick = { onCloseClick }
30+ >
31+ < Icon
32+ type = { IconTypes . CLOSE }
33+ fillColor = { IconColors . DEFAULT }
34+ width = "24px"
35+ height = "24px"
36+ />
37+ </ IconButton >
38+ </ div >
2439 </ div >
2540) ;
2641
@@ -127,7 +142,7 @@ export function Modal(props: ModalProps): ReactElement {
127142 ] . join ( ' ' ) }
128143 >
129144 { renderHeader ?.( ) || (
130- < ModalHeader titleText = { titleText ?? '' } />
145+ < ModalHeader titleText = { titleText ?? '' } onCloseClick = { handleClose } />
131146 ) }
132147 < ModalBody > { children } </ ModalBody >
133148 {
@@ -141,24 +156,6 @@ export function Modal(props: ModalProps): ReactElement {
141156 />
142157 ) )
143158 }
144- {
145- ! isMobile && (
146- < div className = "sendbird-modal__close" >
147- < IconButton
148- width = "32px"
149- height = "32px"
150- onClick = { handleClose }
151- >
152- < Icon
153- type = { IconTypes . CLOSE }
154- fillColor = { IconColors . DEFAULT }
155- width = "24px"
156- height = "24px"
157- />
158- </ IconButton >
159- </ div >
160- )
161- }
162159 </ div >
163160 < div
164161 className = { `
0 commit comments