File tree 3 files changed +21
-6
lines changed
page-typing-test/lib/components
3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,11 @@ const factory = (intl: IntlShape): IntlNumbers => {
44
44
style : "percent" ,
45
45
maximumFractionDigits : opts ,
46
46
} ;
47
+ } else if ( opts . style !== "percent" ) {
48
+ opts = {
49
+ ...opts ,
50
+ style : "percent" ,
51
+ } ;
47
52
}
48
53
// Do not round up to 100% if the value is less than one.
49
54
// Add decimal digits instead.
Original file line number Diff line number Diff line change
1
+ import { useIntlNumbers } from "@keybr/intl" ;
1
2
import { useFormatter } from "@keybr/lesson-ui" ;
2
3
import {
3
4
AnimationFrames ,
@@ -9,19 +10,23 @@ import { useEffect, useState } from "react";
9
10
import { type ReplayState } from "../session/index.ts" ;
10
11
11
12
export function ReplayProgress ( { stepper } : { readonly stepper : ReplayState } ) {
13
+ const { formatInteger } = useIntlNumbers ( ) ;
12
14
const { formatSpeed } = useFormatter ( ) ;
13
- const { progress, time } = useReplayProgress ( stepper ) ;
15
+ const {
16
+ progress : { progress, length, speed } ,
17
+ time,
18
+ } = useReplayProgress ( stepper ) ;
14
19
return (
15
20
< Para align = "center" >
16
21
< NameValue
17
22
name = "Progress"
18
- value = { `${ progress . progress } /${ progress . length } ` }
23
+ value = { `${ formatInteger ( progress ) } /${ formatInteger ( length ) } ` }
19
24
/>
20
25
< NameValue
21
26
name = "Time"
22
27
value = { formatDuration ( time , { showMillis : true } ) }
23
28
/>
24
- < NameValue name = "Speed" value = { formatSpeed ( progress . speed ) } />
29
+ < NameValue name = "Speed" value = { formatSpeed ( speed ) } />
25
30
</ Para >
26
31
) ;
27
32
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export const TestProgress0 = memo(function TestProgress({
10
10
} : {
11
11
readonly progress : Progress ;
12
12
} ) {
13
- const { formatNumber , formatPercents } = useIntlNumbers ( ) ;
13
+ const { formatInteger , formatPercents } = useIntlNumbers ( ) ;
14
14
const { formatSpeed } = useFormatter ( ) ;
15
15
return (
16
16
< Para className = { styles . root } >
@@ -21,9 +21,14 @@ export const TestProgress0 = memo(function TestProgress({
21
21
< div className = { styles . info } >
22
22
< Value value = { formatDuration ( time , { showMillis : true } ) } />
23
23
{ " / " }
24
- < Value value = { formatNumber ( length ) } />
24
+ < Value value = { formatInteger ( length ) } />
25
25
{ " / " }
26
- < Value value = { formatPercents ( progress ) } />
26
+ < Value
27
+ value = { formatPercents ( progress , {
28
+ minimumFractionDigits : 2 ,
29
+ maximumFractionDigits : 2 ,
30
+ } ) }
31
+ />
27
32
{ " / " }
28
33
< Value value = { formatSpeed ( speed ) } />
29
34
</ div >
You can’t perform that action at this time.
0 commit comments