Skip to content

Commit 9fb2520

Browse files
Revert "Merge pull request salesforce#1376 from kchan902/progress-indicator-assistive-text"
This reverts commit 473c75b, reversing changes made to 8fd3f2b. # Conflicts: # tests/__snapshots__/story-based-tests.snapshot-test.js.snap
1 parent 473059b commit 9fb2520

File tree

28 files changed

+44
-124
lines changed

28 files changed

+44
-124
lines changed

components/progress-indicator/__docs__/storybook-stories.jsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,10 @@ const ExampleProgressIndicator = createReactClass({
4343

4444
render () {
4545
return (
46-
<div style={{ padding: '4rem 1rem 0px' }}>
46+
<div style={{ padding: '2rem 1rem 0px' }}>
4747
<ProgressIndicator
48-
id="example-progress-indicator"
4948
steps={this.props.steps}
5049
selectedStep={this.props.selectedStep}
51-
disabledSteps={this.props.disabledSteps}
52-
completedSteps={this.props.completedSteps}
53-
assistiveText={this.props.assistiveText}
5450
onStepClick={(event, data) => {
5551
console.log(data);
5652
}}
@@ -85,25 +81,10 @@ storiesOf(PROGRESS_INDICATOR, module)
8581
))
8682
.add('Step Error', () => (
8783
<StepError
88-
id="example-progress-indicator"
8984
steps={steps}
9085
selectedStep={steps[1]}
9186
completedSteps={steps.slice(0, 1)}
9287
errorSteps={steps.slice(1, 2)}
9388
/>
9489
))
95-
.add(
96-
'In A Modal (With Step Error) - Needs DOM',
97-
() => (typeof document !== 'undefined' ? <Modal /> : null)
98-
)
99-
.add('Completed Progress', () => (
100-
<ExampleProgressIndicator
101-
steps={steps}
102-
selectedStep={steps[steps.length - 2]}
103-
completedSteps={steps.slice(0, steps.length - 2)}
104-
assistiveText={{
105-
completedStep: 'Finished this step.',
106-
disabledStep: 'Unable to proceed on this step.',
107-
}}
108-
/>
109-
));
90+
.add('In A Modal (With Step Error)', () => <Modal />);
Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import createReactClass from 'create-react-class';
23
import IconSettings from '~/components/icon-settings';
34
import ProgressIndicator from '~/components/progress-indicator'; // `~` is replaced with design-system-react at runtime
45

@@ -14,56 +15,33 @@ const steps = [
1415
{ id: 4, label: 'tooltip label #5' },
1516
];
1617

17-
/*
18-
* This example allows you to select the next step and only the next step. Typically, Progress Indicator should be paired with a modal and form errors should be explained outside of this component.
19-
*/
20-
class Example extends React.Component {
21-
constructor (props) {
22-
super(props);
23-
this.state = {
24-
steps,
25-
completedSteps: [],
26-
disabledSteps: steps.slice(2, steps.length),
27-
selectedStep: steps[0],
28-
};
29-
}
18+
const handleStepEvent = function (event, data) {
19+
console.log(data);
20+
};
3021

31-
handleStepEvent = (event, data) => {
32-
this.setState({
33-
completedSteps: steps.slice(0, data.step.id),
34-
disabledSteps:
35-
data.step.id < steps.length
36-
? steps.slice(data.step.id + 2, steps.length)
37-
: [],
38-
selectedStep: data.step,
39-
});
40-
};
22+
const Example = createReactClass({
23+
displayName: 'ProgressIndicatorDefault',
4124

4225
render () {
4326
return (
4427
<IconSettings iconPath="/assets/icons">
4528
<div
4629
style={{
47-
padding: '4rem 1rem 0px',
30+
padding: '2rem 1rem 0px',
4831
background:
49-
this.props.variant === 'modal' ? 'rgb(244, 246, 249)' : undefined,
32+
this.props.variant === 'modal' ? 'rgb(244, 246, 249)' : '',
5033
}}
5134
>
5235
<ProgressIndicator
53-
id="example-progress-indicator"
54-
completedSteps={this.state.completedSteps}
55-
disabledSteps={this.state.disabledSteps}
56-
onStepClick={this.handleStepEvent}
57-
steps={this.state.steps}
58-
selectedStep={this.state.selectedStep}
36+
steps={steps}
37+
selectedStep={steps[0]}
38+
onStepClick={handleStepEvent}
5939
// tooltipIsOpenSteps={stepsBasic.slice(0, 2)}
6040
/>
6141
</div>
6242
</IconSettings>
6343
);
64-
}
65-
}
66-
67-
Example.displayName = 'ProgressIndicatorDefault';
44+
},
45+
});
6846

6947
export default Example; // export is replaced with `ReactDOM.render(<Example />, mountNode);` at runtime

components/progress-indicator/__examples__/step-error.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const Example = createReactClass({
77

88
render () {
99
return (
10-
<div style={{ padding: '4rem 1rem 0px' }}>
10+
<div style={{ padding: '2rem 1rem 0px' }}>
1111
<ProgressIndicator {...this.props} />
1212
</div>
1313
);

components/progress-indicator/index.jsx

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import React from 'react';
77
import PropTypes from 'prop-types';
88

9+
import assign from 'lodash.assign';
10+
911
import find from 'lodash.find';
1012

1113
// ### shortid
@@ -24,17 +26,10 @@ const propTypes = {
2426
/**
2527
* **Assistive text for accessibility**
2628
* This object is merged with the default props object on every render.
27-
* * `completedStep`: Label for a completed step. The default is `Completed Step`
28-
* * `disabledStep`: Label for disabled step. The default is `Disabled Step`
29-
* * `errorStep`: Label for a step with an error. The default is `Error Step`
30-
* * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`. You will need to calculate the percentage yourself if changing this string.
31-
* * `step`: Label for a step. It will be typically followed by the number of the step such as "Step 1".
29+
* * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`
3230
*/
3331
assistiveText: PropTypes.shape({
34-
completedStep: PropTypes.string,
35-
disabledStep: PropTypes.string,
3632
percentage: PropTypes.string,
37-
step: PropTypes.string,
3833
}),
3934
/**
4035
* CSS class names to be added to the container element. `array`, `object`, or `string` are accepted.
@@ -54,7 +49,7 @@ const propTypes = {
5449
*/
5550
disabledSteps: PropTypes.array,
5651
/**
57-
* Stores all error steps. It is an array of step objects and usually there is only one error step, the current step. If an error occurs a second error icon should be placed to the left of related confirmation buttons (e.g. Cancel, Save) and an Error Popover should appear indicating there are errors. These additional items are NOT part of this component. This note was included for visibility purposes. Please refer to [SLDS website](https://www.lightningdesignsystem.com/components/progress-indicator/) for full details **
52+
* Stores all error steps. It is an array of step objects and usually there is only one error step, the current step.
5853
*/
5954
errorSteps: PropTypes.array,
6055
/**
@@ -111,12 +106,7 @@ const defaultSteps = [
111106
];
112107

113108
const defaultProps = {
114-
assistiveText: {
115-
completedStep: 'Completed',
116-
disabledStep: 'Disabled',
117-
errorStep: 'Error',
118-
step: 'Step',
119-
},
109+
assistiveText: {},
120110
errorSteps: [],
121111
completedSteps: [],
122112
disabledSteps: [],
@@ -175,17 +165,10 @@ class ProgressIndicator extends React.Component {
175165

176166
render () {
177167
// Merge objects of strings with their default object
178-
const assistiveText = {
179-
...defaultProps.assistiveText,
180-
...this.props.assistiveText,
181-
};
182-
183-
const {
184-
selectedStep,
185-
disabledSteps,
186-
errorSteps,
187-
completedSteps,
188-
} = this.props;
168+
const assistiveText = this.props
169+
? assign({}, defaultProps.assistiveText, this.props.assistiveText)
170+
: defaultProps.assistiveText;
171+
189172
/** 1. preparing data */
190173
const allSteps = this.getSteps();
191174

@@ -216,14 +199,13 @@ class ProgressIndicator extends React.Component {
216199
>
217200
{allSteps.map((step, i) => (
218201
<Step
219-
assistiveText={assistiveText}
220202
key={`${this.getId()}-${step.id}`}
221203
id={this.getId()}
222204
index={i}
223-
isSelected={findStep(step, selectedStep)}
224-
isDisabled={findStep(step, disabledSteps)}
225-
isError={findStep(step, errorSteps)}
226-
isCompleted={findStep(step, completedSteps)}
205+
isSelected={findStep(step, this.props.selectedStep)}
206+
isDisabled={findStep(step, this.props.disabledSteps)}
207+
isError={findStep(step, this.props.errorSteps)}
208+
isCompleted={findStep(step, this.props.completedSteps)}
227209
onClick={this.props.onStepClick}
228210
onFocus={this.props.onStepFocus}
229211
step={step}

components/progress-indicator/private/progress-bar.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ProgressBar extends React.Component {
2828
aria-valuemax="100"
2929
aria-valuenow={this.props.value}
3030
role="progressbar"
31+
tabIndex={0}
3132
>
3233
<span
3334
className="slds-progress-bar__value"

components/progress-indicator/private/step.jsx

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,6 @@ const displayName = PROGRESS_INDICATOR_STEP;
1919

2020
// ### Prop Types
2121
const propTypes = {
22-
/**
23-
* **Assistive text for accessibility**
24-
* This object is merged with the default props object on every render.
25-
* * `completedStep`: Label for a completed step. The default is `Completed Step`
26-
* * `disabledStep`: Label for disabled step. The default is `Disabled Step`
27-
* * `errorStep`: Label for a step with an error. The default is `Error Step`
28-
* * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`. You will need to calculate the percentage yourself if changing this string.
29-
* * `step`: Label for a step. It will be typically followed by the number of the step such as "Step 1".
30-
*/
31-
assistiveText: PropTypes.shape({
32-
completedStep: PropTypes.string,
33-
disabledStep: PropTypes.string,
34-
percentage: PropTypes.string,
35-
step: PropTypes.string,
36-
}),
3722
/**
3823
* Id for Steps, ranging in [0, steps.length).
3924
*/
@@ -45,7 +30,6 @@ const propTypes = {
4530
/**
4631
* Determines if the step has been completed
4732
*/
48-
4933
isCompleted: PropTypes.bool,
5034
/**
5135
* Determines if the step has been disabled
@@ -107,15 +91,15 @@ class Step extends React.Component {
10791
const icon = renderIcon ? (
10892
<ButtonIcon
10993
category="utility"
110-
name={this.props.isError ? 'error' : 'success'}
94+
name={this.props.isError ? 'warning' : 'success'}
11195
/>
11296
) : null;
11397

11498
const handleClick = (event) => props.onClick(event, data);
11599
const handleFocus = (event) => props.onFocus(event, data);
116100

117101
const stepButton = props.isDisabled ? (
118-
<a
102+
<span
119103
className={classNames(
120104
'slds-button',
121105
{ 'slds-button_icon': renderIcon },
@@ -129,12 +113,9 @@ class Step extends React.Component {
129113
>
130114
{icon}
131115
<span className="slds-assistive-text">
132-
{this.props.step.assistiveText ||
133-
`${props.assistiveText.step} ${props.index + 1}: ${
134-
props.step.label
135-
} - ${status}`}
116+
{props.step.assistiveText || `Step ${props.index + 1}: ${status}`}
136117
</span>
137-
</a>
118+
</span>
138119
) : (
139120
<button
140121
className={classNames(
@@ -147,14 +128,10 @@ class Step extends React.Component {
147128
onFocus={handleFocus}
148129
aria-describedby={`progress-indicator-tooltip-${this.props.step.id ||
149130
this.props.index}`}
150-
aria-current={this.props.isSelected ? 'step' : null}
151131
>
152132
{icon}
153133
<span className="slds-assistive-text">
154-
{this.props.step.assistiveText ||
155-
`${props.assistiveText.step} ${props.index + 1}: ${
156-
props.step.label
157-
}${status ? ` - ${status}` : ''}`}
134+
{props.step.assistiveText || `Step ${props.index + 1}: ${status}`}
158135
</span>
159136
</button>
160137
);
@@ -164,21 +141,22 @@ class Step extends React.Component {
164141

165142
render () {
166143
const renderIcon = this.props.isCompleted || this.props.isError;
144+
// step status (one of ['Error', 'Completed', 'Active', 'Uncompleted'])
167145
let status = '';
168146
if (this.props.isError) {
169-
status = this.props.assistiveText.errorStep;
147+
status = 'Error';
170148
} else if (this.props.isCompleted) {
171-
status = this.props.assistiveText.completedStep;
172-
} else if (this.props.isDisabled) {
173-
status = this.props.assistiveText.disabledStep;
174-
}
149+
status = 'Completed';
150+
} else if (this.props.isSelected) {
151+
status = 'Active';
152+
} else status = 'Uncompleted';
175153

176154
const tooltipProps = {
177155
align: 'top',
178156
id: `progress-indicator-tooltip-${this.props.step.id ||
179157
this.props.index}`,
180158
content: this.props.step.label,
181-
theme: 'info',
159+
theme: this.props.isError ? 'error' : 'info',
182160
triggerStyle: { display: !renderIcon ? 'flex' : '' },
183161
};
184162

components/story-based-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export Tree from '../components/tree/__docs__/storybook-stories';
6464
// export Notification from '../components/notification/__docs__/storybook-stories';
6565
// export Panel from '../components/panel/__docs__/storybook-stories';
6666
// export Popover from '../components/popover/__docs__/storybook-stories';
67-
export ProgressIndicator from '../components/progress-indicator/__docs__/storybook-stories';
67+
// export ProgressIndicator from '../components/progress-indicator/__docs__/storybook-stories';
6868
// export Picklist from '../components/menu-picklist/__docs__/storybook-stories';
6969
// export Spinner from '../components/spinner/__docs__/storybook-stories';
7070
// export TimePicker from '../components/time-picker/__docs__/storybook-stories';

tests/story-based-tests.snapshot-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import path from 'path';
1616
// be run first.
1717
const rootPath = path.resolve(__dirname, '../');
1818
const app = express();
19-
const port = process.env.PORT || 8002;
19+
const port = process.env.PORT || 9001;
2020

2121
// Register static asset folders
2222
app.use(

0 commit comments

Comments
 (0)