Skip to content

Commit b28712e

Browse files
authored
fix: added localized text shape to input group (#486)
* added localized text shape to input group * descriptions added to input group
1 parent c107a11 commit b28712e

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/InputGroup/InputGroup.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import classnames from 'classnames';
2+
import CustomPropTypes from '../utils/CustomPropTypes/CustomPropTypes';
23
import PropTypes from 'prop-types';
34
import { INPUT_GROUP_ADDON_POSITIONS, INPUT_GROUP_TYPES } from '../utils/constants';
45
import React, { Component } from 'react';
@@ -64,6 +65,7 @@ class InputGroup extends Component {
6465
inputPlaceholder,
6566
inputProps,
6667
inputValue,
68+
localizedText,
6769
numberDownButtonProps,
6870
numberUpButtonProps,
6971
searchButtonProps,
@@ -102,12 +104,12 @@ class InputGroup extends Component {
102104
<span className='fd-input-group__addon fd-input-group__addon--button fd-input-group__addon--after'>
103105
<button
104106
{...numberUpButtonProps}
105-
aria-label='Step up'
107+
aria-label={localizedText.up}
106108
className='fd-input-group__button fd-input-group__button--step-up sap-icon--slim-arrow-up'
107109
onClick={this.handleUp} />
108110
<button
109111
{...numberDownButtonProps}
110-
aria-label='Step down'
112+
aria-label={localizedText.down}
111113
className='fd-input-group__button fd-input-group__button--step-down sap-icon--slim-arrow-down'
112114
onClick={this.handleDown} />
113115
</span>
@@ -145,7 +147,7 @@ class InputGroup extends Component {
145147
<span className='fd-input-group__addon fd-input-group__addon--button'>
146148
<button
147149
{...searchButtonProps}
148-
aria-label='Clear'
150+
aria-label={localizedText.clear}
149151
className='fd-input-group__button fd-input-group__button--clear'
150152
onClick={this.handleClear} />
151153
</span>
@@ -268,6 +270,11 @@ InputGroup.propTypes = {
268270
inputProps: PropTypes.object,
269271
inputType: PropTypes.oneOf(INPUT_GROUP_TYPES),
270272
inputValue: PropTypes.any,
273+
localizedText: CustomPropTypes.i18n({
274+
clear: PropTypes.string,
275+
down: PropTypes.string,
276+
up: PropTypes.string
277+
}),
271278
numberDownButtonProps: PropTypes.object,
272279
numberUpButtonProps: PropTypes.object,
273280
searchButtonProps: PropTypes.object
@@ -276,7 +283,12 @@ InputGroup.propTypes = {
276283
InputGroup.defaultProps = {
277284
addonPos: 'after',
278285
inputType: 'text',
279-
inputValue: ''
286+
inputValue: '',
287+
localizedText: {
288+
clear: 'Clear',
289+
down: 'Step down',
290+
up: 'Step up'
291+
}
280292
};
281293

282294
InputGroup.propDescriptions = {
@@ -289,6 +301,11 @@ InputGroup.propDescriptions = {
289301
inputPlaceholder: 'Value for the `placeholder` attribute on the `<input>` element.',
290302
inputType: 'Value for the `type` attribute on the `<input>` element.',
291303
inputValue: 'Value for the `value` attribute on the `<input>` element.',
304+
localizedText: {
305+
clear: 'Value for aria-label on the clear <button> element.',
306+
down: 'Value for aria-label on the down <button> element.',
307+
up: 'Value for aria-label on the up <button> element.'
308+
},
292309
numberDownButtonProps: 'Additional props to be spread to the down `<button>` element (for inputType=\'number\').',
293310
numberUpButtonProps: 'Additional props to be spread to the up `<button>` element (for inputType=\'number\').',
294311
searchButtonProps: 'Additional props to be spread to the `<button>` element.'

0 commit comments

Comments
 (0)