Skip to content

Commit e671f78

Browse files
authored
fix: added localized text shape to Modal (#487)
* added localized text shape to modal * added description to modal
1 parent b28712e commit e671f78

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Modal/Modal.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import classnames from 'classnames';
2+
import CustomPropTypes from '../utils/CustomPropTypes/CustomPropTypes';
23
import FocusTrap from 'focus-trap-react';
34
import PropTypes from 'prop-types';
45
import ReactDOM from 'react-dom';
56
import React, { Component } from 'react';
6-
77
class 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+
113122
Modal.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

Comments
 (0)