Skip to content

Fix for Issue #2889 Challenge listing prize read out #3168

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 1 commit into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ export default function Bonus({
prizeUnitSymbol,
}) {
return (
<div styleName="bonus">
<span styleName="name">
{name}
<div styleName="bonus" aria-label={`${name} bonus is ${prizeUnitSymbol}${prize.toLocaleString()}`}>
<span aria-hidden="true">
<span styleName="name">
{name}
</span>
{prizeUnitSymbol}
{prize.toLocaleString()}
</span>
{prizeUnitSymbol}
{prize.toLocaleString()}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import PT from 'prop-types';
import React from 'react';
import './style.scss';

const suffixes = ['th', 'st', 'nd', 'rd'];
const getOrdinalSuffix = (n) => {
const v = n % 100;
return suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0];
};

/**
* A single prise component.
* It renders a round-shaped medal with the specified place number inside it,
Expand All @@ -15,12 +21,14 @@ export default function Prize({
let medalStyleName = 'medal';
if (place <= 3) medalStyleName += ` place-${place}`;
return (
<div styleName="prize">
<span styleName={medalStyleName}>
{place}
<div styleName="prize" aria-label={`${place}${getOrdinalSuffix(place)} prize is ${prizeUnitSymbol}${prize.toLocaleString()}`}>
<span aria-hidden="true">
<span styleName={medalStyleName}>
{place}
</span>
{prizeUnitSymbol}
{prize.toLocaleString()}
</span>
{prizeUnitSymbol}
{prize.toLocaleString()}
</div>
);
}
Expand Down