File tree 2 files changed +12
-7
lines changed
src/app/compatibility/avm2
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -15,18 +15,19 @@ import React from "react";
15
15
import {
16
16
ClassStatus ,
17
17
ProgressIcon ,
18
+ displayedPercentage
18
19
} from "@/app/compatibility/avm2/report_utils" ;
19
20
20
21
export function ClassBox ( props : ClassStatus ) {
21
22
const [ opened , { toggle } ] = useDisclosure ( false ) ;
22
- const pctDone = Math . ceil (
23
- ( ( props . summary . impl_points - props . summary . stub_penalty ) /
24
- props . summary . max_points ) *
25
- 100 ,
26
- ) ;
27
- const pctStub = Math . ceil (
28
- ( props . summary . stub_penalty / props . summary . max_points ) * 100 ,
23
+ const pctDone = displayedPercentage (
24
+ props . summary . impl_points - props . summary . stub_penalty ,
25
+ props . summary . max_points ,
29
26
) ;
27
+ const pctStub =
28
+ props . summary . impl_points === props . summary . max_points
29
+ ? 100 - pctDone
30
+ : displayedPercentage ( props . summary . stub_penalty , props . summary . max_points ) ;
30
31
return (
31
32
< Card bg = "var(--ruffle-blue-9)" className = { classes . class } >
32
33
< Title order = { 4 } > { props . name || "(Package level)" } </ Title >
Original file line number Diff line number Diff line change @@ -143,3 +143,7 @@ export async function getReportByNamespace(): Promise<{ [name: string]: Namespac
143
143
}
144
144
return byNamespace ;
145
145
}
146
+
147
+ export function displayedPercentage ( value : number , max : number ) : number {
148
+ return value === 0 ? value : Math . max ( 1 , Math . floor ( value / max * 100 ) ) ;
149
+ }
You can’t perform that action at this time.
0 commit comments