File tree Expand file tree Collapse file tree 6 files changed +56
-30
lines changed
packages/react-core/src/components/Modal Expand file tree Collapse file tree 6 files changed +56
-30
lines changed Original file line number Diff line number Diff line change 1+ import * as React from 'react' ;
2+
3+ import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box' ;
4+ import { css } from '@patternfly/react-styles' ;
5+
6+ export interface ModalBoxHeaderProps {
7+ /** Content rendered inside the Header */
8+ children ?: React . ReactNode ;
9+ /** Additional classes added to the button */
10+ className ?: string ;
11+ }
12+
13+ export const ModalBoxHeader : React . FunctionComponent < ModalBoxHeaderProps > = ( {
14+ children = null ,
15+ className = '' ,
16+ ...props
17+ } : ModalBoxHeaderProps ) => (
18+ < div className = { css ( styles . modalBoxTitle , className ) } { ...props } >
19+ { children }
20+ </ div >
21+ ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import * as React from 'react';
22import { FocusTrap } from '../../helpers' ;
33import titleStyles from '@patternfly/react-styles/css/components/Title/title' ;
44import bullsEyeStyles from '@patternfly/react-styles/css/layouts/Bullseye/bullseye' ;
5- import styles from '@patternfly/react-styles/css/components/ModalBox/modal-box' ;
65import { css } from '@patternfly/react-styles' ;
76
87import { Backdrop } from '../Backdrop/Backdrop' ;
@@ -11,6 +10,7 @@ import { ModalBoxCloseButton } from './ModalBoxCloseButton';
1110import { ModalBox } from './ModalBox' ;
1211import { ModalBoxFooter } from './ModalBoxFooter' ;
1312import { ModalBoxDescription } from './ModalBoxDescription' ;
13+ import { ModalBoxHeader } from './ModalBoxHeader' ;
1414
1515export interface ModalContentProps {
1616 /** Content rendered inside the Modal. */
@@ -76,7 +76,7 @@ export const ModalContent: React.FunctionComponent<ModalContentProps> = ({
7676 const modalBoxHeader = header ? (
7777 < div className = { css ( titleStyles . title ) } > { header } </ div >
7878 ) : (
79- title && < div className = { css ( styles . modalBoxTitle ) } > { title } </ div >
79+ title && < ModalBoxHeader > { title } </ ModalBoxHeader >
8080 ) ;
8181
8282 const modalBoxFooter = footer ? (
Original file line number Diff line number Diff line change 1+ import * as React from 'react' ;
2+ import { shallow } from 'enzyme' ;
3+
4+ import { ModalBoxHeader } from '../ModalBoxHeader' ;
5+
6+ test ( 'ModalBoxHeader Test' , ( ) => {
7+ const view = shallow ( < ModalBoxHeader > This is a ModalBox header</ ModalBoxHeader > ) ;
8+ expect ( view ) . toMatchSnapshot ( ) ;
9+ } ) ;
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` ModalBoxHeader Test 1` ] = `
4+ <div
5+ className = " pf-c-modal-box__title"
6+ >
7+ This is a ModalBox header
8+ </div >
9+ ` ;
Original file line number Diff line number Diff line change @@ -23,11 +23,9 @@ exports[`Modal Content Test description 1`] = `
2323 <ModalBoxCloseButton
2424 onClose = { [Function ]}
2525 />
26- <div
27- className = " pf-c-modal-box__title"
28- >
26+ <ModalBoxHeader >
2927 Test Modal Content title
30- </div >
28+ </ModalBoxHeader >
3129 <ModalBoxDescription
3230 id = " id"
3331 >
@@ -64,11 +62,9 @@ exports[`Modal Content Test isOpen 1`] = `
6462 <ModalBoxCloseButton
6563 onClose = { [Function ]}
6664 />
67- <div
68- className = " pf-c-modal-box__title"
69- >
65+ <ModalBoxHeader >
7066 Test Modal Content title
71- </div >
67+ </ModalBoxHeader >
7268 <ModalBoxBody
7369 id = " id"
7470 >
@@ -102,11 +98,9 @@ exports[`Modal Content Test only body 1`] = `
10298 <ModalBoxCloseButton
10399 onClose = { [Function ]}
104100 />
105- <div
106- className = " pf-c-modal-box__title"
107- >
101+ <ModalBoxHeader >
108102 Test Modal Content title
109- </div >
103+ </ModalBoxHeader >
110104 <ModalBoxBody
111105 id = " id"
112106 >
@@ -140,11 +134,9 @@ exports[`Modal Content Test with footer 1`] = `
140134 <ModalBoxCloseButton
141135 onClose = { [Function ]}
142136 />
143- <div
144- className = " pf-c-modal-box__title"
145- >
137+ <ModalBoxHeader >
146138 Test Modal Content title
147- </div >
139+ </ModalBoxHeader >
148140 <ModalBoxBody
149141 id = " id"
150142 >
@@ -181,11 +173,9 @@ exports[`Modal Content Test with onclose 1`] = `
181173 <ModalBoxCloseButton
182174 onClose = { [Function ]}
183175 />
184- <div
185- className = " pf-c-modal-box__title"
186- >
176+ <ModalBoxHeader >
187177 Test Modal Content title
188- </div >
178+ </ModalBoxHeader >
189179 <ModalBoxBody
190180 id = " id"
191181 isLarge = { true }
@@ -223,11 +213,9 @@ exports[`Modal Content test without footer 1`] = `
223213 <ModalBoxCloseButton
224214 onClose = { [Function ]}
225215 />
226- <div
227- className = " pf-c-modal-box__title"
228- >
216+ <ModalBoxHeader >
229217 Test Modal Content title
230- </div >
218+ </ModalBoxHeader >
231219 <ModalBoxBody
232220 id = " id"
233221 >
@@ -261,11 +249,9 @@ exports[`Modal Test with custom footer 1`] = `
261249 <ModalBoxCloseButton
262250 onClose = { [Function ]}
263251 />
264- <div
265- className = " pf-c-modal-box__title"
266- >
252+ <ModalBoxHeader >
267253 Test Modal Custom Footer
268- </div >
254+ </ModalBoxHeader >
269255 <ModalBoxBody
270256 id = " id"
271257 isLarge = { true }
Original file line number Diff line number Diff line change @@ -2,5 +2,6 @@ export * from './Modal';
22export * from './ModalBox' ;
33export * from './ModalBoxBody' ;
44export * from './ModalBoxCloseButton' ;
5+ export * from './ModalBoxHeader' ;
56export * from './ModalBoxFooter' ;
67export * from './ModalContent' ;
You can’t perform that action at this time.
0 commit comments