Skip to content

Commit 973a75d

Browse files
committed
Only show implementation 100% when everything is implemented (fix ruffle-rs#290)
1 parent 1536646 commit 973a75d

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/app/compatibility/avm2/class_box.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ import React from "react";
1515
import {
1616
ClassStatus,
1717
ProgressIcon,
18+
displayedPercentage
1819
} from "@/app/compatibility/avm2/report_utils";
1920

2021
export 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>

src/app/compatibility/avm2/report_utils.tsx

+4
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)