Skip to content

Commit

Permalink
Bug 1619645 - Improve wording for ProgressBar aria label (#6470)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tintinator authored Sep 2, 2020
1 parent 030c67a commit 910c628
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions ui/shared/ProgressBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,37 @@ import { Progress } from 'reactstrap';

import SimpleTooltip from './SimpleTooltip';

const ProgressBar = ({ magnitude, regression, color }) => (
<SimpleTooltip
text={
<Progress
multi
aria-label={`Magnitude of difference based on lower is better. Metric: ${
regression ? 100 - magnitude : magnitude
} % regressed`}
>
{/* the % of the bars that are colored and transparent is based on the newIsBetter metric,
which determines whether the colored bar for magnitude is displayed on the left or right */}
<div aria-hidden="true" className="progress w-100">
<Progress
bar
value={regression ? 100 - magnitude : magnitude}
color={regression ? 'transparent' : color}
/>
<Progress
bar
value={regression ? magnitude : 100 - magnitude}
color={regression ? color : 'transparent'}
/>
</div>
</Progress>
}
tooltipText="Relative magnitude of change (scale from 0 - 20%+)"
/>
);
const ProgressBar = ({ magnitude, regression, color }) => {
const truncMag = regression
? (Math.floor((100 - magnitude) * 100) / 100).toFixed(2)
: (Math.floor(magnitude * 100) / 100).toFixed(2);
return (
<SimpleTooltip
text={
<Progress
multi
aria-label={`Lower is better. Metric: ${truncMag} % regressed`}
>
{/* the % of the bars that are colored and transparent is based on the newIsBetter metric,
which determines whether the colored bar for magnitude is displayed on the left or right */}
<div aria-hidden="true" className="progress w-100">
<Progress
bar
value={regression ? 100 - magnitude : magnitude}
color={regression ? 'transparent' : color}
/>
<Progress
bar
value={regression ? magnitude : 100 - magnitude}
color={regression ? color : 'transparent'}
/>
</div>
</Progress>
}
tooltipText="Relative magnitude of change (scale from 0 - 20%+)"
/>
);
};

ProgressBar.propTypes = {
regression: PropTypes.bool.isRequired,
Expand Down

0 comments on commit 910c628

Please sign in to comment.