-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathclass_box.tsx
81 lines (79 loc) · 2.29 KB
/
class_box.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"use client";
import { useDisclosure } from "@mantine/hooks";
import {
Button,
Card,
List,
ListItem,
ProgressRoot,
ProgressSection,
Title,
} from "@mantine/core";
import classes from "./avm2.module.css";
import React from "react";
import {
ClassStatus,
displayedPercentage,
} from "@/app/compatibility/avm2/report_utils";
import { ProgressIcon } from "@/app/compatibility/avm2/icons";
import { useTranslation } from "@/app/translate";
export function ClassBox(props: ClassStatus) {
const { t } = useTranslation();
const [opened, { toggle }] = useDisclosure(false);
const pctDone = displayedPercentage(
props.summary.impl_points - props.summary.stub_penalty,
props.summary.max_points,
);
const pctStub =
props.summary.impl_points === props.summary.max_points
? 100 - pctDone
: displayedPercentage(
props.summary.stub_penalty,
props.summary.max_points,
);
return (
<Card bg="var(--ruffle-blue-9)" className={classes.class}>
<Title order={4}>
{props.name || t("compatibility.avm2.package-level")}
</Title>
<ProgressRoot size="xl" radius={10} className={classes.progress}>
<ProgressSection
striped
value={pctDone}
color="var(--mantine-color-green-9)"
title={`${pctDone}% ${t("compatibility.done")}`}
></ProgressSection>
{pctStub > 0 && (
<ProgressSection
striped
value={pctStub}
color="ruffle-orange"
className={classes.progressStub}
title={`${pctStub}% ${t("compatibility.partial")}`}
></ProgressSection>
)}
</ProgressRoot>
{props.items.length > 0 && (
<>
<Button
size="compact-sm"
className={classes.showMemberButton}
onClick={toggle}
>
{opened
? t("compatibility.avm2.hide")
: t("compatibility.avm2.show")}{" "}
{t("compatibility.avm2.missing-members")}
</Button>
<List hidden={!opened}>
{props.items.map((item, i) => (
<ListItem key={i} icon={ProgressIcon(item.icon)}>
<code>{item.name}</code>
</ListItem>
))}
</List>
</>
)}
</Card>
);
}