Skip to content

Commit 1f6bf1c

Browse files
Progress Indicator: Use assistiveText prop keys
instead of hard coded text strings This also makes all tooltips info tooltips and removes use of error tooltips.
1 parent 93ee8bf commit 1f6bf1c

File tree

1 file changed

+26
-22
lines changed
  • components/progress-indicator/private

1 file changed

+26
-22
lines changed

components/progress-indicator/private/step.jsx

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@ const displayName = PROGRESS_INDICATOR_STEP;
1919

2020
// ### Prop Types
2121
const propTypes = {
22-
/*
23-
* assistiveText propTypes
24-
*/
22+
/**
23+
* **Assistive text for accessibility**
24+
* This object is merged with the default props object on every render.
25+
* * `activeStep`: Label for the active step. The default is `Active Step`
26+
* * `completedStep`: Label for a completed step. The default is `Completed Step`
27+
* * `disabledStep`: Label for disabled step. The default is `Disabled Step`
28+
* * `errorStep`: Label for a step with an error. The default is `Error Step`
29+
* * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`. You will need to calculate the percentage yourself if changing this string.
30+
* * `step`: Label for a step. It will be typically followed by the number of the step such as "Step 1".
31+
*/
2532
assistiveText: PropTypes.shape({
26-
// percentage: PropTypes.string,
33+
activeStep: PropTypes.string,
2734
completedStep: PropTypes.string,
28-
disabledStep: PropTypes.string
35+
disabledStep: PropTypes.string,
36+
percentage: PropTypes.string,
37+
step: PropTypes.string,
2938
}),
3039
/**
3140
* Id for Steps, ranging in [0, steps.length).
@@ -100,7 +109,7 @@ class Step extends React.Component {
100109
const icon = renderIcon ? (
101110
<ButtonIcon
102111
category="utility"
103-
name={this.props.isError ? 'warning' : 'success'}
112+
name={this.props.isError ? 'error' : 'success'}
104113
/>
105114
) : null;
106115

@@ -122,7 +131,7 @@ class Step extends React.Component {
122131
>
123132
{icon}
124133
<span className="slds-assistive-text">
125-
{this.props.assistiveText.disabledStep}
134+
{this.props.step.assistiveText || `${props.assistiveText.step} ${props.index + 1}: ${status}`}
126135
</span>
127136
</span>
128137
) : (
@@ -137,17 +146,11 @@ class Step extends React.Component {
137146
onFocus={handleFocus}
138147
aria-describedby={`progress-indicator-tooltip-${this.props.step.id ||
139148
this.props.index}`}
140-
aria-current={this.props.isSelected ? 'step' : ''}
149+
aria-current={this.props.isSelected ? 'step' : null}
141150
>
142151
{icon}
143152
<span className="slds-assistive-text">
144-
{(() => {
145-
if (props.isCompleted) {
146-
return this.props.assistiveText.completedStep;
147-
} else {
148-
return `Step ${props.index + 1}: ${status}`;
149-
}
150-
})()}
153+
{this.props.step.assistiveText || `${props.assistiveText.step} ${props.index + 1}: ${status}`}
151154
</span>
152155
</button>
153156
);
@@ -157,22 +160,23 @@ class Step extends React.Component {
157160

158161
render () {
159162
const renderIcon = this.props.isCompleted || this.props.isError;
160-
// step status (one of ['Error', 'Completed', 'Active', 'Uncompleted'])
161163
let status = '';
162164
if (this.props.isError) {
163-
status = 'Error';
164-
} else if (this.props.isCompleted) {
165-
status = 'Completed';
165+
status = this.props.assistiveText.errorStep;
166166
} else if (this.props.isSelected) {
167-
status = 'Active';
168-
} else status = 'Uncompleted';
167+
status = this.props.assistiveText.activeStep;
168+
} else if (this.props.isCompleted) {
169+
status = this.props.assistiveText.completedStep;
170+
} else if (this.props.isDisabled) {
171+
status = this.props.assistiveText.disabledStep;
172+
}
169173

170174
const tooltipProps = {
171175
align: 'top',
172176
id: `progress-indicator-tooltip-${this.props.step.id ||
173177
this.props.index}`,
174178
content: this.props.step.label,
175-
theme: this.props.isError ? 'error' : 'info',
179+
theme: 'info',
176180
triggerStyle: { display: !renderIcon ? 'flex' : '' },
177181
};
178182

0 commit comments

Comments
 (0)