File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
src/app/compatibility/avm2 Expand file tree Collapse file tree 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";
1515import {
1616 ClassStatus ,
1717 ProgressIcon ,
18+ displayedPercentage ,
1819} from "@/app/compatibility/avm2/report_utils" ;
1920
2021export function ClassBox ( props : ClassStatus ) {
2122 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 ,
2926 ) ;
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 ) ;
3031 return (
3132 < Card bg = "var(--ruffle-blue-9)" className = { classes . class } >
3233 < 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
143143 }
144144 return byNamespace ;
145145}
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