@@ -25,7 +25,7 @@ export class ModalComponent extends Component {
2525 this . txtEmailRef = React . createRef ( ) ;
2626 }
2727
28- informationModalCode = `<Modal title="Product Added" onClose={this.showHideModal}>
28+ informationModalCode = `<Modal show={this.state.bShowInfoModal} title="Product Added" onClose={this.showHideModal}>
2929 <div>
3030 <b>The new product have been added to your catalog.</b>
3131 <br />
@@ -39,7 +39,7 @@ export class ModalComponent extends Component {
3939 </div>
4040</Modal>` ;
4141
42- confirmationModalCode = `<Modal title="Delete"
42+ confirmationModalCode = `<Modal show={this.state.bShowComfirmModal} title="Delete"
4343 onClose={this.showHideConfirmModal}
4444 actions={
4545 <React.Fragment>
@@ -59,7 +59,7 @@ export class ModalComponent extends Component {
5959 </div>
6060</Modal>` ;
6161
62- formModalCode = `<Modal title="Invite user"
62+ formModalCode = `<Modal show={this.state.bShowFormModal} title="Invite user"
6363 onClose={this.showHideFormModal}
6464 actions={
6565 <React.Fragment>
@@ -154,6 +154,10 @@ export class ModalComponent extends Component {
154154 The modal is a container generally displayed in response to an action.
155155 It is used for short forms, confirmation messages or to display
156156 contextual information that does not require a page.
157+ < br />
158+ To display the Modal control, pass a boolean value to the "show"
159+ property of the component. It is recommended to store this value as a
160+ state property in the Parent control.
157161 </ Description >
158162 < Import module = "Modal" path = "/fundamental-react/src/" />
159163
@@ -162,6 +166,10 @@ export class ModalComponent extends Component {
162166 < Properties
163167 type = "Inputs"
164168 properties = { [
169+ {
170+ name : 'show' ,
171+ description : 'Bool - true: show modal, false: hide modal.'
172+ } ,
165173 {
166174 name : 'title' ,
167175 description : 'String (required) - Title for modal dialog box'
@@ -183,23 +191,23 @@ export class ModalComponent extends Component {
183191 </ Description >
184192 < DocsTile >
185193 < button onClick = { this . showHideModal } > Show Information Modal</ button >
186- { this . state . bShowInfoModal ? (
187- < Modal title = "Product Added" onClose = { this . showHideModal } >
188- < div >
189- < b > The new product have been added to your catalog. </ b >
190- < br / >
191- < br / >
192- Automatic Product ID: < b > PD-3465334 </ b >
193- < br />
194- < br />
195- Expiration date : < b > 13/03/2018 </ b >
196- < br />
197- < br />
198- </ div >
199- </ Modal >
200- ) : (
201- ''
202- ) }
194+ < Modal
195+ show = { this . state . bShowInfoModal }
196+ title = "Product Added"
197+ onClose = { this . showHideModal }
198+ >
199+ < div >
200+ < b > The new product have been added to your catalog. </ b >
201+ < br />
202+ < br />
203+ Automatic Product ID : < b > PD-3465334 </ b >
204+ < br />
205+ < br />
206+ Expiration date: < b > 13/03/2018 </ b >
207+ < br / >
208+ < br />
209+ </ div >
210+ </ Modal >
203211 </ DocsTile >
204212 < DocsText > { this . informationModalCode } </ DocsText >
205213 < Separator />
@@ -214,31 +222,28 @@ export class ModalComponent extends Component {
214222 < button onClick = { this . showHideConfirmModal } >
215223 Show Confirmation Modal
216224 </ button >
217- { this . state . bShowComfirmModal ? (
218- < Modal
219- title = "Delete"
220- onClose = { this . showHideConfirmModal }
221- actions = {
222- < React . Fragment >
223- < Button
224- type = "secondary"
225- onclick = { ( ) => this . showHideConfirmModal ( 'No Way' ) }
226- >
227- No Way
228- </ Button >
229- < Button onclick = { ( ) => this . showHideConfirmModal ( 'Sure' ) } >
230- Sure
231- </ Button >
232- </ React . Fragment >
233- }
234- >
235- < div >
236- Do you want to delete item < b > X</ b > ?
237- </ div >
238- </ Modal >
239- ) : (
240- ''
241- ) }
225+ < Modal
226+ show = { this . state . bShowComfirmModal }
227+ title = "Delete"
228+ onClose = { this . showHideConfirmModal }
229+ actions = {
230+ < React . Fragment >
231+ < Button
232+ type = "secondary"
233+ onclick = { ( ) => this . showHideConfirmModal ( 'No Way' ) }
234+ >
235+ No Way
236+ </ Button >
237+ < Button onclick = { ( ) => this . showHideConfirmModal ( 'Sure' ) } >
238+ Sure
239+ </ Button >
240+ </ React . Fragment >
241+ }
242+ >
243+ < div >
244+ Do you want to delete item < b > X</ b > ?
245+ </ div >
246+ </ Modal >
242247 </ DocsTile >
243248 < DocsText > { this . confirmationModalCode } </ DocsText >
244249 < Separator />
@@ -250,40 +255,37 @@ export class ModalComponent extends Component {
250255 </ Description >
251256 < DocsTile >
252257 < button onClick = { this . showHideFormModal } > Show Form Modal</ button >
253- { this . state . bShowFormModal ? (
254- < Modal
255- title = "Invite user"
256- onClose = { this . showHideFormModal }
257- actions = {
258- < React . Fragment >
259- < Button
260- type = "secondary"
261- onclick = { ( ) => this . showHideFormModal ( 'Cancel' ) }
262- >
263- Cancel
264- </ Button >
265- < Button onclick = { ( ) => this . showHideFormModal ( 'Invite' ) } >
266- Invite
267- </ Button >
268- </ React . Fragment >
269- }
270- >
271- < div className = "fd-form__group" >
272- < div className = "fd-form__item" >
273- < label className = "fd-form__label is-required" > Email</ label >
274- < input
275- className = "fd-form__control"
276- type = "text"
277- value = { this . state . emailAddress }
278- onChange = { this . updateEmailAddress }
279- ref = { this . txtEmailRef }
280- />
281- </ div >
258+ < Modal
259+ show = { this . state . bShowFormModal }
260+ title = "Invite user"
261+ onClose = { this . showHideFormModal }
262+ actions = {
263+ < React . Fragment >
264+ < Button
265+ type = "secondary"
266+ onclick = { ( ) => this . showHideFormModal ( 'Cancel' ) }
267+ >
268+ Cancel
269+ </ Button >
270+ < Button onclick = { ( ) => this . showHideFormModal ( 'Invite' ) } >
271+ Invite
272+ </ Button >
273+ </ React . Fragment >
274+ }
275+ >
276+ < div className = "fd-form__group" >
277+ < div className = "fd-form__item" >
278+ < label className = "fd-form__label is-required" > Email</ label >
279+ < input
280+ className = "fd-form__control"
281+ type = "text"
282+ value = { this . state . emailAddress }
283+ onChange = { this . updateEmailAddress }
284+ ref = { this . txtEmailRef }
285+ />
282286 </ div >
283- </ Modal >
284- ) : (
285- ''
286- ) }
287+ </ div >
288+ </ Modal >
287289 </ DocsTile >
288290 < DocsText > { this . formModalCode } </ DocsText >
289291 < Separator />
0 commit comments