@@ -15,6 +15,7 @@ import { IconButtonProps, IconButton } from '../button'
15
15
import styles from './modal.module.css'
16
16
import type { ObfuscatedClassName } from '../utils/common-types'
17
17
import { forwardRef } from 'react'
18
+ import type { DividerProps } from '../divider'
18
19
19
20
type ModalWidth = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'full'
20
21
type ModalHeightMode = 'expand' | 'fitContent'
@@ -26,11 +27,13 @@ type ModalHeightMode = 'expand' | 'fitContent'
26
27
type ModalContextValue = {
27
28
onDismiss ?( this : void ) : void
28
29
height : ModalHeightMode
30
+ dividers ?: DividerProps [ 'weight' ]
29
31
}
30
32
31
33
const ModalContext = React . createContext < ModalContextValue > ( {
32
34
onDismiss : undefined ,
33
35
height : 'fitContent' ,
36
+ dividers : undefined ,
34
37
} )
35
38
36
39
//
@@ -81,6 +84,11 @@ export interface ModalProps extends DivProps, ObfuscatedClassName {
81
84
*/
82
85
height ?: ModalHeightMode
83
86
87
+ /**
88
+ * The weight to apply to all dividers rendered inside the modal.
89
+ */
90
+ dividers ?: DividerProps [ 'weight' ]
91
+
84
92
/**
85
93
* Whether to set or not the focus initially to the first focusable element inside the modal.
86
94
*/
@@ -152,6 +160,7 @@ export function Modal({
152
160
isOpen,
153
161
onDismiss,
154
162
height = 'fitContent' ,
163
+ dividers,
155
164
width = 'medium' ,
156
165
exceptionallySetClassName,
157
166
exceptionallySetOverlayClassName,
@@ -175,9 +184,10 @@ export function Modal({
175
184
)
176
185
const store = useDialogStore ( { open : isOpen , setOpen } )
177
186
178
- const contextValue : ModalContextValue = React . useMemo ( ( ) => ( { onDismiss, height } ) , [
187
+ const contextValue : ModalContextValue = React . useMemo ( ( ) => ( { onDismiss, height, dividers } ) , [
179
188
onDismiss ,
180
189
height ,
190
+ dividers ,
181
191
] )
182
192
183
193
const portalRef = React . useRef < HTMLElement | null > ( null )
@@ -378,6 +388,8 @@ export function ModalHeader({
378
388
exceptionallySetClassName,
379
389
...props
380
390
} : ModalHeaderProps ) {
391
+ const { dividers } = React . useContext ( ModalContext )
392
+
381
393
return (
382
394
< >
383
395
< Box
@@ -407,7 +419,7 @@ export function ModalHeader({
407
419
) }
408
420
</ Columns >
409
421
</ Box >
410
- { withDivider ? < Divider /> : null }
422
+ { withDivider ? < Divider weight = { dividers } /> : null }
411
423
</ >
412
424
)
413
425
}
@@ -484,9 +496,11 @@ export function ModalFooter({
484
496
withDivider = false ,
485
497
...props
486
498
} : ModalFooterProps ) {
499
+ const { dividers } = React . useContext ( ModalContext )
500
+
487
501
return (
488
502
< >
489
- { withDivider ? < Divider /> : null }
503
+ { withDivider ? < Divider weight = { dividers } /> : null }
490
504
< Box as = "footer" { ...props } className = { exceptionallySetClassName } padding = "large" />
491
505
</ >
492
506
)
0 commit comments