Skip to content

Commit dd0f2ed

Browse files
committed
compatibility/avm2: Split icons into their own component
1 parent 8d783b4 commit dd0f2ed

File tree

4 files changed

+59
-58
lines changed

4 files changed

+59
-58
lines changed

src/app/compatibility/avm2/class_box.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import classes from "./avm2.module.css";
1414
import React from "react";
1515
import {
1616
ClassStatus,
17-
ProgressIcon,
1817
displayedPercentage,
1918
} from "@/app/compatibility/avm2/report_utils";
19+
import { ProgressIcon } from "@/app/compatibility/avm2/icons";
2020

2121
export function ClassBox(props: ClassStatus) {
2222
const [opened, { toggle }] = useDisclosure(false);

src/app/compatibility/avm2/icons.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { rem, ThemeIcon } from "@mantine/core";
2+
import { IconCheck, IconProgress, IconX } from "@tabler/icons-react";
3+
4+
export function IconDone() {
5+
return (
6+
<ThemeIcon
7+
size={20}
8+
radius="xl"
9+
color="var(--mantine-color-green-9)"
10+
title="Done"
11+
>
12+
<IconCheck
13+
color="white"
14+
style={{ width: rem(12), height: rem(12) }}
15+
stroke={4}
16+
/>
17+
</ThemeIcon>
18+
);
19+
}
20+
21+
export function IconStub() {
22+
return (
23+
<ThemeIcon size={20} radius="xl" title="Partial">
24+
<IconProgress
25+
color="#3c1518"
26+
style={{ width: rem(12), height: rem(12) }}
27+
stroke={4}
28+
/>
29+
</ThemeIcon>
30+
);
31+
}
32+
33+
export function IconMissing() {
34+
return (
35+
<ThemeIcon size={20} radius="xl" color="#3c1518" title="Missing">
36+
<IconX
37+
color="white"
38+
style={{ width: rem(12), height: rem(12) }}
39+
stroke={4}
40+
/>
41+
</ThemeIcon>
42+
);
43+
}
44+
45+
export function ProgressIcon(type: "stub" | "missing" | "done") {
46+
switch (type) {
47+
case "stub":
48+
return <IconStub />;
49+
case "missing":
50+
return <IconMissing />;
51+
case "done":
52+
return <IconDone />;
53+
}
54+
}

src/app/compatibility/avm2/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import classes from "./avm2.module.css";
1313
import { ClassBox } from "@/app/compatibility/avm2/class_box";
1414
import {
1515
getReportByNamespace,
16+
NamespaceStatus,
17+
} from "@/app/compatibility/avm2/report_utils";
18+
import {
1619
IconDone,
1720
IconMissing,
1821
IconStub,
19-
NamespaceStatus,
20-
} from "@/app/compatibility/avm2/report_utils";
22+
} from "@/app/compatibility/avm2/icons";
2123
import Link from "next/link";
2224

2325
function NamespaceBox(props: NamespaceStatus) {

src/app/compatibility/avm2/report_utils.tsx

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,4 @@
1-
import { rem, ThemeIcon } from "@mantine/core";
2-
import { IconCheck, IconProgress, IconX } from "@tabler/icons-react";
31
import { fetchReport } from "@/app/downloads/github";
4-
import React from "react";
5-
6-
export function IconDone() {
7-
return (
8-
<ThemeIcon
9-
size={20}
10-
radius="xl"
11-
color="var(--mantine-color-green-9)"
12-
title="Done"
13-
>
14-
<IconCheck
15-
color="white"
16-
style={{ width: rem(12), height: rem(12) }}
17-
stroke={4}
18-
/>
19-
</ThemeIcon>
20-
);
21-
}
22-
23-
export function IconStub() {
24-
return (
25-
<ThemeIcon size={20} radius="xl" title="Partial">
26-
<IconProgress
27-
color="#3c1518"
28-
style={{ width: rem(12), height: rem(12) }}
29-
stroke={4}
30-
/>
31-
</ThemeIcon>
32-
);
33-
}
34-
35-
export function IconMissing() {
36-
return (
37-
<ThemeIcon size={20} radius="xl" color="#3c1518" title="Missing">
38-
<IconX
39-
color="white"
40-
style={{ width: rem(12), height: rem(12) }}
41-
stroke={4}
42-
/>
43-
</ThemeIcon>
44-
);
45-
}
46-
47-
export function ProgressIcon(type: "stub" | "missing" | "done") {
48-
switch (type) {
49-
case "stub":
50-
return <IconStub />;
51-
case "missing":
52-
return <IconMissing />;
53-
case "done":
54-
return <IconDone />;
55-
}
56-
}
572

583
export interface SummaryStatistics {
594
max_points: number;

0 commit comments

Comments
 (0)