Skip to content
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

feat(progress-indicator): adds hidden span to announce state of completion #5125

Merged
merged 10 commits into from
Jan 24, 2020
2 changes: 2 additions & 0 deletions packages/components/docs/sass.md
Original file line number Diff line number Diff line change
Expand Up @@ -20398,6 +20398,7 @@ Progress indicator styles
margin-left: $carbon--spacing-06;
margin-top: rem(28px);
color: $text-01;
text-align: start;
}

//CURRENT STYLING
Expand Down Expand Up @@ -20434,6 +20435,7 @@ Progress indicator styles

//interactive button
.#{$prefix}--progress-step-button {
@include button-reset();
display: flex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
margin-left: $carbon--spacing-06;
margin-top: rem(28px);
color: $text-01;
text-align: start;
}

//CURRENT STYLING
Expand Down Expand Up @@ -168,6 +169,7 @@

//interactive button
.#{$prefix}--progress-step-button {
@include button-reset();
display: flex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('ProgressIndicator', () => {
mountedList
.find(ProgressStep)
.at(0)
.find('[role="button"]')
.find('button')
.simulate('click');
expect(mockOnChange).toHaveBeenCalledWith(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ import { CheckmarkOutline16, Warning16 } from '@carbon/icons-react';
import { keys, matches } from '../../internal/keyboard';

const { prefix } = settings;

const defaultRenderLabel = props => <p {...props} />;
export const ProgressStep = ({ ...props }) => {
const {
label,
description,
className,
current,
complete,
invalid,
secondaryLabel,
disabled,
onClick,
renderLabel: ProgressStepLabel,
} = props;

export function ProgressStep({
label,
description,
className,
current,
complete,
invalid,
secondaryLabel,
disabled,
onClick,
renderLabel: ProgressStepLabel,
}) {
const classes = classnames({
[`${prefix}--progress-step`]: true,
[`${prefix}--progress-step--current`]: current,
Expand Down Expand Up @@ -70,16 +70,31 @@ export const ProgressStep = ({ ...props }) => {
);
};

let message = 'Incomplete';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g11n; Do we want to add a prop to let app specify the assistive text? (Though translate-ability for assistive text didn't use to be a hard-requirements, I have seen several issues asking for it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I added it, it's the first time I've done it so let me know if it all looks good!


if (current) {
message = 'Current';
}

if (complete) {
message = 'Complete';
}

if (invalid) {
message = 'Invalid';
}

return (
<li className={classes} aria-disabled={disabled}>
<div
<li className={classes}>
<button
className={classnames(`${prefix}--progress-step-button`, {
[`${prefix}--progress-step-button--unclickable`]: !onClick || current,
})}
role="button"
aria-disabled={disabled}
tabIndex={!current && onClick ? 0 : -1}
onClick={!current ? onClick : undefined}
onKeyDown={handleKeyDown}>
<span className={`${prefix}--assistive-text`}>{message}</span>
<SVGIcon
complete={complete}
current={current}
Expand All @@ -94,10 +109,10 @@ export const ProgressStep = ({ ...props }) => {
<p className={`${prefix}--progress-optional`}>{secondaryLabel}</p>
) : null}
<span className={`${prefix}--progress-line`} />
</div>
</button>
</li>
);
};
}

ProgressStep.propTypes = {
/**
Expand Down