File tree Expand file tree Collapse file tree 3 files changed +27
-9
lines changed
packages/react-core/src/components/Modal Expand file tree Collapse file tree 3 files changed +27
-9
lines changed Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import { css } from '@patternfly/react-styles' ;
3
+ import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box' ;
4
+
5
+ export interface ModalBoxDescriptionProps {
6
+ /** Content rendered inside the description */
7
+ children ?: React . ReactNode ;
8
+ /** Additional classes added to the description */
9
+ className ?: string ;
10
+ /** ID of the description */
11
+ id ?: string ;
12
+ }
13
+
14
+ export const ModalBoxDescription : React . FunctionComponent < ModalBoxDescriptionProps > = ( {
15
+ children = null ,
16
+ className = '' ,
17
+ id = '' ,
18
+ ...props
19
+ } : ModalBoxDescriptionProps ) => (
20
+ < div { ...props } id = { id } className = { css ( styles . modalBoxDescription , className ) } >
21
+ { children }
22
+ </ div >
23
+ ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ const FocusTrap: any = require('focus-trap-react');
7
7
8
8
import styles from '@patternfly/react-styles/css/layouts/Bullseye/bullseye' ;
9
9
import titleStyles from '@patternfly/react-styles/css/components/Title/title' ;
10
- import modalStyles from '@patternfly/react-styles/css/components/ModalBox/modal-box' ;
11
10
import { css } from '@patternfly/react-styles' ;
12
11
13
12
import { Backdrop } from '../Backdrop/Backdrop' ;
@@ -16,6 +15,7 @@ import { ModalBoxHeader } from './ModalBoxHeader';
16
15
import { ModalBoxCloseButton } from './ModalBoxCloseButton' ;
17
16
import { ModalBox } from './ModalBox' ;
18
17
import { ModalBoxFooter } from './ModalBoxFooter' ;
18
+ import { ModalBoxDescription } from './ModalBoxDescription' ;
19
19
20
20
export interface ModalContentProps {
21
21
/** Content rendered inside the Modal. */
@@ -104,11 +104,7 @@ export const ModalContent: React.FunctionComponent<ModalContentProps> = ({
104
104
>
105
105
{ showClose && < ModalBoxCloseButton onClose = { onClose } /> }
106
106
{ modalBoxHeader }
107
- { description && (
108
- < div className = { css ( modalStyles . modalBoxDescription ) } id = { id } >
109
- { description }
110
- </ div >
111
- ) }
107
+ { description && < ModalBoxDescription id = { id } > { description } </ ModalBoxDescription > }
112
108
< ModalBoxBody { ...props } { ...( ! description && { id } ) } >
113
109
{ children }
114
110
</ ModalBoxBody >
Original file line number Diff line number Diff line change @@ -32,12 +32,11 @@ exports[`Modal Content Test description 1`] = `
32
32
Test Modal Content title
33
33
34
34
</ModalBoxHeader >
35
- <div
36
- className = " pf-c-modal-box__description"
35
+ <ModalBoxDescription
37
36
id = " id"
38
37
>
39
38
This is a test description.
40
- </div >
39
+ </ModalBoxDescription >
41
40
<ModalBoxBody >
42
41
This is a ModalBox header
43
42
</ModalBoxBody >
You can’t perform that action at this time.
0 commit comments