File tree 2 files changed +20
-10
lines changed
src/shared/components/challenge-listing/ChallengeCard/Prize/Tip
2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,14 @@ export default function Bonus({
14
14
prizeUnitSymbol,
15
15
} ) {
16
16
return (
17
- < div styleName = "bonus" >
18
- < span styleName = "name" >
19
- { name }
17
+ < div styleName = "bonus" aria-label = { `${ name } bonus is ${ prizeUnitSymbol } ${ prize . toLocaleString ( ) } ` } >
18
+ < span aria-hidden = "true" >
19
+ < span styleName = "name" >
20
+ { name }
21
+ </ span >
22
+ { prizeUnitSymbol }
23
+ { prize . toLocaleString ( ) }
20
24
</ span >
21
- { prizeUnitSymbol }
22
- { prize . toLocaleString ( ) }
23
25
</ div >
24
26
) ;
25
27
}
Original file line number Diff line number Diff line change @@ -2,6 +2,12 @@ import PT from 'prop-types';
2
2
import React from 'react' ;
3
3
import './style.scss' ;
4
4
5
+ const suffixes = [ 'th' , 'st' , 'nd' , 'rd' ] ;
6
+ const getOrdinalSuffix = ( n ) => {
7
+ const v = n % 100 ;
8
+ return suffixes [ ( v - 20 ) % 10 ] || suffixes [ v ] || suffixes [ 0 ] ;
9
+ } ;
10
+
5
11
/**
6
12
* A single prise component.
7
13
* It renders a round-shaped medal with the specified place number inside it,
@@ -15,12 +21,14 @@ export default function Prize({
15
21
let medalStyleName = 'medal' ;
16
22
if ( place <= 3 ) medalStyleName += ` place-${ place } ` ;
17
23
return (
18
- < div styleName = "prize" >
19
- < span styleName = { medalStyleName } >
20
- { place }
24
+ < div styleName = "prize" aria-label = { `${ place } ${ getOrdinalSuffix ( place ) } prize is ${ prizeUnitSymbol } ${ prize . toLocaleString ( ) } ` } >
25
+ < span aria-hidden = "true" >
26
+ < span styleName = { medalStyleName } >
27
+ { place }
28
+ </ span >
29
+ { prizeUnitSymbol }
30
+ { prize . toLocaleString ( ) }
21
31
</ span >
22
- { prizeUnitSymbol }
23
- { prize . toLocaleString ( ) }
24
32
</ div >
25
33
) ;
26
34
}
You can’t perform that action at this time.
0 commit comments