11import classnames from 'classnames' ;
2+ import CustomPropTypes from '../utils/CustomPropTypes/CustomPropTypes' ;
23import FocusTrap from 'focus-trap-react' ;
34import PropTypes from 'prop-types' ;
45import ReactDOM from 'react-dom' ;
56import React , { Component } from 'react' ;
6-
77class Modal extends Component {
88 // select body element to add Modal component too
99 bodyElm = document . querySelector ( 'body' ) ;
@@ -30,7 +30,7 @@ class Modal extends Component {
3030 }
3131
3232 render ( ) {
33- const { children, title, actions, className, show, titleProps, closeProps, contentProps, headerProps, footerProps, bodyProps, ...rest } = this . props ;
33+ const { localizedText , children, title, actions, className, show, titleProps, closeProps, contentProps, headerProps, footerProps, bodyProps, ...rest } = this . props ;
3434
3535 const modalClasses = classnames (
3636 'fd-ui__overlay' ,
@@ -68,7 +68,7 @@ class Modal extends Component {
6868 </ h1 >
6969 < button
7070 { ...closeProps }
71- aria-label = 'close'
71+ aria-label = { localizedText . closeButton }
7272 className = 'fd-button--light fd-modal__close'
7373 onClick = { this . handleCloseClick } />
7474 </ div >
@@ -106,17 +106,29 @@ Modal.propTypes = {
106106 contentProps : PropTypes . object ,
107107 footerProps : PropTypes . object ,
108108 headerProps : PropTypes . object ,
109+ localizedText : CustomPropTypes . i18n ( {
110+ closeButton : PropTypes . string
111+ } ) ,
109112 show : PropTypes . bool ,
110113 titleProps : PropTypes . object
111114} ;
112115
116+ Modal . defaultProps = {
117+ localizedText : {
118+ closeButton : 'Close'
119+ }
120+ } ;
121+
113122Modal . propDescriptions = {
114123 actions : 'Node(s) to render within the footer of the dialog.' ,
115124 bodyProps : 'Additional props to be spread to the body section of the dialog.' ,
116125 closeProps : 'Additional props to be spread to the close `<button>` element.' ,
117126 contentProps : 'Additional props to be spread to the content section of the dialog.' ,
118127 footerProps : 'Additional props to be spread to the footer of the dialog.' ,
119128 headerProps : 'Additional props to be spread to the header of the dialog.' ,
129+ localizedText : {
130+ closeButton : 'Aria-label for <button> element.'
131+ } ,
120132 show : 'Set to **true** to make the dialog visible.'
121133} ;
122134
0 commit comments