Skip to content

Fixed problem with progress indicator/assistive-text #1376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
316c099
Fixed problem with progress indicator stories not having disabled and…
kchan902 May 13, 2018
a0140fb
Merge branch 'master' of github.com:salesforce/design-system-react in…
interactivellama May 15, 2018
615bc96
made changes to allow internationalization
kchan902 Jun 9, 2018
5d89951
Merge branch 'progress-indicator-assistive-text' of github.com:kchan9…
interactivellama Jun 26, 2018
93ee8bf
Merge branch 'master' of github.com:salesforce/design-system-react in…
interactivellama Jun 27, 2018
1f6bf1c
Progress Indicator: Use assistiveText prop keys
interactivellama Jun 27, 2018
0eb641f
Progress Indicator: Add assistive text options
interactivellama Jun 27, 2018
5d95b11
Progress Indicator: Add working example
interactivellama Jun 27, 2018
bd30c03
Progress Indicator: Add working example
interactivellama Jun 27, 2018
e1ce6f3
Progress Indicator: Add snapshot tests
interactivellama Jun 27, 2018
64123b0
Move storyshot port
interactivellama Jun 27, 2018
f61bf25
Merge branch 'progress-indicator-assistive-text' of github.com:kchan9…
interactivellama Jun 27, 2018
b2912ec
Merge branch 'progress-indicator-assistive-text' of github.com:kchan9…
interactivellama Jun 27, 2018
90be165
Merge branch 'progress-indicator-assistive-text' of github.com:kchan9…
interactivellama Jun 27, 2018
460cf8c
Progress Indicator: Add additional UX pattern notes
interactivellama Jul 5, 2018
1f0344a
Add padding to storybook stories
interactivellama Jul 5, 2018
63c4499
added changes based on adam's comments
kchan902 Jul 18, 2018
2edf6f6
remove activestep from component
kchan902 Jul 19, 2018
a9671ee
fixed 2 of the cosmetic things
kchan902 Jul 25, 2018
f6d1943
Merge branch 'master' of github.com:salesforce/design-system-react in…
interactivellama Jul 25, 2018
f88853b
Update illustration image snapshots
interactivellama Jul 26, 2018
8d63d17
Progress Indicator: Update assistiveText
interactivellama Jul 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions components/progress-indicator/__docs__/storybook-stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ const ExampleProgressIndicator = createReactClass({

render () {
return (
<div style={{ padding: '2rem 1rem 0px' }}>
<div style={{ padding: '4rem 1rem 0px' }}>
<ProgressIndicator
id="example-progress-indicator"
steps={this.props.steps}
selectedStep={this.props.selectedStep}
disabledSteps={this.props.disabledSteps}
completedSteps={this.props.completedSteps}
assistiveText={this.props.assistiveText}
onStepClick={(event, data) => {
console.log(data);
}}
Expand Down Expand Up @@ -81,10 +85,25 @@ storiesOf(PROGRESS_INDICATOR, module)
))
.add('Step Error', () => (
<StepError
id="example-progress-indicator"
steps={steps}
selectedStep={steps[1]}
completedSteps={steps.slice(0, 1)}
errorSteps={steps.slice(1, 2)}
/>
))
.add('In A Modal (With Step Error)', () => <Modal />);
.add(
'In A Modal (With Step Error) - Needs DOM',
() => (typeof document !== 'undefined' ? <Modal /> : null)
)
.add('Completed Progress', () => (
<ExampleProgressIndicator
steps={steps}
selectedStep={steps[steps.length - 2]}
completedSteps={steps.slice(0, steps.length - 2)}
assistiveText={{
completedStep: 'Finished this step.',
disabledStep: 'Unable to proceed on this step.',
}}
/>
));
48 changes: 35 additions & 13 deletions components/progress-indicator/__examples__/default.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import createReactClass from 'create-react-class';
import IconSettings from '~/components/icon-settings';
import ProgressIndicator from '~/components/progress-indicator'; // `~` is replaced with design-system-react at runtime

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

const handleStepEvent = function (event, data) {
console.log(data);
};
/*
* 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.
*/
class Example extends React.Component {
constructor (props) {
super(props);
this.state = {
steps,
completedSteps: [],
disabledSteps: steps.slice(2, steps.length),
selectedStep: steps[0],
};
}

const Example = createReactClass({
displayName: 'ProgressIndicatorDefault',
handleStepEvent = (event, data) => {
this.setState({
completedSteps: steps.slice(0, data.step.id),
disabledSteps:
data.step.id < steps.length
? steps.slice(data.step.id + 2, steps.length)
: [],
selectedStep: data.step,
});
};

render () {
return (
<IconSettings iconPath="/assets/icons">
<div
style={{
padding: '2rem 1rem 0px',
padding: '4rem 1rem 0px',
background:
this.props.variant === 'modal' ? 'rgb(244, 246, 249)' : '',
this.props.variant === 'modal' ? 'rgb(244, 246, 249)' : undefined,
}}
>
<ProgressIndicator
steps={steps}
selectedStep={steps[0]}
onStepClick={handleStepEvent}
id="example-progress-indicator"
completedSteps={this.state.completedSteps}
disabledSteps={this.state.disabledSteps}
onStepClick={this.handleStepEvent}
steps={this.state.steps}
selectedStep={this.state.selectedStep}
// tooltipIsOpenSteps={stepsBasic.slice(0, 2)}
/>
</div>
</IconSettings>
);
},
});
}
}

Example.displayName = 'ProgressIndicatorDefault';

export default Example; // export is replaced with `ReactDOM.render(<Example />, mountNode);` at runtime
2 changes: 1 addition & 1 deletion components/progress-indicator/__examples__/step-error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Example = createReactClass({

render () {
return (
<div style={{ padding: '2rem 1rem 0px' }}>
<div style={{ padding: '4rem 1rem 0px' }}>
<ProgressIndicator {...this.props} />
</div>
);
Expand Down
44 changes: 31 additions & 13 deletions components/progress-indicator/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import React from 'react';
import PropTypes from 'prop-types';

import assign from 'lodash.assign';

import find from 'lodash.find';

// ### shortid
Expand All @@ -26,10 +24,17 @@ const propTypes = {
/**
* **Assistive text for accessibility**
* This object is merged with the default props object on every render.
* * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`
* * `completedStep`: Label for a completed step. The default is `Completed Step`
* * `disabledStep`: Label for disabled step. The default is `Disabled Step`
* * `errorStep`: Label for a step with an error. The default is `Error Step`
* * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`. You will need to calculate the percentage yourself if changing this string.
* * `step`: Label for a step. It will be typically followed by the number of the step such as "Step 1".
*/
assistiveText: PropTypes.shape({
completedStep: PropTypes.string,
disabledStep: PropTypes.string,
percentage: PropTypes.string,
step: PropTypes.string,
}),
/**
* CSS class names to be added to the container element. `array`, `object`, or `string` are accepted.
Expand All @@ -49,7 +54,7 @@ const propTypes = {
*/
disabledSteps: PropTypes.array,
/**
* Stores all error steps. It is an array of step objects and usually there is only one error step, the current step.
* 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 **
*/
errorSteps: PropTypes.array,
/**
Expand Down Expand Up @@ -106,7 +111,12 @@ const defaultSteps = [
];

const defaultProps = {
assistiveText: {},
assistiveText: {
completedStep: 'Completed',
disabledStep: 'Disabled',
errorStep: 'Error',
step: 'Step',
},
errorSteps: [],
completedSteps: [],
disabledSteps: [],
Expand Down Expand Up @@ -165,10 +175,17 @@ class ProgressIndicator extends React.Component {

render () {
// Merge objects of strings with their default object
const assistiveText = this.props
? assign({}, defaultProps.assistiveText, this.props.assistiveText)
: defaultProps.assistiveText;

const assistiveText = {
...defaultProps.assistiveText,
...this.props.assistiveText,
};

const {
selectedStep,
disabledSteps,
errorSteps,
completedSteps,
} = this.props;
/** 1. preparing data */
const allSteps = this.getSteps();

Expand Down Expand Up @@ -199,13 +216,14 @@ class ProgressIndicator extends React.Component {
>
{allSteps.map((step, i) => (
<Step
assistiveText={assistiveText}
key={`${this.getId()}-${step.id}`}
id={this.getId()}
index={i}
isSelected={findStep(step, this.props.selectedStep)}
isDisabled={findStep(step, this.props.disabledSteps)}
isError={findStep(step, this.props.errorSteps)}
isCompleted={findStep(step, this.props.completedSteps)}
isSelected={findStep(step, selectedStep)}
isDisabled={findStep(step, disabledSteps)}
isError={findStep(step, errorSteps)}
isCompleted={findStep(step, completedSteps)}
onClick={this.props.onStepClick}
onFocus={this.props.onStepFocus}
step={step}
Expand Down
1 change: 0 additions & 1 deletion components/progress-indicator/private/progress-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ProgressBar extends React.Component {
aria-valuemax="100"
aria-valuenow={this.props.value}
role="progressbar"
tabIndex={0}
>
<span
className="slds-progress-bar__value"
Expand Down
46 changes: 34 additions & 12 deletions components/progress-indicator/private/step.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ const displayName = PROGRESS_INDICATOR_STEP;

// ### Prop Types
const propTypes = {
/**
* **Assistive text for accessibility**
* This object is merged with the default props object on every render.
* * `completedStep`: Label for a completed step. The default is `Completed Step`
* * `disabledStep`: Label for disabled step. The default is `Disabled Step`
* * `errorStep`: Label for a step with an error. The default is `Error Step`
* * `percentage`: Label for Progress Bar. The default is `Progress: [this.props.value]%`. You will need to calculate the percentage yourself if changing this string.
* * `step`: Label for a step. It will be typically followed by the number of the step such as "Step 1".
*/
assistiveText: PropTypes.shape({
completedStep: PropTypes.string,
disabledStep: PropTypes.string,
percentage: PropTypes.string,
step: PropTypes.string,
}),
/**
* Id for Steps, ranging in [0, steps.length).
*/
Expand All @@ -30,6 +45,7 @@ const propTypes = {
/**
* Determines if the step has been completed
*/

isCompleted: PropTypes.bool,
/**
* Determines if the step has been disabled
Expand Down Expand Up @@ -91,15 +107,15 @@ class Step extends React.Component {
const icon = renderIcon ? (
<ButtonIcon
category="utility"
name={this.props.isError ? 'warning' : 'success'}
name={this.props.isError ? 'error' : 'success'}
/>
) : null;

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

const stepButton = props.isDisabled ? (
<span
<a
className={classNames(
'slds-button',
{ 'slds-button_icon': renderIcon },
Expand All @@ -113,9 +129,12 @@ class Step extends React.Component {
>
{icon}
<span className="slds-assistive-text">
{props.step.assistiveText || `Step ${props.index + 1}: ${status}`}
{this.props.step.assistiveText ||
`${props.assistiveText.step} ${props.index + 1}: ${
props.step.label
} - ${status}`}
</span>
</span>
</a>
) : (
<button
className={classNames(
Expand All @@ -128,10 +147,14 @@ class Step extends React.Component {
onFocus={handleFocus}
aria-describedby={`progress-indicator-tooltip-${this.props.step.id ||
this.props.index}`}
aria-current={this.props.isSelected ? 'step' : null}
>
{icon}
<span className="slds-assistive-text">
{props.step.assistiveText || `Step ${props.index + 1}: ${status}`}
{this.props.step.assistiveText ||
`${props.assistiveText.step} ${props.index + 1}: ${
props.step.label
}${status ? ` - ${status}` : ''}`}
</span>
</button>
);
Expand All @@ -141,22 +164,21 @@ class Step extends React.Component {

render () {
const renderIcon = this.props.isCompleted || this.props.isError;
// step status (one of ['Error', 'Completed', 'Active', 'Uncompleted'])
let status = '';
if (this.props.isError) {
status = 'Error';
status = this.props.assistiveText.errorStep;
} else if (this.props.isCompleted) {
status = 'Completed';
} else if (this.props.isSelected) {
status = 'Active';
} else status = 'Uncompleted';
status = this.props.assistiveText.completedStep;
} else if (this.props.isDisabled) {
status = this.props.assistiveText.disabledStep;
}

const tooltipProps = {
align: 'top',
id: `progress-indicator-tooltip-${this.props.step.id ||
this.props.index}`,
content: this.props.step.label,
theme: this.props.isError ? 'error' : 'info',
theme: 'info',
triggerStyle: { display: !renderIcon ? 'flex' : '' },
};

Expand Down
2 changes: 1 addition & 1 deletion components/story-based-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export Tree from '../components/tree/__docs__/storybook-stories';
// export Notification from '../components/notification/__docs__/storybook-stories';
// export Panel from '../components/panel/__docs__/storybook-stories';
// export Popover from '../components/popover/__docs__/storybook-stories';
// export ProgressIndicator from '../components/progress-indicator/__docs__/storybook-stories';
export ProgressIndicator from '../components/progress-indicator/__docs__/storybook-stories';
// export Picklist from '../components/menu-picklist/__docs__/storybook-stories';
// export Spinner from '../components/spinner/__docs__/storybook-stories';
// export TimePicker from '../components/time-picker/__docs__/storybook-stories';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading